diff options
author | Alexander Sulfrian <alexander@sulfrian.net> | 2009-04-17 21:45:45 +0200 |
---|---|---|
committer | Alexander Sulfrian <alexander@sulfrian.net> | 2009-04-17 21:46:47 +0200 |
commit | ab9077633a539229533d03f56c627be9e88a7865 (patch) | |
tree | ba3049a4ec7c055a6900d7eea756c6ec3eb488b7 /ui | |
parent | 42dcfdbebbbbf8d0ce7d4acdc8507a96911323e0 (diff) | |
download | todolist-ab9077633a539229533d03f56c627be9e88a7865.tar.gz todolist-ab9077633a539229533d03f56c627be9e88a7865.tar.xz todolist-ab9077633a539229533d03f56c627be9e88a7865.zip |
started gui creation
added first window with menu, statusbar and aboutbox
added license file with gpl3 and version
remove some debuging output from storage.sqlite
Diffstat (limited to '')
-rw-r--r-- | ui/__init__.py | 4 | ||||
-rw-r--r-- | ui/ui_pygtk.py | 134 |
2 files changed, 138 insertions, 0 deletions
diff --git a/ui/__init__.py b/ui/__init__.py new file mode 100644 index 0000000..c8713fb --- /dev/null +++ b/ui/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# date: 17 Apr 2009 + + diff --git a/ui/ui_pygtk.py b/ui/ui_pygtk.py new file mode 100644 index 0000000..4dd4b53 --- /dev/null +++ b/ui/ui_pygtk.py @@ -0,0 +1,134 @@ +# -*- coding: utf-8 -*- +# date: 17 Apr 2009 + +import pygtk +pygtk.require('2.0') +import gtk +import gobject + +from license import version, gpl_3 + +class ui_pygtk: + def __init__(self, itemList): + self.itemList = itemList + + # create ui + self.get_main_window(100, 100, 10, 10) + + # start ui + self.get_main_window().show_all() + gtk.main() + return + + ######################################################### + # create gui + ######################################################### + + def get_main_window(self, initial_width=None, initial_height=None, + initial_pos_x=None, initial_pos_y=None): + if 'main_window' not in self.__dict__: + self.main_window = gtk.Window(gtk.WINDOW_TOPLEVEL) + self.main_window.connect('destroy', self.destroy_callback) + + self.main_window.set_title('ToDo') + self.main_window.set_size_request(10, 10) # very small minimal size + self.main_window.resize(initial_width, initial_height) + self.main_window.move(initial_pos_x, initial_pos_y) + + self.main_window.add(self.get_main_content_box()) + return self.main_window + + def get_main_content_box(self): + if 'main_content_box' not in self.__dict__: + self.main_content_box = gtk.VBox(False, 1) + self.main_content_box.pack_start(self.get_main_menu(), False, True, 0) + self.main_content_box.pack_start(self.get_todo_list(), True, True, 0) + self.main_content_box.pack_start(self.get_statusbar(), False, False, 0) + return self.main_content_box + + def get_main_menu(self): + if 'mainmenu' not in self.__dict__: + quit_action = gtk.Action('Quit', '_Quit', 'Exit Todolist', gtk.STOCK_QUIT) + quit_action.connect('activate', self.destroy_callback) + + settings_action = gtk.Action('Settings', '_Settings', 'Settings', gtk.STOCK_PREFERENCES) + settings_action.set_property('sensitive', False) + #settings_action.connect('activate', self.show_settings) + + #delete_action = gtk.Action('Delete', '_Delete', 'Delete a post', + # gtk.STOCK_DELETE) + #delete_action.connect('activate', self.delete_tweet) + + about_action = gtk.Action('About', '_About', 'About Todolist', gtk.STOCK_ABOUT) + about_action.connect('activate', self.about_click_callback) + + file_action = gtk.Action('File', '_File', 'File', None) + edit_action = gtk.Action('Edit', '_Edit', 'Edit', None) + help_action = gtk.Action('Help', '_Help', 'Help', None) + + self.action_group = gtk.ActionGroup('MainMenu') + self.action_group.add_action_with_accel(quit_action, None) # None = default + self.action_group.add_action(settings_action) + self.action_group.add_action(file_action) + self.action_group.add_action(edit_action) + self.action_group.add_action(help_action) + self.action_group.add_action(about_action) + + # definition of the UI + uimanager = gtk.UIManager() + uimanager.insert_action_group(self.action_group, 0) + uimanager.add_ui_from_string(''' + <ui> + <menubar name="MainMenu"> + <menu action="File"> + <menuitem action="Quit" /> + </menu> + <menu action="Edit"> + <separator /> + <menuitem action="Settings" /> + </menu> + <menu action="Help"> + <menuitem action="About" /> + </menu> + </menubar> + </ui> + ''') + + self.main_window.add_accel_group(uimanager.get_accel_group()) + self.main_menu = uimanager.get_widget('/MainMenu') + + return self.main_menu + + def get_todo_list(self): + if 'todo_list' not in self.__dict__: + self.todo_list = gtk.ScrolledWindow() + self.todo_list.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) + + return self.todo_list + + def get_statusbar(self): + if 'statusbar' not in self.__dict__: + self.statusbar = gtk.Statusbar() + self.statusbar.show() + return self.statusbar + + ######################################################### + # callbacks + ######################################################### + + def destroy_callback(self, widget, data=None): + gtk.main_quit() + return + + def about_click_callback(self, widget, data=None): + """Show the about dialog.""" + + about_window = gtk.AboutDialog() + about_window.set_name('Todolist') + about_window.set_version(version) + about_window.set_copyright('2009 Alexander Sulfrian') + about_window.set_license(gpl_3) + about_window.set_website('http://git.animux.de/todolist.git') + about_window.run() + about_window.hide() + return |