def toggle_code_context_event(self, event=None): if not self.label: # Calculate the border width and horizontal padding required to # align the context with the text in the main Text widget. # # All values are passed through int(str(<value>)), since some # values may be pixel objects, which can't simply be added to ints. # Calculate the required horizontal padding padx = int(str(self.editwin.text_notebook.pack_info()['padx'])) self.label = Tkinter.Label( self.editwin.top, text="\n" * (self.context_depth - 1), anchor=W, justify=LEFT, font=self.textfont, bg=self.bgcolor, fg=self.fgcolor, width=1, #don't request more than we get padx=padx, relief=SUNKEN) # Pack the label widget before and above the text_notebook widget, # thus ensuring that it will appear directly above text_notebook self.label.pack(side=TOP, fill=X, expand=False, before=self.editwin.text_notebook) else: self.label.destroy() self.label = None idleConf.SetOption("extensions", "CodeContext", "visible", str(self.label is not None)) idleConf.SaveUserCfgFiles()
def toggle_code_context_event(self, event=None): if not self.label: self.pad_frame = Tkinter.Frame(self.editwin.top, bg=self.bgcolor, border=2, relief="sunken") self.label = Tkinter.Label( self.pad_frame, text="\n" * (self.context_depth - 1), anchor="w", justify="left", font=self.textfont, bg=self.bgcolor, fg=self.fgcolor, border=0, width=1, # Don't request more than we get ) self.label.pack(side="top", fill="x", expand=True, padx=4, pady=0) self.pad_frame.pack(side="top", fill="x", expand=False, padx=0, pady=0, after=self.editwin.status_bar) else: self.label.destroy() self.pad_frame.destroy() self.label = None idleConf.SetOption("extensions", "CodeContext", "visible", str(self.label is not None)) idleConf.SaveUserCfgFiles()