@@ -17,37 +17,39 @@ _Note: this page assumes that you have already installed GoGi by completing the
17
17
18
18
1 . Add the following code to your editor:
19
19
20
- package main
21
-
22
- func main() {
23
- // Run the window event loop function as the main function
24
- gimain.Main(func() {
25
- mainrun()
26
- })
27
- }
28
-
29
- func mainrun() {
30
- // Create a window called My App Window with width 1024 and height 768
31
- win := gi.NewMainWindow("myapp", "My App Window", 1024, 768)
32
- // Get the viewport within our window
33
- vp := win.WinViewport2D()
34
- // Start a protect update on the viewport
35
- updt := vp.UpdateStart()
36
- // Create a standard frame within the window and make it the main widget
37
- mfr := win.SetMainFrame()
38
-
39
- // Add a label to the main frame with the text "Hello, World!"
40
- label := gi.AddNewLabel(mfr, "label", "Hello, World!")
41
-
42
- // End the protected update on the viewport without a signal.
43
- // Update signals cause things to be redrawn, which is unnecessary at the start
44
- // because it is already drawing everything new.
45
- vp.UpdateEndNoSig(updt)
46
- // Start the event loop that keeps the window rendering.
47
- // This is a blocking call, and it will not return until
48
- // the user quits the app or gi.Quit() is called
49
- win.StartEventLoop()
50
- }
20
+ ``` go
21
+ package main
22
+
23
+ func main () {
24
+ // Run the window event loop function as the main function
25
+ gimain.Main (func () {
26
+ mainrun ()
27
+ })
28
+ }
29
+
30
+ func mainrun () {
31
+ // Create a window called My App Window with width 1024 and height 768
32
+ win := gi.NewMainWindow (" myapp" , " My App Window" , 1024 , 768 )
33
+ // Get the viewport within our window
34
+ vp := win.WinViewport2D ()
35
+ // Start a protect update on the viewport
36
+ updt := vp.UpdateStart ()
37
+ // Create a standard frame within the window and make it the main widget
38
+ mfr := win.SetMainFrame ()
39
+
40
+ // Add a label to the main frame with the text "Hello, World!"
41
+ label := gi.AddNewLabel (mfr, " label" , " Hello, World!" )
42
+
43
+ // End the protected update on the viewport without a signal.
44
+ // Update signals cause things to be redrawn, which is unnecessary at the start
45
+ // because it is already drawing everything new.
46
+ vp.UpdateEndNoSig (updt)
47
+ // Start the event loop that keeps the window rendering.
48
+ // This is a blocking call, and it will not return until
49
+ // the user quits the app or gi.Quit() is called
50
+ win.StartEventLoop ()
51
+ }
52
+ ```
51
53
52
54
2 . Update your dependencies by running ` go mod tidy`
53
55
3 . Build the code by running ` go build`
0 commit comments