def __init__(self, master, names): self.widget = Frame(master) self._tree = Treeview(self.widget, columns='name') self._tree.grid(row=0, column=0, sticky=(N, S, W, E)) self._tree.view = self self.widget.columnconfigure(0, weight=1) self.widget.rowconfigure(0, weight=1) self._tree.column('name', width=50) self._tree['show'] = 'tree' actions = { 'edit': lambda e: self.edit(), 'search': lambda e: self.search(), 'focus_next': lambda e: self.focus_next(), 'focus_prev': lambda e: self.focus_prev(), 'select': lambda e: self._tree.selection_toggle(self._tree.focus()), 'clear_selection': lambda e: self._tree.selection_set([]) } kb.make_bindings(kb.tagview, actions, self._tree.bind) self._iids = dict() self._names = dict() logger.debug('Names: %s', names) self.widget.focus_set = self._tree.focus_set for name in sorted(names): iid = self._tree.insert('', 'end', text=name) self._names[iid] = name self._iids[name] = iid self._scroll = Scrollbar(self.widget, command=self._tree.yview) self._tree['yscrollcommand'] = self._scroll.set self._scroll.grid(row=0, column=1, sticky=(N, S)) self.widget.columnconfigure(1, weight=0)
def __init__(self, master, names): self.widget = Frame(master) self._tree = Treeview(self.widget, columns='name') self._tree.grid(row=0,column=0, sticky=(N,S,W,E)) self._tree.view = self self.widget.columnconfigure(0, weight=1) self.widget.rowconfigure(0,weight=1) self._tree.column('name', width=50) self._tree['show'] = 'tree' actions = {'edit': lambda e: self.edit(), 'search': lambda e: self.search(), 'focus_next': lambda e: self.focus_next(), 'focus_prev': lambda e: self.focus_prev(), 'select': lambda e: self._tree.selection_toggle(self._tree.focus()), 'clear_selection': lambda e: self._tree.selection_set([]) } kb.make_bindings(kb.tagview, actions, self._tree.bind) self._iids = dict() self._names = dict() logger.debug('Names: %s', names) self.widget.focus_set = self._tree.focus_set for name in sorted(names): iid = self._tree.insert('', 'end', text=name) self._names[iid] = name self._iids[name] = iid self._scroll = Scrollbar(self.widget, command=self._tree.yview) self._tree['yscrollcommand'] = self._scroll.set self._scroll.grid(row=0, column=1, sticky=(N, S)) self.widget.columnconfigure(1, weight=0)
def __init__(self, root, paths, pos=0): self.paths = paths self.img = paths[pos] self.pos = pos self.widget = Label(root, takefocus=True) self.root = root self.make_view() self.widget.bind('<Expose>', lambda e: self.reload()) actions = {'next':lambda e: self.next(), 'prev':lambda e: self.prev(), 'reload':lambda e: self.reload()} kb.make_bindings(kb.slideshow, actions, self.widget.bind)
def __init__(self, root, paths, pos=0): self.paths = paths self.img = paths[pos] self.pos = pos self.widget = Label(root, takefocus=True) self.root = root self.make_view() self.widget.bind('<Expose>', lambda e: self.reload()) actions = { 'next': lambda e: self.next(), 'prev': lambda e: self.prev(), 'reload': lambda e: self.reload() } kb.make_bindings(kb.slideshow, actions, self.widget.bind)
def make_bindings(self): self._canvas.bind('<Configure>', lambda e: self.reload()) actions = {'slide': self.activate, 'clear_selection': lambda e: self.clear_selection(), 'toggle_selection': self.toggle_selection, 'cursor_up':self.cursor_up, 'cursor_right':self.cursor_right, 'cursor_left':self.cursor_left, 'cursor_down':self.cursor_down, 'load_more':lambda e: self.continue_loading()} self._canvas.bind('<Button-4>', self.scroll) self._canvas.bind('<Button-5>', self.scroll) self._canvas.bind('<MouseWheel>', self.scroll) kb.make_bindings(kb.gallery, actions, self.widget.bind) kb.make_bindings(kb.gallery, actions, self._canvas.bind)
def make_bindings(self): self._canvas.bind('<Configure>', lambda e: self.reload()) actions = { 'slide': self.activate, 'clear_selection': lambda e: self.clear_selection(), 'toggle_selection': self.toggle_selection, 'cursor_up': self.cursor_up, 'cursor_right': self.cursor_right, 'cursor_left': self.cursor_left, 'cursor_down': self.cursor_down, 'load_more': lambda e: self.continue_loading() } self._canvas.bind('<Button-4>', self.scroll) self._canvas.bind('<Button-5>', self.scroll) self._canvas.bind('<MouseWheel>', self.scroll) kb.make_bindings(kb.gallery, actions, self.widget.bind) kb.make_bindings(kb.gallery, actions, self._canvas.bind)
def text_query(self, query_lable, original_text=None, accept_func=None): if self._query is not None: return frame = Frame(self.menubar) label = Label(frame, text=query_lable) label.grid(column=0, row=0, sticky=(N, S)) self._accept_func = accept_func entry = Entry(frame) if original_text is not None: entry.insert(0, original_text) entry.original_value = original_text entry.grid(column=1, row=0, sticky=(N,S,W,E)) kb.make_bindings(kb.text_query, {'accept': self.accept_query, 'cancel': lambda e: self.close_query()}, entry.bind) frame.grid(column=self._menucolumn, row=0) self._menucolumn += 1 entry.focus_set() self._query = frame
def text_query(self, query_lable, original_text=None, accept_func=None): if self._query is not None: return frame = Frame(self.menubar) label = Label(frame, text=query_lable) label.grid(column=0, row=0, sticky=(N, S)) self._accept_func = accept_func entry = Entry(frame) if original_text is not None: entry.insert(0, original_text) entry.original_value = original_text entry.grid(column=1, row=0, sticky=(N, S, W, E)) kb.make_bindings(kb.text_query, { 'accept': self.accept_query, 'cancel': lambda e: self.close_query() }, entry.bind) frame.grid(column=self._menucolumn, row=0) self._menucolumn += 1 entry.focus_set() self._query = frame
lambda e: mainview.text_query('Jump to tag: ', accept_func=jump_to_tag ), 'focus_sidebar': lambda e: mainview.focus_sidebar(), 'focus_main_view': lambda e: mainview.focus_main_view(), 'toggle_selection_tags': glue.toggle_selection_tags, 'toggle_collections': glue.toggle_collections, 'tagstring_search': glue.search_tagstring, 'help': lambda e: mainview.new_view(HelpView(mainview.root)), } keybindings.make_bindings(keybindings.appwide, actions, mainview.root.bind_all) buttons = { 'Add collection': glue.add_collection, 'Remove collection': glue.remove_collection, 'Remove deleted': glue.remove_deleted_files, } for label in buttons: mainview.add_menubutton(label, buttons[label]) # Custom virtual events do not need to be user bindable # since their generation is user bindable. -> no dictionaries used. mainview.root.bind_all('<<TagViewSearch>>', glue.search_event) mainview.root.bind_all( '<<TagViewEdit>>', lambda e: mainview.text_query('Edit tag:', tview.selection()[0]))
'delete_view': mainview.delete_current_view, 'add_tags' : lambda e: mainview.text_query('Add tags: '), 'add_selected_tags': lambda e: glue.add_tags_from_tagview(e, tview), 'add_images' : glue.add_files, 'add_folder' : glue.add_directory, 'remove_tags': glue.remove_tags_from_files, 'jump_to_tag': lambda e: mainview.text_query('Jump to tag: ', accept_func=jump_to_tag), 'focus_sidebar': lambda e: mainview.focus_sidebar(), 'focus_main_view': lambda e: mainview.focus_main_view(), 'toggle_selection_tags': glue.toggle_selection_tags, 'toggle_collections': glue.toggle_collections, 'tagstring_search': glue.search_tagstring, 'help': lambda e: mainview.new_view(HelpView(mainview.root)), } keybindings.make_bindings(keybindings.appwide, actions, mainview.root.bind_all) buttons = { 'Add collection': glue.add_collection, 'Remove collection': glue.remove_collection, 'Remove deleted': glue.remove_deleted_files, } for label in buttons: mainview.add_menubutton(label, buttons[label]) # Custom virtual events do not need to be user bindable # since their generation is user bindable. -> no dictionaries used. mainview.root.bind_all('<<TagViewSearch>>', glue.search_event) mainview.root.bind_all('<<TagViewEdit>>', lambda e: mainview.text_query('Edit tag:', tview.selection()[0])) mainview.root.bind_all('<<MainQueryAccept>>', glue.add_or_rename_tags) mainview.root.bind_all('<<GallerySelectionChanged>>', glue.update_selection_tags)