Part 2b

Gtk Dialog Box

The Python

We only need to add a few things to our previous example to show the Help About Dialog so lets examine the code we need to add. This line creates an instance of our dialog box using the GtkBuilder.

    self.aboutdialog = self.builder.get_object("aboutdialog")

As in the first tutorial the first line is connected to our menu item signal. When the menu item is activated the define is called. The second line just prints debugging info. The third line gets an instance of the dialog window using the .run() method. If there was some buttons or something added the response can be tested with an if. The code will wait at the .run() line until you press the Close button then the .hide() method will run to close the Help About dialog box.

  def on_gtk_about_activate(self, menuitem, data=None):
    print "help about selected"
    self.response =

The following code is the complete python file. In the same directory as the file was saved save the following python code as
#!/usr/bin/env python

import gtk

class Buglump:

  def on_window1_destroy(self, object, data=None):
    print "quit with cancel"

  def on_gtk_quit_activate(self, menuitem, data=None):
    print "quit from menu"

  def on_gtk_about_activate(self, menuitem, data=None):
    print "help about selected"
    self.response =

  def __init__(self):
    self.gladefile = ""
    self.builder = gtk.Builder()
    self.window = self.builder.get_object("window1")
    self.aboutdialog = self.builder.get_object("aboutdialog1")

if __name__ == "__main__":
  main = Buglump()

View the Results

Now open up a terminal and cd to the directory where your files are. Type in ls and we can see our files.


Now we will make the file executable by changing the mode of the file with chmod command. In the terminal type in chmod +x then type in ls again. Notice how the file is now displayed in green. This means it is an executable file now and can be executed by adding ./ in front of the file name like this ./ The ./ means something like search for the file in the current directory.


Now type ./ and our screen pops up… now click on Help > About and our dialog screen pops up. Click on Credits and License to see what pops up when you do.


It was such a struggle to figure this out when the solution was so simple.

That’s all for this one and we still didn’t even say Hello World