def __init__(self, parent, treeProvider, showPreview=True, showPreviewTop=True, **args): tk.Frame.__init__(self, parent, **args) self.treeProvider = treeProvider self._lastSelected = None gui.configureWeigths(self) self.showPreviewTop = showPreviewTop # The main layout will be two panes, # At the left containing the elements list # and the right containing the preview and description p = tk.PanedWindow(self, orient=tk.HORIZONTAL) p.grid(row=0, column=0, sticky='news') leftPanel = tk.Frame(p) self._fillLeftPanel(leftPanel) p.add(leftPanel, padx=5, pady=5) p.paneconfig(leftPanel, minsize=300) if showPreview: rightPanel = tk.Frame(p) self._fillRightPanel(rightPanel) p.add(rightPanel, padx=5, pady=5) p.paneconfig(rightPanel, minsize=200) # Register a callback when the item is clicked self.tree.itemClick = self._itemClicked
def body(self, bodyFrame): bodyFrame.config() gui.configureWeigths(bodyFrame) self._createTree(bodyFrame) if self.message: label = tk.Label(bodyFrame, text=self.message, compound=tk.LEFT, image=self.getImage(Icon.LIGHTBULB)) label.grid(row=1, column=0, sticky='nw', padx=5, pady=5) self.initial_focus = self.tree
def body(self, bodyFrame): bodyFrame.config(bg='white') gui.configureWeigths(bodyFrame) self._createTree(bodyFrame) if self.message: label = tk.Label(bodyFrame, text=self.message, bg='white', image=self.getImage('fa-lightbulb-o.png'), compound=tk.LEFT) label.grid(row=1, column=0, sticky='nw', padx=5, pady=5) self.initial_focus = self.tree
def createWidgets(self, fileList): #registerCommonFonts() self.columnconfigure(0, weight=1) self.rowconfigure(1, weight=1) #Create toolbar frame toolbarFrame = tk.Frame(self) toolbarFrame.grid(column=0, row=0, padx=5, sticky='new') gui.configureWeigths(toolbarFrame) #Add the search box right = tk.Frame(toolbarFrame) right.grid(column=1, row=0, sticky='ne') self.searchVar = tk.StringVar() if self._allowSearch: tk.Label(right, text='Search:').grid(row=0, column=3, padx=5) self.searchEntry = tk.Entry(right, textvariable=self.searchVar) self.searchEntry.grid(row=0, column=4, sticky='ew', padx=5) btn = IconButton(right, "Search", Icon.ACTION_SEARCH, tooltip=Message.TOOLTIP_SEARCH, command=self.findText, bg=None) btn.grid(row=0, column=5, padx=(0, 5)) if self._allowRefresh: btn = IconButton(right, "Refresh", Icon.ACTION_REFRESH, tooltip=Message.TOOLTIP_REFRESH, command=self._onRefresh, bg=None) btn.grid(row=0, column=6, padx=(0, 5), pady=2) if self._allowOpen: btn = IconButton(right, "Open external", Icon.ACTION_REFERENCES, tooltip=Message.TOOLTIP_EXTERNAL, command=self._openExternal, bg=None) btn.grid(row=0, column=7, padx=(0, 5), pady=2) #Create tabs frame tabsFrame = tk.Frame(self) tabsFrame.grid(column=0, row=1, padx=5, pady=(0, 5), sticky="nsew") tabsFrame.columnconfigure(0, weight=1) tabsFrame.rowconfigure(0, weight=1) self.notebook = ttk.Notebook(tabsFrame) self.notebook.rowconfigure(0, weight=1) self.notebook.columnconfigure(0, weight=1) for f in fileList: self._addFileTab(f) self.notebook.grid(column=0, row=0, sticky='nsew', padx=5, pady=5) self.notebook.bind('<<NotebookTabChanged>>', self._tabChanged)
def _fillRightPanel(self, frame): frame.columnconfigure(0, weight=1) if self.showPreviewTop: top = tk.Frame(frame) top.grid(row=0, column=0, sticky='news') frame.rowconfigure(0, weight=3) gui.configureWeigths(top) top.rowconfigure(0, minsize=200) self._fillRightTop(top) bottom = tk.Frame(frame) bottom.grid(row=1, column=0, sticky='news') frame.rowconfigure(1, weight=1) gui.configureWeigths(bottom) bottom.rowconfigure(1, weight=1) self._fillRightBottom(bottom)
def body(self, bodyFrame): bodyFrame.config(bg='white') gui.configureWeigths(bodyFrame, 1, 0) # Add an extra frame to insert the Toolbar # and another one for the ListDialog's body self.toolbarFrame = tk.Frame(bodyFrame, bg='white') self.toolbarFrame.grid(row=0, column=0, sticky='new') if self.toolbarButtons: for i, b in enumerate(self.toolbarButtons): self._addButton(b, i) subBody = tk.Frame(bodyFrame) subBody.grid(row=1, column=0, sticky='news', padx=5, pady=5) ListDialog.body(self, subBody) if self._itemDoubleClick: self.tree.itemDoubleClick = self._itemDoubleClick
def showTextFileViewer(title, filelist, parent=None, main=False): w = gui.Window(title, parent, minsize=(600, 400)) viewer = TextFileViewer(w.root, filelist, maxSize=-1) viewer.grid(row=0, column=0, sticky='news') gui.configureWeigths(w.root) w.show()
def _fillLeftPanel(self, frame): gui.configureWeigths(frame) self.tree = BoundTree(frame, self.treeProvider) self.tree.grid(row=0, column=0, sticky='news') self.itemConfig = self.tree.itemConfig self.getImage = self.tree.getImage
def __init__(self, parent, title, **args): """Initialize a dialog. Arguments: parent -- a parent window (the application window) title -- the dialog title **args accepts: buttons -- list of buttons tuples containing which buttons to display """ if parent is None: parent = tk.Tk() parent.withdraw() gui.setCommonFonts() tk.Toplevel.__init__(self, parent) self.withdraw() # remain invisible for now # If the master is not viewable, don't # make the child transient, or else it # would be opened withdrawn if parent.winfo_viewable(): self.transient(parent) if title: self.title(title) self.parent = parent self.result = None self.initial_focus = None bodyFrame = tk.Frame(self) # Call subclass method body to create that region self.body(bodyFrame) bodyFrame.grid(row=0, column=0, sticky='news', padx=5, pady=5) self.icons = {RESULT_YES: Icon.BUTTON_SELECT, RESULT_NO: Icon.BUTTON_CLOSE, RESULT_CANCEL: Icon.BUTTON_CANCEL} self.buttons = args.get('buttons', [('OK', RESULT_YES), ('Cancel', RESULT_CANCEL)]) self.defaultButton = args.get('default', 'OK') btnFrame = tk.Frame(self) # Create buttons self.buttonbox(btnFrame) btnFrame.grid(row=1, column=0, sticky='sew', padx=5, pady=(0, 5)) gui.configureWeigths(self) if self.initial_focus is None: self.initial_focus = self self.protocol("WM_DELETE_WINDOW", self.cancel) if self.parent is not None: self.geometry("+%d+%d" % (parent.winfo_rootx()+50, parent.winfo_rooty()+50)) self.deiconify() # become visibile now self.initial_focus.focus_set() # wait for window to appear on screen before calling grab_set self.wait_visibility() self.grab_set() self.wait_window(self)
def __init__(self, parent, title, **args): """Initialize a dialog. Arguments: parent -- a parent window (the application window) title -- the dialog title **args accepts: buttons -- list of buttons tuples containing which buttons to display """ if parent is None: parent = tk.Tk() parent.withdraw() gui.setCommonFonts() tk.Toplevel.__init__(self, parent) self.withdraw() # remain invisible for now # If the master is not viewable, don't # make the child transient, or else it # would be opened withdrawn if parent.winfo_viewable(): self.transient(parent) if title: self.title(title) self.parent = parent self.result = None self.initial_focus = None bodyFrame = tk.Frame(self) # Call subclass method body to create that region self.body(bodyFrame) bodyFrame.grid(row=0, column=0, sticky='news', padx=5, pady=5) self.icons = { RESULT_YES: Icon.BUTTON_SELECT, RESULT_NO: Icon.BUTTON_CLOSE, RESULT_CANCEL: Icon.BUTTON_CANCEL } self.buttons = args.get('buttons', [('OK', RESULT_YES), ('Cancel', RESULT_CANCEL)]) self.defaultButton = args.get('default', 'OK') btnFrame = tk.Frame(self) # Create buttons self.buttonbox(btnFrame) btnFrame.grid(row=1, column=0, sticky='sew', padx=5, pady=(0, 5)) gui.configureWeigths(self) if self.initial_focus is None: self.initial_focus = self self.protocol("WM_DELETE_WINDOW", self.cancel) if self.parent is not None: self.geometry( "+%d+%d" % (parent.winfo_rootx() + 50, parent.winfo_rooty() + 50)) self.deiconify() # become visible now self.initial_focus.focus_set() # wait for window to appear on screen before calling grab_set self.wait_visibility() self.grab_set() self.wait_window(self)