from gi.repository import Gtk

class ButtonExample(Gtk.Window):
   def __init__(self):
       Gtk.Window.__init__(self, title="Buttons")
       box = Gtk.Box(spacing=6)
       self.add(box)

       button = Gtk.Button("Test Button") #create a button
       button.connect("clicked", self.on_button_clicked) #connect the handler
       box.pack_start(button, True, True, 0)

   def on_button_clicked(self, button): #what happens when button is clicked
       print "Button was clicked!"



win = ButtonExample()
win.connect("delete-event", Gtk.main_quit)
win.show_all()
Gtk.main()
