Select Entry Dropdown Advance – Fyne Golang GUI tutorial 69

Select Entry Dropdown Advance – Fyne Golang GUI tutorial 69

<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 - DropDown advance")</div>
<div>    // resize window</div>
<div>    w.Resize(fyne.NewSize(400, 400))</div>
<div>    // lets create a label</div>
<div>    label1 := widget.NewLabel("...")</div>
<div>    // newselectentry widget</div>
<div>    // []string{} it take only slice of option</div>
<div>    //&amp; you can your options also in run time. Not hardcoded</div>
<div>    select_entry := widget.NewSelectEntry([]string{"peshawar", "multan", "gujrat", "kabul", "dehli"})</div>
<div>    // what to do with the selected entry ?</div>
<div>    // here is what we are going to define</div>
<div>    select_entry.OnSubmitted = func(s string) {</div>
<div>        fmt.Printf("my city %s is awesome", s)</div>
<div>        // update label with our values</div>
<div>        label1.Text = s</div>
<div>        label1.Refresh()</div>
<div>    }</div>
<div>    // container .. we have more than one widgets</div>
<div>    c := container.NewVBox(</div>
<div>        label1,</div>
<div>        select_entry,</div>
<div>    )</div>
<div>    w.SetContent(c)</div>
<div>    w.ShowAndRun()</div>
<div>}</div>
</div>
Download Code

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: