Class 2: Fyne GoLang GUI – Resize Window Tutorial
Welcome back to our Fyne and GoLang GUI course! ???? In this second class, we’ll dive into resizing GUI windows using Fyne. This tutorial will guide you through writing an 8-line program to resize a window, covering these steps:
STEP:1 Define the main package
package main
STEP:2 importing fyne v2
import "fyne.io/fyne/v2"
STEP:3 import the fyne app
import "fyne.io/fyne/v2/app"
STEP:4 Define the main function
func main(){}
STEP:5 Create a new app instance
a := app.New()
STEP:6 Create a new window with a title
w := a.NewWindow("Title: Tutorial 2 Resize Window")
STEP:7 Resize Fyne App Window
w.Resize(fyne.NewSize(700,700))
1.First value is width
2. 2nd value is height
STEP:8 Show the window and Run the app
w.ShowAndRun()
STEP:9 Run your project in the terminal
go run main.go
SOURCE CODE
// Define the main package package main // importing fyne v2 import "fyne.io/fyne/v2" // import the fyne app import "fyne.io/fyne/v2/app" // Define the main function func main(){ // Create a new app instance a := app.New() // Create a new window with a title w := a.NewWindow("Title: Tutorial 2 Resize Window") // Resize Fyne App Window w.Resize(fyne.NewSize(700,700)) //First value is width //2nd value is height //Show the window and Run the app w.ShowAndRun() // Run your project in the terminal // go run main.go }