Toolbar icons- Fyne GUI Golang tutorial 65

Toolbar icons- Fyne GUI Golang tutorial 65

Fyne Toolbar widget is another fyne Golang example and tutorial.

fyne widgets are very easy to use but without proper fyne documentation it may not be easy.

Yesterday we covered fyne table which is an amazing fyne widget to create tables.

 

 


package main
// import fyne
import (
    "fmt"
    "fyne.io/fyne/v2"
    "fyne.io/fyne/v2/app"
    "fyne.io/fyne/v2/container"
    "fyne.io/fyne/v2/theme"
    "fyne.io/fyne/v2/widget"
)
func main() {
    // new app
    a := app.New()
    // new title and window
    w := a.NewWindow("Tool bar - music player ui")
    // resize main window
    w.Resize(fyne.NewSize(400, 400))
    // new widget---- Tool bar
    toolbar := widget.NewToolbar(
        //toolbar items
        widget.NewToolbarAction(
            // first argument is icon
            // 2nd is action/func(){}
            theme.MediaPlayIcon(), func() {
                fmt.Println("Play music...")
            },
        ),
        // copy paste for other items
        // pause
        widget.NewToolbarAction(
            // first argument is icon
            // 2nd is action/func(){}
            theme.MediaPauseIcon(), func() {
                fmt.Println("Pause music...")
            },
        ),
        widget.NewToolbarAction(
            // first argument is icon
            // 2nd is action/func(){}
            theme.MediaStopIcon(), func() {
                fmt.Println("Stop music...")
            },
        ),
        // spacer widget
        widget.NewToolbarSpacer(),
        // new item for support
        /// copy paste
        widget.NewToolbarAction(
            // first argument is icon
            // 2nd is action/func(){}
            theme.HelpIcon(), func() {
                fmt.Println("support music...")
            },
        ),
    )
    // put everthing in a container
    // c := container.NewHBox(toolbar)
    // letss change container
    c := container.NewBorder(
        // 5 elements / arguments
        // top, right,left,bottom, center
        toolbar, nil, nil, nil, widget.NewLabel("Content here"),
    )
    w.SetContent(c)
    w.ShowAndRun()
}

 

[easy_media_download url=”http://blogvali.com/wp-content/uploads/fyne-golang-downloads/main56.go” text=”Download Code” color=”red_darker”]

Fyne Golang GUI Course

 

Tony BB
 

TonyBB is a Coach , marketer, hypnotist and a founder of RSKVF Production who specializes in providing simple, affordable, and easy to use solutions for Life.

Click Here to Leave a Comment Below 0 comments

Leave a Reply: