def init(self): "Create browser tkinter widgets, including the tree." global file_open root = self.master flist = (pyshell.flist if not (self._htest or self._utest) else pyshell.PyShellFileList(root)) file_open = flist.open pyclbr._modules.clear() # create top self.top = top = ListedToplevel(root) top.protocol("WM_DELETE_WINDOW", self.close) top.bind("<Escape>", self.close) if self._htest: # place dialog below parent if running htest top.geometry("+%d+%d" % (root.winfo_rootx(), root.winfo_rooty() + 200)) self.settitle() top.focus_set() # create scrolled canvas theme = editConf.CurrentTheme() background = editConf.GetHighlight(theme, 'normal')['background'] sc = ScrolledCanvas(top, bg=background, highlightthickness=0, takefocus=1) sc.frame.pack(expand=1, fill="both") item = self.rootnode() self.node = node = TreeNode(sc.canvas, None, item) if not self._utest: node.update() node.expand()
def reload(cls): "Load class variables from config." cls.context_depth = editConf.GetOption("extensions", "CodeContext", "maxlines", type="int", default=15) cls.colors = editConf.GetHighlight(editConf.CurrentTheme(), 'context')
def reload(cls): cls.STYLE = editConf.GetOption( 'extensions','ParenMatch','style', default='opener') cls.FLASH_DELAY = editConf.GetOption( 'extensions','ParenMatch','flash-delay', type='int',default=500) cls.BELL = editConf.GetOption( 'extensions','ParenMatch','bell', type='bool', default=1) cls.HILITE_CONFIG = editConf.GetHighlight(editConf.CurrentTheme(), 'hilite')
def color_config(text): """Set color options of Text widget. If ColorDelegator is used, this should be called first. """ # Called from htest, TextFrame, Editor, and Turtledemo. # Not automatic because ColorDelegator does not know 'text'. theme = editConf.CurrentTheme() normal_colors = editConf.GetHighlight(theme, 'normal') cursor_color = editConf.GetHighlight(theme, 'cursor', fgBg='fg') select_colors = editConf.GetHighlight(theme, 'hilite') text.config( foreground=normal_colors['foreground'], background=normal_colors['background'], insertbackground=cursor_color, selectforeground=select_colors['foreground'], selectbackground=select_colors['background'], inactiveselectbackground=select_colors['background'], # new in 8.5 )
def drawtext(self): textx = self.x + 20 - 1 texty = self.y - 4 labeltext = self.item.GetLabelText() if labeltext: id = self.canvas.create_text(textx, texty, anchor="nw", text=labeltext) self.canvas.tag_bind(id, "<1>", self.select) self.canvas.tag_bind(id, "<Double-1>", self.flip) x0, y0, x1, y1 = self.canvas.bbox(id) textx = max(x1, 200) + 10 text = self.item.GetText() or "<no text>" try: self.entry except AttributeError: pass else: self.edit_finish() try: self.label except AttributeError: # padding carefully selected (on Windows) to match Entry widget: self.label = Label(self.canvas, text=text, bd=0, padx=2, pady=2) theme = editConf.CurrentTheme() if self.selected: self.label.configure(editConf.GetHighlight(theme, 'hilite')) else: self.label.configure(editConf.GetHighlight(theme, 'normal')) id = self.canvas.create_window(textx, texty, anchor="nw", window=self.label) self.label.bind("<1>", self.select_or_edit) self.label.bind("<Double-1>", self.flip) self.text_id = id
def LoadTagDefs(self): "Create dictionary of tag names to text colors." theme = editConf.CurrentTheme() self.tagdefs = { "COMMENT": editConf.GetHighlight(theme, "comment"), "KEYWORD": editConf.GetHighlight(theme, "keyword"), "BUILTIN": editConf.GetHighlight(theme, "builtin"), "STRING": editConf.GetHighlight(theme, "string"), "DEFINITION": editConf.GetHighlight(theme, "definition"), "SYNC": {'background':None,'foreground':None}, "TODO": {'background':None,'foreground':None}, "ERROR": editConf.GetHighlight(theme, "error"), # The following is used by ReplaceDialog: "hit": editConf.GetHighlight(theme, "hit"), } if DEBUG: print('tagdefs',self.tagdefs)