Resize Entry, Button – Fyne GUI Golang tutorial 50
Resize Entry, Button – Fyne GUI Golang tutorial 50
Fyne Resize Entry
Create New Entry/Input widget
entry := widget.NewEntry()
Set place holder Text
entry.SetPlaceHolder(“Enter your name”)
Resize widget Size
entry.Resize(fyne.NewSize(250, 30))
Position of widget on parent window
entry.Move(fyne.NewPos(40, 50))
Fyne Resize Button
Create a Button and Set button label. Here “submit” is my button label
btn_submit := widget.NewButton("Submit", nil)Resize button size according to your needs.
btn_submit.Resize(fyne.NewSize(150, 30))
Set position of your button on parent window
btn_submit.Move(fyne.NewPos(40, 200))
Source Code
package main // import fyne import ( "fyne.io/fyne/v2" "fyne.io/fyne/v2/app" "fyne.io/fyne/v2/container" "fyne.io/fyne/v2/widget" ) func main() { // New app a := app.New() // New Window & title w := a.NewWindow("Resize any widget") //Resize main/parent window w.Resize(fyne.NewSize(400, 400)) // 1st Widget Entry entry := widget.NewEntry() entry.SetPlaceHolder("Enter your name") entry.Resize(fyne.NewSize(250, 30)) // my widget size entry.Move(fyne.NewPos(40, 50)) // position of widget entry_email := widget.NewEntry() entry_email.SetPlaceHolder("Enter your email") entry_email.Resize(fyne.NewSize(250, 30)) // my widget size entry_email.Move(fyne.NewPos(40, 100)) // position of widget entry_address := widget.NewEntry() entry_address.SetPlaceHolder("Enter your name") entry_address.Resize(fyne.NewSize(250, 30)) // my widget size entry_address.Move(fyne.NewPos(40, 150)) // position of widget // button btn_submit := widget.NewButton("Submit", nil) btn_submit.Resize(fyne.NewSize(150, 30)) // my widget size btn_submit.Move(fyne.NewPos(40, 200)) // position of widget w.SetContent( container.NewWithoutLayout( entry, entry_email, entry_address, btn_submit, ), ) //show and run w.ShowAndRun() }
[easy_media_download url=”http://blogvali.com/wp-content/uploads/fyne-golang-downloads/main50.go” text=”Download Code” color=”red_darker”]
Fyne Golang GUI Course