本文整理汇总了Python中Tkinter.Text方法的典型用法代码示例。如果您正苦于以下问题:Python Tkinter.Text方法的具体用法?Python Tkinter.Text怎么用?Python Tkinter.Text使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tkinter
的用法示例。
在下文中一共展示了Tkinter.Text方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Text [as 别名]
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)
示例2: _color_delegator
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Text [as 别名]
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)
示例3: _widget_redirector
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Text [as 别名]
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()
示例4: _calltip_window
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Text [as 别名]
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()
示例5: test_init_close
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Text [as 别名]
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).
示例6: __init__
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Text [as 别名]
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()
示例7: __init__
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Text [as 别名]
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])
示例8: _widget_redirector
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Text [as 别名]
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()
示例9: __showInfo
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Text [as 别名]
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)
示例10: addMessageFrame
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Text [as 别名]
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)
示例11: setUp
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Text [as 别名]
def setUp(self):
self.root = setup_master()
self.text = Tkinter.Text(self.root)
示例12: create
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Text [as 别名]
def create(self, **kwargs):
return tkinter.Text(self.root, **kwargs)
示例13: setUp
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Text [as 别名]
def setUp(self):
super(TextTest, self).setUp()
self.text = tkinter.Text(self.root)
示例14: __init__
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Text [as 别名]
def __init__(self, master):
self.text = tkText(master=master)
self._bell = False
示例15: setUpClass
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Text [as 别名]
def setUpClass(cls):
requires('gui')
cls.root = Tk()
cls.text = Text(cls.root)
cls.editwin = DummyEditwin(cls.text)