Difference between revisions of "PyGTK"
(→Toplevels) |
|||
| Line 31: | Line 31: | ||
| <source lang="python">window = builder.get_object('windowname') | | <source lang="python">window = builder.get_object('windowname') | ||
window.show_all()</source> | window.show_all()</source> | ||
| + | |- | ||
| FileChooserDialog | | FileChooserDialog | ||
| | | | ||
| Line 40: | Line 41: | ||
| ??? | | ??? | ||
|} | |} | ||
| + | |||
==Control and Display== | ==Control and Display== | ||
{| class="wikitable" | {| class="wikitable" | ||
Revision as of 03:39, 11 June 2013
PyGTK is loads better than TKinter. There are far more events to work with which let you make a more responsive, convenient, and concise interface.
I am using Glade to create the gui. pygtk is well documented; glade is not.
For starters, supposedly you should use the GtkBuilder file format over Libglade. Many instructions on the web are for Libglade.
Contents
Loading a glade file, hooking up event handlers, and displaying a window
#Load the file
import gtk
gladefile = 'app.glade'
builder = gtk.Builder()
builder.add_from_file(gladefile)
#Connect callback handlers
handlers = {}
handlers['button_clicked_cb'] = buttonclickedfunction
builder.connect_signals(handlers)
#Display the window
window = builder.get_object('mainwindow')
window.show_all()But first you have to create the glade file. Create a window and divide it with boxes and then put widgets in each panel and widgets within those widgets as needed.
Actions
What are actions for? Do they let me configure a button to launch a file dialog?
Toplevels
| widget | glade | python |
|---|---|---|
| Window | Make an empty window | window = builder.get_object('windowname')
window.show_all() |
| FileChooserDialog |
|
??? |
Control and Display
| widget | glade | python |
|---|---|---|
| ComboBox |
|
builder.get_object('comboboxname') |