prog = re.compile(make_pat(), re.S)
idprog = re.compile(r"\s+(\w+)", re.S)
-def color_config(text): # Called from htest, Editor, and Turtle Demo.
- '''Set color opitons of Text widget.
+def color_config(text):
+ """Set color options of Text widget.
- Should be called whenever ColorDelegator is called.
- '''
+ 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 = idleConf.CurrentTheme()
normal_colors = idleConf.GetHighlight(theme, 'normal')
inactiveselectbackground=select_colors['background'], # new in 8.5
)
+
class ColorDelegator(Delegator):
def __init__(self):
d = ColorDelegator()
p.insertfilter(d)
+
if __name__ == "__main__":
from unittest import main
main('idlelib.idle_test.test_colorizer', verbosity=2, exit=False)
from tkinter.ttk import Frame, Scrollbar, Button
from tkinter.messagebox import showerror
+from idlelib.colorizer import color_config
+
class TextFrame(Frame):
"Display text with scrollbar."
super().__init__(parent)
self['relief'] = 'sunken'
self['height'] = 700
- # TODO: get fg/bg from theme.
- self.bg = '#ffffff'
- self.fg = '#000000'
- self.text = text = Text(self, wrap='word', highlightthickness=0,
- fg=self.fg, bg=self.bg)
+ self.text = text = Text(self, wrap='word', highlightthickness=0)
+ color_config(text)
self.scroll = scroll = Scrollbar(self, orient='vertical',
takefocus=False, command=text.yview)
text['yscrollcommand'] = scroll.set