def build_tree(self,name,cols): tree = self._builder.get_object('tree_%s'%name) TreeviewProxy.quick(tree, cols, self._models[name]) TreeviewProxy(tree).optimise_tree(config.column_size)
def on_selection_change(self, selection, selected_tree): obj = TreeviewProxy.by_selection(selection).get_selected_row() if obj: self.unselect(set(('authors','editors','serials'))-set((selected_tree,))) self._filter.refilter_obj(obj() if obj else None)
def run(self): builder = self._uieditor._builder model = self._models serial = builder.get_object('serial') editor = builder.get_object('editor') def match_func_name(obj, key): return obj.name.lower().startswith(key.lower()) def match_func_title(obj, key): return obj.title.lower().startswith(key.lower()) def display_func_name(obj): return obj.name def display_func_title(obj): return obj.title def search_name(obj, key): return key.lower() in obj.name.lower() e_editors = EntryCompletion(editor, self._models['editors'], display_func_name, match_func_name) e_serials = EntryCompletion(serial, self._models['serials'], display_func_title, match_func_title) trees = builder.get_object('have'), builder.get_object('available') choose = ChooseModel(model['authors']) multiples = ChooseWidget(choose, (Column("Affectés",str),Column('Disponibles',str)), trees, search_name) for tree in trees: TreeviewProxy(tree).optimise_tree(1) def format_prefix(obj): if len(obj.prefix) == 1: prefix_str, = obj.prefix else: prefix_str = ', '.join(obj.prefix) return "%s - %s"%(obj.title,prefix_str) self._uieditor._mapper.update({ 'kind': RadioButtonMapper( { 'b': builder.get_object('kind_bd'), 'm': builder.get_object('kind_manga'), } ), 'authors': ChooseModelAdapter(choose), 'editor':e_editors, 'serial':e_serials, }) return self._uieditor.run()
def on_selection_change(self, selection, selected_tree): obj = TreeviewProxy.by_selection(selection).get_selected_row() if obj: self.unselect( set(('authors', 'editors', 'serials')) - set((selected_tree, ))) self._filter.refilter_obj(obj() if obj else None)
def on_tree_loans_row_activated(self, treeview, path, view_column): book_p = TreeviewProxy(treeview).get_selected_row() user_p = TreeviewProxy( self._builder.get_object('tree_users')).get_selected_row() if not user_p: show_message( 'Vous devez avoir selectionné un utilisateur pour rendre des ouvrages' ) else: with database.session.begin(): if book_p().user: # rendu assert book_p().user == user_p() user_p().returns(book_p()) else: # emprunt # TODO: check abo (limit + date) user_p().takes(book_p()) user_p.changed() book_p.changed()
def on_tree_loans_row_activated(self,treeview,path,view_column): book_p = TreeviewProxy(treeview).get_selected_row() user_p = TreeviewProxy(self._builder.get_object('tree_users')).get_selected_row() if not user_p: show_message('Vous devez avoir selectionné un utilisateur pour rendre des ouvrages') else: with database.session.begin(): if book_p().user: # rendu assert book_p().user == user_p() user_p().returns(book_p()) else: # emprunt # TODO: check abo (limit + date) user_p().takes(book_p()) user_p.changed() book_p.changed()
def build_tree(self, name, cols): tree = self._builder.get_object('tree_%s' % name) TreeviewProxy.quick(tree, cols, self._models[name]) TreeviewProxy(tree).optimise_tree(config.column_size)
def on_tree_books_row_activated(self, treeview, path, view_column): object_p = TreeviewProxy(treeview).get_selected_row() self.add_edit('book', object_p)
def on_selection_user_change(self, selection): obj = TreeviewProxy.by_selection(selection).get_selected_row() self._filter.refilter_loans(obj() if obj else None)