Select DropDown widget – Fyne Golang GUI tutorial 68

Select DropDown widget – Fyne Golang GUI tutorial 68

<div>
<div>package main</div>
<div>// import fyne</div>
<div>import (</div>
<div>    "fmt"</div>
<div>    "fyne.io/fyne/v2"</div>
<div>    "fyne.io/fyne/v2/app"</div>
<div>    "fyne.io/fyne/v2/container"</div>
<div>    "fyne.io/fyne/v2/widget"</div>
<div>)</div>
<div>func main() {</div>
<div>    // New app</div>
<div>    a := app.New()</div>
<div>    // new title and window</div>
<div>    w := a.NewWindow("Select entry widget, drop down")</div>
<div>    // resize window</div>
<div>    w.Resize(fyne.NewSize(400, 400))</div>
<div>    // lets show our selected entry in label</div>
<div>    label1 := widget.NewLabel("...")</div>
<div>    // dropdown/ select entry</div>
<div>    //[]string{} all our option goes in slice</div>
<div>    // s is the variable to get the selected value</div>
<div>    dd := widget.NewSelect(</div>
<div>        []string{"city1-dehli", "London", "islamabad", "kabul"},</div>
<div>        func(s string) {</div>
<div>            fmt.Printf("I selected %s to live forever..", s)</div>
<div>            label1.Text = s</div>
<div>            label1.Refresh()</div>
<div>        })</div>
<div>    // more than one widget. so use container</div>
<div>    c := container.NewVBox(dd, label1)</div>
<div>    w.SetContent(c)</div>
<div>    //show and run</div>
<div>    w.ShowAndRun()</div>
<div>}</div>
</div>

 

[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: