本文整理汇总了Python中ttk.Scrollbar.configure方法的典型用法代码示例。如果您正苦于以下问题:Python Scrollbar.configure方法的具体用法?Python Scrollbar.configure怎么用?Python Scrollbar.configure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ttk.Scrollbar
的用法示例。
在下文中一共展示了Scrollbar.configure方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TextWindow
# 需要导入模块: from ttk import Scrollbar [as 别名]
# 或者: from ttk.Scrollbar import configure [as 别名]
class TextWindow(Frame):
""" A basic, scrollable text window that can either be editable or not """
def __init__(self, master):
""" Make a scrollable, resizeable text """
Frame.__init__(self, master)
# Add a horizontal and vertical scroller
self.hscroller = Scrollbar(self, orient=HORIZONTAL)
self.vscroller = Scrollbar(self, orient=VERTICAL)
# Make the text box
self.text = Text(self, width=90, state=DISABLED, height=15, wrap=NONE,
xscrollcommand=self.hscroller.set,
yscrollcommand=self.vscroller.set)
# Pack everything in there, nice and tight. Let the text expand and the
# scroll bars lengthen, but do not let the scroll bars thicken.
self.text.grid(column=0, row=0, sticky=N+S+E+W)
self.hscroller.grid(column=0, row=1, sticky=N+S+E+W)
self.vscroller.grid(column=1, row=0, sticky=N+S+E+W)
self.columnconfigure(0, weight=1)
self.columnconfigure(1, weight=0)
self.rowconfigure(0, weight=1)
self.rowconfigure(1, weight=0)
# Now make the scroll bars actually work
self.hscroller.configure(command=self.text.xview)
self.vscroller.configure(command=self.text.yview)
def write(self, s):
"""
Writes 's' to the window, such that it will emulate a file. We have to
change the state to ACTIVE in order to add text, but then change it back
to the original state afterwards
"""
self.text.configure(state=NORMAL)
self.text.insert(END, s)
self.text.configure(state=DISABLED)
def clear(self, event=None):
""" Clears all text from this window """
self.text.config(state=NORMAL)
self.text.delete('0.0', END)
self.text.config(state=DISABLED)