def __init__(self, master=None, **kw): # Get the filename associated with this widget's contents, if any. self.filename = kw.pop('filename', False) #Turn on undo, but don't override a passed-in setting. kw.setdefault('undo', True) # kw.setdefault('bg', 'white') kw.setdefault('wrap', 'word') kw.setdefault('font', 'arial 12') #Create ourselves as a Tkinter Text Text.__init__(self, master, **kw) #Initialize our mouse mixin. mousebindingsmixin.__init__(self) #Add tag config for command highlighting. self.tag_config('command', **self.command_tags) #Create us a command instance variable self.command = '' #Activate event bindings. Modify text_bindings in your config #file to affect the key bindings and whatnot here. for event_sequence, callback_finder in text_bindings.iteritems(): callback = callback_finder(self) self.bind(event_sequence, callback) self.tk.call(self._w, 'edit', 'modified', 0) self.bind('<<Modified>>', self._beenModified) self._resetting_modified_flag = False
def __init__(self, master=None, change_hook=None, **kw): self.frame = Frame(master) self.vbar = Scrollbar(self.frame) self.vbar.pack(side=RIGHT, fill=Y) self.hbar = Scrollbar(self.frame, orient=HORIZONTAL) self.hbar.pack(side=BOTTOM, fill=X) kw.update({'yscrollcommand': self.vbar.set}) kw.update({'xscrollcommand': self.hbar.set}) kw.update({'wrap': 'none'}) Text.__init__(self, self.frame, **kw) self.pack(side=LEFT, fill=BOTH, expand=True) self.vbar['command'] = self.yview self.hbar['command'] = self.xview # Copy geometry methods of self.frame without overriding Text # methods -- hack! text_meths = vars(Text).keys() methods = vars(Pack).keys() + vars(Grid).keys() + vars(Place).keys() methods = set(methods).difference(text_meths) for m in methods: if m[0] != '_' and m != 'config' and m != 'configure': setattr(self, m, getattr(self.frame, m))
def __init__(self, *args, **kwargs): Text.__init__(self, *args, **kwargs) self.redirector = WidgetRedirector(self) self.insert = \ self.redirector.register("insert", lambda *args, **kw: "break") self.delete = \ self.redirector.register("delete", lambda *args, **kw: "break")
def __init__(self, parent, filename): "Configure tags and feed file to parser." uwide = idleConf.GetOption('main', 'EditorWindow', 'width', type='int') uhigh = idleConf.GetOption('main', 'EditorWindow', 'height', type='int') uhigh = 3 * uhigh // 4 # lines average 4/3 of editor line height Text.__init__(self, parent, wrap='word', highlightthickness=0, padx=5, borderwidth=0, width=uwide, height=uhigh) normalfont = self.findfont(['TkDefaultFont', 'arial', 'helvetica']) fixedfont = self.findfont(['TkFixedFont', 'monaco', 'courier']) self['font'] = (normalfont, 12) self.tag_configure('em', font=(normalfont, 12, 'italic')) self.tag_configure('h1', font=(normalfont, 20, 'bold')) self.tag_configure('h2', font=(normalfont, 18, 'bold')) self.tag_configure('h3', font=(normalfont, 15, 'bold')) self.tag_configure('pre', font=(fixedfont, 12), background='#f6f6ff') self.tag_configure('preblock', font=(fixedfont, 10), lmargin1=25, borderwidth=1, relief='solid', background='#eeffcc') self.tag_configure('l1', lmargin1=25, lmargin2=25) self.tag_configure('l2', lmargin1=50, lmargin2=50) self.tag_configure('l3', lmargin1=75, lmargin2=75) self.tag_configure('l4', lmargin1=100, lmargin2=100) self.parser = HelpParser(self) with open(filename) as f: contents = f.read().decode(encoding='utf-8') self.parser.feed(contents) self['state'] = 'disabled'
def __init__(self, parent, filename): "Configure tags and feed file to parser." uwide = idleConf.GetOption('main', 'EditorWindow', 'width', type='int') uhigh = idleConf.GetOption('main', 'EditorWindow', 'height', type='int') uhigh = 3 * uhigh // 4 # lines average 4/3 of editor line height Text.__init__(self, parent, wrap='word', highlightthickness=0, padx=5, borderwidth=0, width=uwide, height=uhigh) normalfont = self.findfont(['TkDefaultFont', 'arial', 'helvetica']) fixedfont = self.findfont(['TkFixedFont', 'monaco', 'courier']) self['font'] = (normalfont, 12) self.tag_configure('em', font=(normalfont, 12, 'italic')) self.tag_configure('h1', font=(normalfont, 20, 'bold')) self.tag_configure('h2', font=(normalfont, 18, 'bold')) self.tag_configure('h3', font=(normalfont, 15, 'bold')) self.tag_configure('pre', font=(fixedfont, 12), background='#f6f6ff') self.tag_configure('preblock', font=(fixedfont, 10), lmargin1=25, borderwidth=1, relief='solid', background='#eeffcc') self.tag_configure('l1', lmargin1=25, lmargin2=25) self.tag_configure('l2', lmargin1=50, lmargin2=50) self.tag_configure('l3', lmargin1=75, lmargin2=75) self.tag_configure('l4', lmargin1=100, lmargin2=100) self.parser = HelpParser(self) with open(filename) as f: contents = f.read().decode(encoding='utf-8') self.parser.feed(contents) self['state'] = 'disabled'
def __init__(self, master=None, change_hook=None, **kw): self.frame = Frame(master) self.vbar = Scrollbar(self.frame) self.vbar.pack(side=RIGHT, fill=Y) self.hbar = Scrollbar(self.frame, orient=HORIZONTAL) self.hbar.pack(side=BOTTOM,fill=X) kw.update({'yscrollcommand': self.vbar.set}) kw.update({'xscrollcommand': self.hbar.set}) kw.update({'wrap': 'none'}) Text.__init__(self, self.frame, **kw) self.pack(side=LEFT, fill=BOTH, expand=True) self.vbar['command'] = self.yview self.hbar['command'] = self.xview # Copy geometry methods of self.frame without overriding Text # methods -- hack! text_meths = vars(Text).keys() methods = vars(Pack).keys() + vars(Grid).keys() + vars(Place).keys() methods = set(methods).difference(text_meths) for m in methods: if m[0] != '_' and m != 'config' and m != 'configure': setattr(self, m, getattr(self.frame, m))
def __init__(self, master=None, **kw): # Get the filename associated with this widget's contents, if any. self.filename = kw.pop('filename', False) #Turn on undo, but don't override a passed-in setting. kw.setdefault('undo', True) # kw.setdefault('bg', 'white') kw.setdefault('wrap', 'word') kw.setdefault('font', 'arial 12') #Create ourselves as a Tkinter Text Text.__init__(self, master, **kw) #Initialize our mouse mixin. mousebindingsmixin.__init__(self) #Add tag config for command highlighting. self.tag_config('command', **self.command_tags) #Create us a command instance variable self.command = '' #Activate event bindings. Modify text_bindings in your config #file to affect the key bindings and whatnot here. for event_sequence, callback_finder in text_bindings.iteritems(): callback = callback_finder(self) self.bind(event_sequence, callback) self.tk.call(self._w, 'edit', 'modified', 0) self.bind('<<Modified>>', self._beenModified) self._resetting_modified_flag = False
def __init__(self, parent, scrollbar=True, **kw): self.parent = parent frame = Frame(parent) frame.pack(fill='both', expand=True) # text widget Text.__init__(self, frame, **kw) self.pack(side='left', fill='both', expand=True) # scrollbar if scrollbar: scrb = Scrollbar(frame, orient='vertical', command=self.yview) self.config(yscrollcommand=scrb.set) scrb.pack(side='right', fill='y') # pop-up menu self.popup = Menu(self, tearoff=0) self.popup.add_command(label='Cut', command=self._cut) self.popup.add_command(label='Copy', command=self._copy) self.popup.add_command(label='Paste', command=self._paste) self.popup.add_separator() self.popup.add_command(label='Select All', command=self._select_all) self.popup.add_command(label='Clear All', command=self._clear_all) self.bind('<Button-3>', self._show_popup)
def __init__(self, *a, **b): # Create self as a Text. Text.__init__(self, *a, **b) # Initialize the ModifiedMixin. self._init()
def __init__(self, *a, **b): # Create self as a Text. Text.__init__(self, *a, **b) # Initialize the ModifiedMixin. self._init()
def __init__(self, master, **options): Text.__init__(self, master, **options) self.config(highlightbackground=background, selectbackground="Dodger Blue", selectforeground="White") self.height = options.get("height", 20) self.queue = Queue.Queue() self.update()
def __init__(self, master, **options): Text.__init__(self, master, **options) self.root = master self.config(highlightbackground=background, selectbackground="Dodger Blue", selectforeground="White") self.height = options.get("height", 20) self.queue = Queue.Queue() self.lines = 0 # number of lines in the text self.modifying = False self.update()
def __init__(self, *args, **kwdargs): Text.__init__(self, *args, **kwdargs) self.redirector = WidgetRedirector(self) self.insert = self.redirector.register("insert", lambda *args, **kw: "break") self.delete = self.redirector.register("delete", lambda *args, **kw: "break") self.replace = self.redirector.register("replace", lambda *args, **kw: "break")
def __init__(self, root=None, **args): Text.__init__(self, root, **args) self.main = self.master.master self.create_syntas_tags() self.bind("<Key>", self.update_syntax) self.config(maxundo=15, undo=True, bg="white") self.update_linenumber()
def __init__(self, *args, **kwargs): """ initialize our specialized tkinter Text widget """ Text.__init__(self, *args, **kwargs) self.known_tags = set([]) # register a default color tag self.register_tag("30", "White", "Black") self.reset_to_default_attribs()
def __init__(self, parent): """ initialize our specialized tkinter Text widget """ Text.__init__(self, parent) self.known_tags = set([]) self.configure(background="Black") # register a default color tag self.register_tag("30", "White", "Black") self.reset_to_default_attribs()
def __init__(self, *args, **kwargs): """ Trashes every attempt to modify the text area coming from user input. """ Text.__init__(self, *args, **kwargs) self.redirector = WidgetRedirector(self) self.insert = \ self.redirector.register("insert", lambda *args, **kw: "break") self.delete = \ self.redirector.register("delete", lambda *args, **kw: "break")
def __init__(self, api, text="", id=None): self.master = Tk() self.id = id self.api = api Text.__init__(self, self.master, bg="#f9f3a9", wrap="word", undo=True) self.bind("<Control-n>", self.create) self.bind("<Control-s>", self.save) if id: self.master.title("#%d" % id) self.delete("1.0", "end") self.insert("1.0", text) self.master.geometry("220x235") self.pack(fill="both", expand=1)
def __init__(self, *args, **kwargs): """ Trashes every attempt to modify the text area coming from user input. """ Text.__init__(self, *args, **kwargs) self.redirector = WidgetRedirector(self) self.insert = \ self.redirector.register("insert", lambda *args, **kw: "break") self.delete = \ self.redirector.register("delete", lambda *args, **kw: "break")
def __init__(self, api, text='', id=None): self.master = Tk() self.id = id self.api = api Text.__init__(self, self.master, bg='#f9f3a9', wrap='word', undo=True) self.bind('<Control-n>', self.create) self.bind('<Control-s>', self.save) if id: self.master.title('#%d' % id) self.delete('1.0', 'end') self.insert('1.0', text) self.master.geometry('220x235') self.pack(fill='both', expand=1)
def __init__(self, master = None, **kw): self.frame = Frame(master) self.vbar = Scrollbar(self.frame) self.vbar.pack(side=RIGHT, fill=Y) kw.update({'yscrollcommand': self.vbar.set}) Text.__init__(self, self.frame, **kw) self.pack(side=LEFT, fill=BOTH, expand=True) self.vbar['command'] = self.yview text_meths = vars(Text).keys() methods = vars(Pack).keys() + vars(Grid).keys() + vars(Place).keys() methods = set(methods).difference(text_meths) for m in methods: if m[0] != '_' and m != 'config' and m != 'configure': setattr(self, m, getattr(self.frame, m))
def __init__(self, parent, data_model=None, key=None, context_manager=None, tcl_buffer_size=100, tcl_buffer_low_cutoff=0.25, tcl_buffer_high_cutoff=0.75, tcl_moveto_yview=0.50, max_lines_jump=10, **kwargs): Text.__init__(self, parent, **kwargs) self.scroller = None self.context_manager = context_manager self.TCL_BUFFER_SIZE = tcl_buffer_size self.TCL_BUFFER_LOW_CUTOFF = tcl_buffer_low_cutoff self.TCL_BUFFER_HIGH_CUTOFF = tcl_buffer_high_cutoff self.TCL_MOVETO_YVIEW = tcl_moveto_yview self.MAX_LINES_JUMP = max_lines_jump self.reset() self.data_model = data_model self.key = key self.setCursor(START)
def __init__(self, master=None, **kw): self.frame = Frame(master) self.vbar = Scrollbar(self.frame) self.vbar.pack(side=RIGHT, fill=Y) kw.update({'yscrollcommand': self.vbar.set}) Text.__init__(self, self.frame, **kw) self.pack(side=LEFT, fill=BOTH, expand=True) self.vbar['command'] = self.yview text_meths = vars(Text).keys() methods = vars(Pack).keys() + vars(Grid).keys() + vars(Place).keys() methods = set(methods).difference(text_meths) for m in methods: if m[0] != '_' and m != 'config' and m != 'configure': setattr(self, m, getattr(self.frame, m))
def __init__(self): self.root = tk.Tk() self.frame = tk.Frame(self.root) self.frame.pack(fill='both', expand=True) # text widget #self.text = tk.Text(self.frame, borderwidth=3, relief="sunken") Text.__init__(self, self.frame, borderwidth=3, relief="sunken") self.config(tabs=(400, )) # configure Text widget tab stops self.config(background='black', foreground='white', font=("consolas", 12), wrap='word', undo='True') self.config(height=24, width=120) self.pack(side='left', fill='both', expand=True) self.tag_config('normal', foreground='white') self.tag_config('warning', foreground='yellow') self.tag_config('error', foreground='red') self.tag_config('highlight_green', foreground='green') self.tag_config('highlight_blue', foreground='cyan') # self.bind('<Control-Key-a>', self.select_all) # the event happens but the action doesn't # scrollbar scrb = tk.Scrollbar(self.frame, orient='vertical', command=self.yview) self.config(yscrollcommand=scrb.set) scrb.pack(side='right', fill='y') # pop-up menu self.popup = tk.Menu(self, tearoff=0) self.popup.add_command(label='Cut', command=self._cut) self.popup.add_command(label='Copy', command=self._copy) self.popup.add_command(label='Paste', command=self._paste) self.popup.add_separator() self.popup.add_command(label='Select All', command=self._select_all) self.popup.add_command(label='Clear All', command=self._clear_all) self.popup.add_separator() self.popup.add_command(label='Save As', command=self._file_save_as) self.bind('<Button-3>', self._show_popup)
def __init__(self, *args, **kwargs): Text.__init__(self, *args, **kwargs) self.config(wrap='none') #Scrollbar self.yscrollframe = Frame(self.master) self.yscroll = ttk.Scrollbar(self.yscrollframe, orient='vertical', cursor='arrow', command=self.yview) self.config(yscrollcommand=self.yscroll.set) self.yscrollframe.pack(side='right', fill='y') self.yscroll.pack(expand=True, fill='y') #Line Numbers self.lnframe = Frame(self.master) self.linenotify = lncnv.LineCanvas(self.lnframe) self.linenotify.subscribe(self) self.lnframe.pack(side='left', fill='y') self.linenotify.pack(expand=True, fill='y') self.add_intercept() self.bind('<Configure>', self.linenotify.update) self.bind('<<Changed>>', self.linenotify.update) self.bind('<KeyRelease>', self.linenotify.update)
def __init__(self, parent, data_model=None, key=None, context_manager=None, tcl_buffer_size=100, tcl_buffer_low_cutoff=0.25, tcl_buffer_high_cutoff=0.75, tcl_moveto_yview=0.50, max_lines_jump=10, **kwargs): Text.__init__(self, parent, **kwargs) self.scroller = None self.context_manager = context_manager self.TCL_BUFFER_SIZE = tcl_buffer_size self.TCL_BUFFER_LOW_CUTOFF = tcl_buffer_low_cutoff self.TCL_BUFFER_HIGH_CUTOFF = tcl_buffer_high_cutoff self.TCL_MOVETO_YVIEW = tcl_moveto_yview self.MAX_LINES_JUMP = max_lines_jump self.reset() self.data_model = data_model self.key = key self.setCursor(START)
def __init__(self): self.root = tk.Tk() self.frame = tk.Frame(self.root) self.frame.pack(fill='both', expand=True) # text widget #self.text = tk.Text(self.frame, borderwidth=3, relief="sunken") Text.__init__(self, self.frame, borderwidth=3, relief="sunken") self.config(tabs=(400, )) # configure Text widget tab stops self.config(background='black', foreground='white', font=("consolas", 12), wrap='word', undo='True') # self.config(background = 'black', foreground = 'white', font= ("consolas", 12), wrap = 'none', undo = 'True') self.config(height=24, width=100) self.config(insertbackground='pale green') # keyboard insertion point self.pack(side='left', fill='both', expand=True) self.tag_config('normal', foreground='white') self.tag_config('warning', foreground='yellow') self.tag_config('error', foreground='red') self.tag_config('highlight_green', foreground='green') self.tag_config('highlight_blue', foreground='cyan') self.tag_config('error_highlight_inactive', background='dim gray') self.tag_config('error_highlight_active', background='light grey') self.bind_class( "Text", "<Control-a>", self.select_all) # required in windows, works in others self.bind_all("<Control-Shift-E>", self.scroll_errors) self.bind_class("<Control-Shift-R>", self.rebuild) # scrollbar scrb = tk.Scrollbar(self.frame, orient='vertical', command=self.yview) self.config(yscrollcommand=scrb.set) scrb.pack(side='right', fill='y') # self.scrb_Y = tk.Scrollbar(self.frame, orient='vertical', command=self.yview) # self.scrb_Y.config(yscrollcommand=self.scrb_Y.set) # self.scrb_Y.pack(side='right', fill='y') # # self.scrb_X = tk.Scrollbar(self.frame, orient='horizontal', command=self.xview) # self.scrb_X.config(xscrollcommand=self.scrb_X.set) # self.scrb_X.pack(side='bottom', fill='x') # scrb_X = tk.Scrollbar(self, orient=tk.HORIZONTAL, command=self.xview) # tk.HORIZONTAL now have a horizsontal scroll bar BUT... shrinks it to a postage stamp and hides far right behind the vertical scroll bar # self.config(xscrollcommand=scrb_X.set) # scrb_X.pack(side='bottom', fill='x') # # scrb= tk.Scrollbar(self, orient='vertical', command=self.yview) # self.config(yscrollcommand=scrb.set) # scrb.pack(side='right', fill='y') # self.config(height = 240, width = 1000) # didn't get the size baCK TO NORMAL # self.pack(side='left', fill='both', expand=True) # didn't get the size baCK TO NORMAL # pop-up menu self.popup = tk.Menu(self, tearoff=0) self.popup.add_command(label='Copy', command=self._copy) self.popup.add_command(label='Paste', command=self._paste) self.popup.add_separator() self.popup.add_command(label='Cut', command=self._cut) self.popup.add_separator() self.popup.add_command(label='Select All', command=self._select_all) self.popup.add_command(label='Clear All', command=self._clear_all) self.popup.add_separator() self.popup.add_command(label='Save As', command=self._file_save_as) self.popup.add_separator() # self.popup.add_command(label='Repeat Build(CTL-shift-r)', command=self._rebuild) self.popup.add_command(label='Repeat Build', command=self._rebuild) self.popup.add_separator() self.popup.add_command(label='Scroll Errors (CTL-shift-e)', command=self._scroll_errors) self.popup.add_separator() self.popup.add_command(label='Open File at Cursor', command=self._open_selected_file) if current_OS == 'Darwin': # MAC self.bind('<Button-2>', self._show_popup) # macOS only else: self.bind('<Button-3>', self._show_popup) # Windows & Linux
def __init__(self, root, **kwargs): Text.__init__(self, root, **kwargs)
def __init__(self): self.root = tk.Tk() self.frame = tk.Frame(self.root) self.frame.pack(fill='both', expand=True) # text widget #self.text = tk.Text(self.frame, borderwidth=3, relief="sunken") Text.__init__(self, self.frame, borderwidth=3, relief="sunken") self.config(tabs=(400,)) # configure Text widget tab stops self.config(background = 'black', foreground = 'white', font= ("consolas", 12), wrap = 'word', undo = 'True') # self.config(background = 'black', foreground = 'white', font= ("consolas", 12), wrap = 'none', undo = 'True') self.config(height = 24, width = 100) self.config(insertbackground = 'pale green') # keyboard insertion point self.pack(side='left', fill='both', expand=True) self.tag_config('normal', foreground = 'white') self.tag_config('warning', foreground = 'yellow' ) self.tag_config('error', foreground = 'red') self.tag_config('highlight_green', foreground = 'green') self.tag_config('highlight_blue', foreground = 'cyan') self.tag_config('error_highlight_inactive', background = 'dim gray') self.tag_config('error_highlight_active', background = 'light grey') self.bind_class("Text","<Control-a>", self.select_all) # required in windows, works in others self.bind_all("<Control-Shift-E>", self.scroll_errors) self.bind_class("<Control-Shift-R>", self.rebuild) # scrollbar scrb = tk.Scrollbar(self.frame, orient='vertical', command=self.yview) self.config(yscrollcommand=scrb.set) scrb.pack(side='right', fill='y') # self.scrb_Y = tk.Scrollbar(self.frame, orient='vertical', command=self.yview) # self.scrb_Y.config(yscrollcommand=self.scrb_Y.set) # self.scrb_Y.pack(side='right', fill='y') # # self.scrb_X = tk.Scrollbar(self.frame, orient='horizontal', command=self.xview) # self.scrb_X.config(xscrollcommand=self.scrb_X.set) # self.scrb_X.pack(side='bottom', fill='x') # scrb_X = tk.Scrollbar(self, orient=tk.HORIZONTAL, command=self.xview) # tk.HORIZONTAL now have a horizsontal scroll bar BUT... shrinks it to a postage stamp and hides far right behind the vertical scroll bar # self.config(xscrollcommand=scrb_X.set) # scrb_X.pack(side='bottom', fill='x') # # scrb= tk.Scrollbar(self, orient='vertical', command=self.yview) # self.config(yscrollcommand=scrb.set) # scrb.pack(side='right', fill='y') # self.config(height = 240, width = 1000) # didn't get the size baCK TO NORMAL # self.pack(side='left', fill='both', expand=True) # didn't get the size baCK TO NORMAL # pop-up menu self.popup = tk.Menu(self, tearoff=0) self.popup.add_command(label='Copy', command=self._copy) self.popup.add_command(label='Paste', command=self._paste) self.popup.add_separator() self.popup.add_command(label='Cut', command=self._cut) self.popup.add_separator() self.popup.add_command(label='Select All', command=self._select_all) self.popup.add_command(label='Clear All', command=self._clear_all) self.popup.add_separator() self.popup.add_command(label='Save As', command=self._file_save_as) self.popup.add_separator() # self.popup.add_command(label='Repeat Build(CTL-shift-r)', command=self._rebuild) self.popup.add_command(label='Repeat Build', command=self._rebuild) self.popup.add_separator() self.popup.add_command(label='Scroll Errors (CTL-shift-e)', command=self._scroll_errors) self.popup.add_separator() self.popup.add_command(label='Open File at Cursor', command=self._open_selected_file) if current_OS == 'Darwin': # MAC self.bind('<Button-2>', self._show_popup) # macOS only else: self.bind('<Button-3>', self._show_popup) # Windows & Linux
def __init__(self, root): Text.__init__(self, bd=0, width=600, highlightthickness=0) self.master = root self.focus_force() self.pack()
def __init__(self, *args, **kwargs): Text.__init__(self, *args, **kwargs)
def __init__(self, parent): Text.__init__(self, parent)
def __init__(self, master, **options): Text.__init__(self, master, **options) self.config(highlightbackground=background) self.height = options.get("height", 20) self.queue = Queue.Queue() self.update()
def __init__(self, *a, **b): Text.__init__(self, *a, **b) self._init()
def __init__(self, master, **options): Text.__init__(self, master, **options) self.height = options.get("height", 20) self.queue = Queue.Queue() self.update()
def __init__(self, master, **options): Text.__init__(self, master, **options) self.queue = Queue.Queue() self.check_queue()
def __init__(self, master, **options): Text.__init__(self, master, **options) self.queue = Queue.Queue() self.update()
def __init__(self, root, **kwargs): Text.__init__(self, root, **kwargs)
def __init__(self, parent): Text.__init__(self, parent)