Golang GTK + 3 Tutorial: grid layout

Source: Internet
Author: User
Tags gtk

In the previous example, we used the box layout. Now let's learn another layout, grid. In fact, these la s are similar. If you understand the previous example, it is not difficult to use grid.

Program running effect:

Package mainimport ("github.com/gotk3/gotk3/glib" "github.com/gotk3/gotk3/gtk" "OS") func main () {const appid = "com. nayoso. example "app, _: = GTK. applicationnew (appid, glib. application_flags_none) app. connect ("Activate", func () {onactivate (APP)}) app. run (OS. ARGs)} func onactivate (application * GTK. application) {appwindow, _: = GTK. applicationwindownew (Application) appwindow. settitle ("Grid example") // -- above, the general code is input, and the following is the focus of this example:-D grid, _: = GTK. gridnew () // create the container appwindow. add (GRID) // Add the container to the window // now let's create some buttons to demonstrate the grid effect button1, _: = GTK. buttonnewwithlabel ("button 1") button2, _: = GTK. buttonnewwithlabel ("button 2") button3, _: = GTK. buttonnewwithlabel ("button 3") // Add buttons to the grid. attach (button1, 0, 0, 1, 1) // parameter: left, top, width, high grid. attach (button2, 1, 0, 1, 1) grid. attach (button3, 0, 1, 2, 1) // -- note that the button is in a coordinate axis, with the origin on the top left and the X axis on the right, Y axis down // -- it doesn't matter if you don't like it very much or understand it very well. I will introduce the visual UI design tool appwindow later. showall ()}

You may find that I sometimes use containers and la s to name the same thing. In fact, this is because it has both of these two properties.

Golang GTK + 3 Tutorial: grid layout

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.