Python Tkinter.Text() Examples
The following are 30
code examples of Tkinter.Text().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
Tkinter
, or try the search function
.
Example #1
Source File: test_formatparagraph.py From oss-ftp with MIT License | 6 votes |
def test_init_close(self): instance = fp.FormatParagraph('editor') self.assertEqual(instance.editwin, 'editor') instance.close() self.assertEqual(instance.editwin, None) # For testing format_paragraph_event, Initialize FormatParagraph with # a mock Editor with .text and .get_selection_indices. The text must # be a Text wrapper that adds two methods # A real EditorWindow creates unneeded, time-consuming baggage and # sometimes emits shutdown warnings like this: # "warning: callback failed in WindowList <class '_tkinter.TclError'> # : invalid command name ".55131368.windows". # Calling EditorWindow._close in tearDownClass prevents this but causes # other problems (windows left open).
Example #2
Source File: WidgetRedirector.py From oss-ftp with MIT License | 6 votes |
def _widget_redirector(parent): # htest # from Tkinter import Tk, Text import re root = Tk() root.title("Test WidgetRedirector") width, height, x, y = list(map(int, re.split('[x+]', parent.geometry()))) root.geometry("+%d+%d"%(x, y + 150)) text = Text(root) text.pack() text.focus_set() redir = WidgetRedirector(text) def my_insert(*args): print "insert", args original_insert(*args) original_insert = redir.register("insert", my_insert) root.mainloop()
Example #3
Source File: ColorDelegator.py From oss-ftp with MIT License | 6 votes |
def _color_delegator(parent): # htest # from Tkinter import Toplevel, Text from idlelib.Percolator import Percolator top = Toplevel(parent) top.title("Test ColorDelegator") top.geometry("200x100+%d+%d" % (parent.winfo_rootx() + 200, parent.winfo_rooty() + 150)) source = "if somename: x = 'abc' # comment\nprint\n" text = Text(top, background="white") text.pack(expand=1, fill="both") text.insert("insert", source) text.focus_set() p = Percolator(text) d = ColorDelegator() p.insertfilter(d)
Example #4
Source File: CallTipWindow.py From oss-ftp with MIT License | 6 votes |
def _calltip_window(parent): # htest # from Tkinter import Toplevel, Text, LEFT, BOTH top = Toplevel(parent) top.title("Test calltips") top.geometry("200x100+%d+%d" % (parent.winfo_rootx() + 200, parent.winfo_rooty() + 150)) text = Text(top) text.pack(side=LEFT, fill=BOTH, expand=1) text.insert("insert", "string.split") top.update() calltip = CallTip(text) def calltip_show(event): calltip.showtip("(s=Hello world)", "insert", "end") def calltip_hide(event): calltip.hidetip() text.event_add("<<calltip-show>>", "(") text.event_add("<<calltip-hide>>", ")") text.bind("<<calltip-show>>", calltip_show) text.bind("<<calltip-hide>>", calltip_hide) text.focus_set()
Example #5
Source File: CallTipWindow.py From Splunking-Crime with GNU Affero General Public License v3.0 | 6 votes |
def _calltip_window(parent): # htest # from Tkinter import Toplevel, Text, LEFT, BOTH top = Toplevel(parent) top.title("Test calltips") top.geometry("200x100+%d+%d" % (parent.winfo_rootx() + 200, parent.winfo_rooty() + 150)) text = Text(top) text.pack(side=LEFT, fill=BOTH, expand=1) text.insert("insert", "string.split") top.update() calltip = CallTip(text) def calltip_show(event): calltip.showtip("(s=Hello world)", "insert", "end") def calltip_hide(event): calltip.hidetip() text.event_add("<<calltip-show>>", "(") text.event_add("<<calltip-hide>>", ")") text.bind("<<calltip-show>>", calltip_show) text.bind("<<calltip-hide>>", calltip_hide) text.focus_set()
Example #6
Source File: pykms_GuiMisc.py From py-kms with The Unlicense | 6 votes |
def __init__(self, master, radios, font, changed, **kwargs): tk.Frame.__init__(self, master) self.master = master self.radios = radios self.font = font self.changed = changed self.scrollv = tk.Scrollbar(self, orient = "vertical") self.textbox = tk.Text(self, yscrollcommand = self.scrollv.set, **kwargs) self.scrollv.config(command = self.textbox.yview) # layout. self.scrollv.pack(side = "right", fill = "y") self.textbox.pack(side = "left", fill = "both", expand = True) # create radiobuttons. self.radiovar = tk.StringVar() self.radiovar.set('FILE') self.create()
Example #7
Source File: nemo_app.py From luscan-devel with GNU General Public License v2.0 | 6 votes |
def __init__(self, image, initialField, initialText): frm = tk.Frame(root) frm.config(background="white") self.image = tk.PhotoImage(format='gif',data=images[image.upper()]) self.imageDimmed = tk.PhotoImage(format='gif',data=images[image]) self.img = tk.Label(frm) self.img.config(borderwidth=0) self.img.pack(side = "left") self.fld = tk.Text(frm, **fieldParams) self.initScrollText(frm,self.fld,initialField) frm = tk.Frame(root) self.txt = tk.Text(frm, **textParams) self.initScrollText(frm,self.txt,initialText) for i in range(2): self.txt.tag_config(colors[i], background = colors[i]) self.txt.tag_config("emph"+colors[i], foreground = emphColors[i])
Example #8
Source File: ColorDelegator.py From Splunking-Crime with GNU Affero General Public License v3.0 | 6 votes |
def _color_delegator(parent): # htest # from Tkinter import Toplevel, Text from idlelib.Percolator import Percolator top = Toplevel(parent) top.title("Test ColorDelegator") top.geometry("200x100+%d+%d" % (parent.winfo_rootx() + 200, parent.winfo_rooty() + 150)) source = "if somename: x = 'abc' # comment\nprint\n" text = Text(top, background="white") text.pack(expand=1, fill="both") text.insert("insert", source) text.focus_set() p = Percolator(text) d = ColorDelegator() p.insertfilter(d)
Example #9
Source File: WidgetRedirector.py From Splunking-Crime with GNU Affero General Public License v3.0 | 6 votes |
def _widget_redirector(parent): # htest # from Tkinter import Tk, Text import re root = Tk() root.title("Test WidgetRedirector") width, height, x, y = list(map(int, re.split('[x+]', parent.geometry()))) root.geometry("+%d+%d"%(x, y + 150)) text = Text(root) text.pack() text.focus_set() redir = WidgetRedirector(text) def my_insert(*args): print("insert", args) original_insert(*args) original_insert = redir.register("insert", my_insert) root.mainloop()
Example #10
Source File: SikuliGui.py From lackey with MIT License | 6 votes |
def __init__(self, master, textvariable=None, *args, **kwargs): tk.Frame.__init__(self, master) # Init GUI self._y_scrollbar = tk.Scrollbar(self, orient=tk.VERTICAL) self._text_widget = tk.Text(self, yscrollcommand=self._y_scrollbar.set, *args, **kwargs) self._text_widget.pack(side=tk.LEFT, fill=tk.BOTH, expand=1) self._y_scrollbar.config(command=self._text_widget.yview) self._y_scrollbar.pack(side=tk.RIGHT, fill=tk.Y) if textvariable is not None: if not isinstance(textvariable, tk.Variable): raise TypeError("tkinter.Variable type expected, {} given.".format( type(textvariable))) self._text_variable = textvariable self.var_modified() self._text_trace = self._text_widget.bind('<<Modified>>', self.text_modified) self._var_trace = textvariable.trace("w", self.var_modified)
Example #11
Source File: test_formatparagraph.py From Splunking-Crime with GNU Affero General Public License v3.0 | 6 votes |
def test_init_close(self): instance = fp.FormatParagraph('editor') self.assertEqual(instance.editwin, 'editor') instance.close() self.assertEqual(instance.editwin, None) # For testing format_paragraph_event, Initialize FormatParagraph with # a mock Editor with .text and .get_selection_indices. The text must # be a Text wrapper that adds two methods # A real EditorWindow creates unneeded, time-consuming baggage and # sometimes emits shutdown warnings like this: # "warning: callback failed in WindowList <class '_tkinter.TclError'> # : invalid command name ".55131368.windows". # Calling EditorWindow._close in tearDownClass prevents this but causes # other problems (windows left open).
Example #12
Source File: guiClass.py From Video-Downloader with GNU General Public License v2.0 | 6 votes |
def __showInfo (self) : self.slave = Tkinter.Tk(); self.slave.title('Info') self.slave.resizable(width = 'false', height = 'false') info = [ 'Support: www.youku.com\nwww.tudou.com\ntv.sohu.com\nwww.letv.com\nwww.bilibili.com\nwww.acfun.tv\nwww.iqiyi.com', 'Website: http://evilcult.github.io/Video-Downloader/', 'Special Thanks: bunnyswe(https://github.com/bunnyswe)\nliuyug(https://github.com/liuyug)' ] label = Tkinter.Label(self.slave, text="Video Downloader", font = ("Helvetica", "16", 'bold'), anchor = 'center') label.grid(row = 0, pady = 10) information = Tkinter.Text(self.slave, height = 10, width = 50, highlightthickness = 0, font = ("Helvetica", "14")) information.grid(row = 1, padx = 10, pady = 5) for n in info : information.insert('end', n.split(': ')[0] + '\n') information.insert('end', n.split(': ')[1] + '\r') label = Tkinter.Label(self.slave, text="Version: " + self.version, font = ("Helvetica", "12"), anchor = 'center') label.grid(row = 2) label = Tkinter.Label(self.slave, text="Author: Ray H.", font = ("Helvetica", "12"), anchor = 'center') label.grid(row = 3)
Example #13
Source File: test_formatparagraph.py From PokemonGo-DesktopMap with MIT License | 6 votes |
def test_init_close(self): instance = fp.FormatParagraph('editor') self.assertEqual(instance.editwin, 'editor') instance.close() self.assertEqual(instance.editwin, None) # For testing format_paragraph_event, Initialize FormatParagraph with # a mock Editor with .text and .get_selection_indices. The text must # be a Text wrapper that adds two methods # A real EditorWindow creates unneeded, time-consuming baggage and # sometimes emits shutdown warnings like this: # "warning: callback failed in WindowList <class '_tkinter.TclError'> # : invalid command name ".55131368.windows". # Calling EditorWindow._close in tearDownClass prevents this but causes # other problems (windows left open).
Example #14
Source File: menotexport-gui.py From Menotexport with GNU General Public License v3.0 | 6 votes |
def addMessageFrame(self): frame=Frame(self) frame.pack(fill=tk.BOTH,side=tk.TOP,\ expand=1,padx=8,pady=5) self.messagelabel=tk.Label(frame,text='Message',bg='#bbb') self.messagelabel.pack(side=tk.TOP,fill=tk.X) self.text=tk.Text(frame) self.text.pack(side=tk.TOP,fill=tk.BOTH,expand=1) self.text.height=10 scrollbar=tk.Scrollbar(self.text) scrollbar.pack(side=tk.RIGHT,fill=tk.Y) self.text.config(yscrollcommand=scrollbar.set) scrollbar.config(command=self.text.yview)
Example #15
Source File: test_widgetredir.py From PokemonGo-DesktopMap with MIT License | 5 votes |
def setUpClass(cls): requires('gui') cls.root = Tk() cls.text = Text(cls.root)
Example #16
Source File: test_formatparagraph.py From PokemonGo-DesktopMap with MIT License | 5 votes |
def __init__(self, master): self.text = Text(master=master)
Example #17
Source File: test_formatparagraph.py From PokemonGo-DesktopMap with MIT License | 5 votes |
def setUpClass(cls): from idlelib.idle_test.mock_tk import Text cls.text = Text()
Example #18
Source File: test_parenmatch.py From PokemonGo-DesktopMap with MIT License | 5 votes |
def setUpClass(cls): requires('gui') cls.root = Tk() cls.text = Text(cls.root) cls.editwin = DummyEditwin(cls.text) cls.editwin.text_frame = Mock()
Example #19
Source File: test_editmenu.py From PokemonGo-DesktopMap with MIT License | 5 votes |
def setUpClass(cls): requires('gui') cls.root = root = tk.Tk() PyShell.fix_x11_paste(root) cls.text = tk.Text(root) cls.entry = tk.Entry(root) cls.spin = tk.Spinbox(root) root.clipboard_clear() root.clipboard_append('two')
Example #20
Source File: guiClass.py From Video-Downloader with GNU General Public License v2.0 | 5 votes |
def __autoUpdate (self) : now = int(time.time()) if self.cfg['udrate'] == 1: updateTime = int(self.cfg['udtime']) + 86400 elif self.cfg['udrate'] == 2: updateTime = int(self.cfg['udtime']) + 86400 * 7 elif self.cfg['udrate'] == 3: updateTime = int(self.cfg['udtime']) + 86400 * 30 else : updateTime = int(self.cfg['udtime']) + 86400 * 7 if updateTime < now : Updater = updateClass.Update() info = Updater.check(self.appVer) self.CfgClass.lastUd(now) if info['update'] == True : self.slave = Tkinter.Tk(); self.slave.title('Update') self.slave.resizable(width = 'false', height = 'false') label = Tkinter.Label(self.slave, text = info['version'], font = ("Helvetica", "16", 'bold'), anchor = 'center') label.grid(row = 0, pady = 10) information = Tkinter.Text(self.slave, height = 10, width = 60, highlightthickness = 0, font = ("Helvetica", "14")) information.grid(row = 1, padx = 10, pady = 5) information.insert('end', info['msg']); btn = Tkinter.Button(self.slave, text = 'Download', width = 10, command = lambda target = info['dUrl'] : webbrowser.open_new(target)) btn.grid(row = 2, pady = 10)
Example #21
Source File: guiClass.py From Video-Downloader with GNU General Public License v2.0 | 5 votes |
def __chkUpdate (self) : Updater = updateClass.Update() info = Updater.check(self.appVer) self.slave = Tkinter.Tk(); self.slave.title('Update') self.slave.resizable(width = 'false', height = 'false') if info['update'] == True : label = Tkinter.Label(self.slave, text = info['version'], font = ("Helvetica", "16", 'bold'), anchor = 'center') label.grid(row = 0, pady = 10) information = Tkinter.Text(self.slave, height = 10, width = 60, highlightthickness = 0, font = ("Helvetica", "14")) information.grid(row = 1, padx = 10, pady = 5) information.insert('end', info['msg']); btn = Tkinter.Button(self.slave, text = 'Download', width = 10, command = lambda target = info['dUrl'] : webbrowser.open_new(target)) btn.grid(row = 2, pady = 10) else : label = Tkinter.Label(self.slave, text = self.version, font = ("Helvetica", "16", 'bold'), anchor = 'center') label.grid(row = 0, pady = 10) label = Tkinter.Label(self.slave, height = 3, width = 60, text = info['msg'], font = ("Helvetica", "14"), anchor = 'center') label.grid(row = 1, pady = 10) now = int(time.time()) self.CfgClass.lastUd(now)
Example #22
Source File: test_widgets.py From oss-ftp with MIT License | 5 votes |
def create(self, **kwargs): return tkinter.Text(self.root, **kwargs)
Example #23
Source File: guiClass.py From Video-Downloader with GNU General Public License v2.0 | 5 votes |
def __showResult (self) : self.mainFoot = Tkinter.Frame(self.master, bd = 10) self.mainFoot.grid(row = 1, column = 0, sticky = '') self.__searchBtn(False) self.resultWindow = Tkinter.Text(self.mainFoot, height = 5, width = 70, highlightthickness = 0) self.resultWindow.grid(row = 0, sticky = '') threading.Thread(target = self.__getUrl).start() self.dlZone = Tkinter.Button(self.mainFoot, text = '下载', command = self.__download) self.dlZone.grid(row = 1, column = 0, sticky = 'ew') self.mainFoot.update()
Example #24
Source File: Tkinter_Widget_Examples.py From MacAdmins-2016-Craft-GUIs-with-Python-and-Tkinter with MIT License | 5 votes |
def ok(self): print('Text box:\n{}'.format(self.text.get('1.0', 'end').rstrip()))
Example #25
Source File: Tkinter_Widget_Examples.py From MacAdmins-2016-Craft-GUIs-with-Python-and-Tkinter with MIT License | 5 votes |
def __init__(self, master): tk.Frame.__init__(self, master) self.pack() tk.Label(self, text="This is a text box").pack() text_frame = tk.Frame(self, borderwidth=1, relief='sunken') text_frame.pack(padx=10, pady=10) self.text = tk.Text(text_frame, width=30, height=4, wrap=tk.WORD) self.text.pack() tk.Button(self, text='OK', command=self.ok).pack()
Example #26
Source File: Tkinter_Widget_Examples.py From MacAdmins-2016-Craft-GUIs-with-Python-and-Tkinter with MIT License | 5 votes |
def ok(self): print('Text box: {}\nSecret box: {}'.format(self.entry.get(), self.secret_entry.get()))
Example #27
Source File: test_autocomplete.py From Splunking-Crime with GNU Affero General Public License v3.0 | 5 votes |
def setUpClass(cls): requires('gui') cls.root = Tk() mac.setupApp(cls.root, None) cls.text = Text(cls.root) cls.editor = DummyEditwin(cls.root, cls.text)
Example #28
Source File: test_autoexpand.py From Splunking-Crime with GNU Affero General Public License v3.0 | 5 votes |
def setUpClass(cls): if 'Tkinter' in str(Text): requires('gui') cls.tk = Tk() cls.text = Text(cls.tk) else: cls.text = Text() cls.auto_expand = AutoExpand(Dummy_Editwin(cls.text))
Example #29
Source File: test_formatparagraph.py From Splunking-Crime with GNU Affero General Public License v3.0 | 5 votes |
def __init__(self, master): self.text = Text(master=master)
Example #30
Source File: app.py From subfinder with MIT License | 5 votes |
def _create_widgets(self): self.button_open_file = tk.Button( self, text='选择文件', command=self._open_file) self.button_open_file.grid(row=0, column=0, sticky='nswe') self.button_open_directory = tk.Button( self, text='选择目录', command=self._open_directory) self.button_open_directory.grid(row=0, column=1, sticky='nswe') frame = tk.Frame(self) self.label = tk.Label(frame, text='选中的文件或目录:') self.label.pack(side=tk.LEFT) self.label_selected = tk.Label(frame, text=self.videofile) self.label_selected.pack(side=tk.LEFT) frame.grid(row=1, column=0, columnspan=2, sticky='nswe') self.button_start = tk.Button(self, text='开始', command=self._start) self.button_start.grid( row=2, column=0, columnspan=2, pady=20, sticky='nswe') frame = tk.Frame(self) self.text_logger = tk.Text(frame) self.scrollbar = tk.Scrollbar(frame, command=self.text_logger.yview) self.text_logger.configure(yscrollcommand=self.scrollbar.set) self.text_logger.grid(row=0, column=0, sticky='nswe') self.scrollbar.grid(row=0, column=1, sticky='ns') tk.Grid.rowconfigure(self, 0, weight=1) tk.Grid.columnconfigure(frame, 0, weight=1) # tk.Grid.columnconfigure(frame, 1, weight=1) frame.grid(row=3, column=0, columnspan=2, pady=20, sticky='nswe') self._output = OutputStream(self.text_logger) self.after(100, self._display_msg) tk.Grid.rowconfigure(self, 3, weight=1) tk.Grid.columnconfigure(self, 0, weight=1) tk.Grid.columnconfigure(self, 1, weight=1)