Login form – Fyne Golang GUI Tutorial 54

Login form – Fyne Golang GUI Tutorial 54



<div>package main</div>
<div>// import fyne</div>
<div>import (</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>func main() {</div>
<div>    // new app</div>
<div>    a := app.New()</div>
<div>    // new title and window</div>
<div>    w := a.NewWindow("New Form")</div>
<div>    // resize window</div>
<div>    w.Resize(fyne.NewSize(400, 400))</div>
<div>    // label empty</div>
<div>    label := widget.NewLabel("")</div>
<div>    // form widget</div>
<div>    form := widget.NewForm(</div>
<div>        // new use form items</div>
<div>        // 2 arguments</div>
<div>        // label, widget</div>
<div>        widget.NewFormItem("Username", widget.NewEntry()),</div>
<div>        // password</div>
<div>        widget.NewFormItem("Password", widget.NewPasswordEntry()),</div>
<div>    )</div>
<div>    // working on cancel and submit functions of form</div>
<div>    form.OnCancel = func() {</div>
<div>        label.Text = "Canceled"</div>
<div>        label.Refresh()</div>
<div>    }</div>
<div>    form.OnSubmit = func() {</div>
<div>        label.Text = "submitted"</div>
<div>        label.Refresh()</div>
<div>    }</div>
<div>    // we are almost done</div>
<div>    w.SetContent(</div>
<div>        container.NewVBox(</div>
<div>            form,</div>
<div>            label,</div>
<div>        ),</div>
<div>    )</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 2 comments
Renan - last year

Which is de variable responsible to store the Username’s input and the Password’s input ?

Tony BB - last year

Use something like this.

1) username := widget.NewEntry()

2) password := widget.NewPasswordEntry()


Leave a Reply: