|
Server : Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 DAV/2 PHP/5.2.17 System : Linux localhost 2.6.18-419.el5 #1 SMP Fri Feb 24 22:47:42 UTC 2017 x86_64 User : nobody ( 99) PHP Version : 5.2.17 Disable Function : NONE Directory : /usr/share/doc/pygtk2-2.10.1/examples/simple/ |
Upload File : |
#!/usr/bin/env python
""" Simple example of creating a basic window and button.
Also adds a tooltip. """
import gtk
def hello_cb(widget, main_window):
""" Callback function that prints a message and destroys the window """
print "Hello World"
main_window.destroy()
def destroy_cb(widget, main_window):
""" Callback function to hide the main window and then terminate. """
main_window.hide()
gtk.main_quit()
def main():
""" Sets up the application
Forms the widgets and connects callback functions to the signals """
window = gtk.Window( type=gtk.WINDOW_TOPLEVEL )
window.set_title("Hello World")
window.set_default_size(200, 200)
window.set_border_width(10)
window.connect("destroy", destroy_cb, window)
button = gtk.Button(label="Hello World")
window.add(button)
button.connect("clicked", hello_cb, window)
# setup tooltips and associate them with the button
tt = gtk.Tooltips()
tt.set_tip(button, 'Prints "Hello World"', None)
tt.enable()
# shows the window and any child objects (button in this example)
window.show_all()
gtk.main()
# if we're being run normally then call the main function
if __name__ == '__main__':
main()