diff options
author | Johan Dahlin <johan@src.gnome.org> | 2004-11-04 20:30:39 +0000 |
---|---|---|
committer | Johan Dahlin <johan@src.gnome.org> | 2004-11-04 20:30:39 +0000 |
commit | 1550aabd929a8b1dcf87c090528243dcf6ce94fe (patch) | |
tree | a051e5246f1ea5345174068d8ceaee72935d662b /examples/gtk | |
parent | ff3a9e5b3ab8ef63bdfc34b883e318360789d8ba (diff) | |
download | pygtk-1550aabd929a8b1dcf87c090528243dcf6ce94fe.tar.gz |
Fix typo
* examples/gtk/filechooser.py: Fix typo
* examples/gtk/uimanager.py: Simplify
Diffstat (limited to 'examples/gtk')
-rw-r--r-- | examples/gtk/filechooser.py | 6 | ||||
-rw-r--r-- | examples/gtk/uimanager.py | 39 |
2 files changed, 10 insertions, 35 deletions
diff --git a/examples/gtk/filechooser.py b/examples/gtk/filechooser.py index 11c62f08..283a4957 100644 --- a/examples/gtk/filechooser.py +++ b/examples/gtk/filechooser.py @@ -3,10 +3,6 @@ pygtk.require('2.0') import gtk -if gtk.pygtk_version < (2,3,90): - print "PyGtk 2.3.90 or later required for this example" - raise SystemExit - dialog = gtk.FileChooserDialog("Open..", None, gtk.FILE_CHOOSER_ACTION_OPEN, @@ -34,7 +30,7 @@ dialog.add_filter(filter) response = dialog.run() if response == gtk.RESPONSE_OK: print dialog.get_filename(), 'selected' -elif response == gtk.RESPONSE: +elif response == gtk.RESPONSE_CANCEL: print 'Closed, no files selected' dialog.destroy() diff --git a/examples/gtk/uimanager.py b/examples/gtk/uimanager.py index 2fd63994..15766c10 100644 --- a/examples/gtk/uimanager.py +++ b/examples/gtk/uimanager.py @@ -9,20 +9,6 @@ pygtk.require('2.0') import gtk -if gtk.pygtk_version < (2,3,90): - print "PyGtk 2.3.90 or later required for this example" - raise SystemExit - -window_actions = [ - ('FileMenu', None, '_File'), - ('New', gtk.STOCK_NEW, '_New', '<control>N', 'Create a new file', 'file_new_cb'), - ('Open', gtk.STOCK_OPEN, '_Open', '<control>O', 'Open a file', 'file_open_cb'), - ('Close', gtk.STOCK_CLOSE, '_Close', '<control>W', 'Close the current window', 'file_close_cb'), - ('Quit', gtk.STOCK_QUIT, '_Quit', '<control>Q', 'Quit application', 'file_quit_cb'), - ('HelpMenu', None, '_Help'), - ('About', None, '_About', None, 'About application', 'help_about_cb'), - ] - ui_string = """<ui> <menubar name='Menubar'> <menu action='FileMenu'> @@ -44,20 +30,6 @@ ui_string = """<ui> </toolbar> </ui>""" -def fix_actions(actions, instance): - "Helper function to map methods to an instance" - retval = [] - - for i in range(len(actions)): - curr = actions[i] - if len(curr) > 5: - curr = list(curr) - curr[5] = getattr(instance, curr[5]) - curr = tuple(curr) - - retval.append(curr) - return retval - class Window(gtk.Window): def __init__(self): gtk.Window.__init__(self) @@ -85,8 +57,15 @@ class Window(gtk.Window): def create_ui(self): ag = gtk.ActionGroup('WindowActions') - - actions = fix_actions(window_actions, self) + actions = [ + ('FileMenu', None, '_File'), + ('New', gtk.STOCK_NEW, '_New', '<control>N', 'Create a new file', self.file_new_cb), + ('Open', gtk.STOCK_OPEN, '_Open', '<control>O', 'Open a file', self.file_open_cb), + ('Close', gtk.STOCK_CLOSE, '_Close', '<control>W', 'Close the current window', self.file_close_cb), + ('Quit', gtk.STOCK_QUIT, '_Quit', '<control>Q', 'Quit application', self.file_quit_cb), + ('HelpMenu', None, '_Help'), + ('About', None, '_About', None, 'About application', 'help_about_cb'), + ] ag.add_actions(actions) self.ui = gtk.UIManager() self.ui.insert_action_group(ag, 0) |