![]() ![]() Now insert these two lines, below the two you just added: This allows you to treat all of the children of a widget as a group for example, you could hide the Gtk.Box, which would also hide all of its children at the same time. Once packed in the Gtk.Box, the Gtk.Image is considered a child of the Gtk.Box. This makes handling window resizing much easier, and widgets should automatically take a sensible size in most situations.Īlso note how the widgets are organized in a hierarchy. You don't position widgets by giving them a precise x,y-coordinate location in the window rather, they are positioned relative to one another. Gtk containers (and widgets) dynamically expand to fill the available space, if you let them. Pack_start takes 4 arguments: the widget that is to be added to the Gtk.Box ( child) whether the Gtk.Box should grow larger when the new widget is added ( expand) whether the new widget should take up all of the extra space created if the Gtk.Box gets bigger ( fill) and how much space there should be, in pixels, between the widget and its neighbors inside the Gtk.Box ( padding). Then, the image widget is added ( packed) into the main_box container using Gtk.Box's pack_start method. The first line creates a new Gtk.Image called image, which will be used to display an image file. Main_box.pack_start (this.image, true, true, 0) We'll do this shortly, but for now you can just hit Ctrl+ C in the terminal window to quit the program. This is because we haven't set up a signal handler to deal with the window's destroy (close) signal yet. You will notice that the application does not quit when you close the window. The main loop listens for events (signals) from the user interface and then calls a signal handler which will do something useful. In Gtk, every widget is hidden by default.įinally, Gtk.main runs the main loop - in other words, it executes the program. The next line explicitly shows the window. In this case we are setting the title of the window. You can pass several properties to the window's constructor by using the syntax. The next line creates the main window by creating a new Gtk.Window object. ![]() Gtk.init initializes the Gtk library this statement is mandatory for all Gtk programs. The libraries are provided by GObject Introspection (gi), which provides language bindings for many GNOME libraries. The first line imports the Gtk namespace (that is, it includes the Gtk library). ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |