User:Bhanutpt/scratchpad/python/pyGTK

GTK is part of GNOME project and is used to create advanced graphical user interfaces, pyGTK is the wrapper of the GTK library on python. This book aims at learning by constructive examples.

Examples
The basic GUI program to pop up a simple window Its always good to use class paradigm in programming GUI using pyGTK The window quit method is not proper in the program, the intercommunication and integrity of the widgets in pyGTK are based on events and signals, so when the user actually clicks on the 'X' button, it generates a signal called "destroy", if there is an event to handle the signal, it will be triggered, gtk.main_quit is the right method that will quit the GUI window in its proper method. So  use win.connect("destroy", callback) to connect the "destroy" signal generated by the window manager and the respective callback function; in callback function call the method gtk.main_quit Now let us add a button widget to the window and link the "clicked" signal from the window manager with the call back function print_message, where it prints a message to console Now, we have to see ways to accommodate more buttons in the desired pattern into the window, to be more generic, we have to know how to pack widgets into the window, here is a little example with two buttons, a separator and a quit button to quit the window