added a function to create the window for the UI.
This commit is contained in:
parent
983ab4ff65
commit
8be17d7c7d
|
@ -1 +1,41 @@
|
||||||
package game
|
package game
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fyne.io/fyne/v2"
|
||||||
|
"fyne.io/fyne/v2/app"
|
||||||
|
"fyne.io/fyne/v2/container"
|
||||||
|
"fyne.io/fyne/v2/layout"
|
||||||
|
"fyne.io/fyne/v2/widget"
|
||||||
|
)
|
||||||
|
|
||||||
|
var TextLabel *widget.Label
|
||||||
|
|
||||||
|
// creates a window for the TicTacToe game application.
|
||||||
|
func CreateWindow() fyne.Window {
|
||||||
|
// Create the app.
|
||||||
|
myApp := app.New()
|
||||||
|
|
||||||
|
// Create a new window for the game application.
|
||||||
|
myWindow := myApp.NewWindow("TicTacToe")
|
||||||
|
|
||||||
|
// Set the text of our TextLabel to TicTacToe
|
||||||
|
TextLabel = widget.NewLabel("TicTacToe")
|
||||||
|
|
||||||
|
// Create a new button with the text "Restart" and a handler function, if it gets pressed.
|
||||||
|
restartButton := widget.NewButton("Restart", func() {
|
||||||
|
// Add logic here to restart the game.
|
||||||
|
})
|
||||||
|
|
||||||
|
// vertical box layout containg the top Items, here the textlabel and the button.
|
||||||
|
topItems := container.NewVBox(TextLabel, restartButton)
|
||||||
|
|
||||||
|
// Generate content for the window using a border layout with the topItems as the only child.
|
||||||
|
content := container.New(layout.NewBorderLayout(topItems, nil, nil, nil), topItems)
|
||||||
|
|
||||||
|
// Set the content and size of the window.
|
||||||
|
myWindow.SetContent(content)
|
||||||
|
myWindow.Resize(fyne.NewSize(300, 300))
|
||||||
|
|
||||||
|
// Return the created window.
|
||||||
|
return myWindow
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue