Select DropDown widget – Fyne Golang GUI tutorial 68

Select DropDown widget – Fyne Golang GUI tutorial 68

<div>package main</div>
<div>// import fyne</div>
<div>import (</div>
<div>    "fmt"</div>
<div>    ""</div>
<div>    ""</div>
<div>    ""</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>


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: