self.view['date'], attribute='date', from_python=lambda d: d.strftime('%Y.%m.%d %H:%M')) m = EntryStore(sys.argv[1]).filter_new() self.view['treeview'].set_model(m) self.visible_func = filtering.get_visible_function(m) # TODO way to write :: in magic handler method names. self.view['editor'].connect('notify::symbols', self.on_editor_changed) def on_editor_changed(self, widget, spec): symbols = widget.get_property('symbols') if not symbols: # TODO avoid None? symbols = () self.visible_func.refilter(symbols, predicates) def on_window__delete_event(self, widget, event): gtk.main_quit() def on_selection__changed(self, widget): store, iter_ = widget.get_selected() if iter_: # Encode to UTF-8? self.view['buffer'].set_text(store[iter_][0].message) else: self.view['buffer'].set_text('') c = Controller(gtkmvc3.Model(), View(), handlers='class') gtk.main()
gtkmvc3.adapters.containers.watch_items_in_tree(self.list) def on_button1__clicked(self, widget): self.undo.undo() def on_button2__clicked(self, widget): self.undo.redo() def on_button3__clicked(self, widget): self.undo.begin_grouping() for row in self.list: row[0].hours = int(random.random() * 10) self.undo.set_action_name("random hours") self.undo.end_grouping() def on_window1__delete_event(self, widget, event): gtk.main_quit() def register_adapters(self): self.setup_columns() adapt_availability(self.undo, 'undoable', self.view['button1']) adapt_availability(self.undo, 'redoable', self.view['button2']) adapt_label(self.undo, 'undo_label', self.view['button1']) adapt_label(self.undo, 'redo_label', self.view['button2']) Controller(gtkmvc3.Model(), gtkmvc3.View(builder='undo.ui'), handlers='class') gtk.main()