本文整理汇总了Python中tkinter.ttk方法的典型用法代码示例。如果您正苦于以下问题:Python tkinter.ttk方法的具体用法?Python tkinter.ttk怎么用?Python tkinter.ttk使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter
的用法示例。
在下文中一共展示了tkinter.ttk方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import ttk [as 别名]
def __init__(self, master,
text='', buttons=[], default=None, cancel=None,
title=None, class_=None):
if class_:
self.root = Toplevel(master, class_=class_)
else:
self.root = Toplevel(master)
if title:
self.root.title(title)
self.root.iconname(title)
self.message = Message(self.root, text=text, aspect=400)
self.message.pack(expand=1, fill=BOTH)
self.frame = Frame(self.root)
self.frame.pack()
self.num = default
self.cancel = cancel
self.default = default
self.root.bind('<Return>', self.return_event)
self.root.bind('<Escape>', self.wm_delete_window)
for num in range(len(buttons)):
s = buttons[num]
f = Frame(self.frame)
b = ttk.Button(f, text=s,
command=(lambda self=self, num=num: self.done(num)))
b.pack(side=LEFT, fill=BOTH)
f.pack(side=TOP, fill=BOTH)
self.root.protocol('WM_DELETE_WINDOW', self.wm_delete_window)
self._set_transient(master)
示例2: __init__
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import ttk [as 别名]
def __init__(self, master):
super().__init__(master)
# Get the username and save list of found files.
self.__user = getpass.getuser()
self.__dirlist = set()
# Create widgets.
self.__log = tkinter.Text(self)
self.__bar = tkinter.ttk.Scrollbar(self, orient=tkinter.VERTICAL,
command=self.__log.yview)
self.__ent = tkinter.ttk.Entry(self, cursor='xterm')
# Configure widgets.
self.__log.configure(state=tkinter.DISABLED, wrap=tkinter.WORD,
yscrollcommand=self.__bar.set)
# Create binding.
self.__ent.bind('<Return>', self.create_message)
# Position widgets.
self.__log.grid(row=0, column=0, sticky=tkinter.NSEW)
self.__bar.grid(row=0, column=1, sticky=tkinter.NS)
self.__ent.grid(row=1, column=0, columnspan=2, sticky=tkinter.EW)
# Configure resizing.
self.grid_rowconfigure(0, weight=1)
self.grid_columnconfigure(0, weight=1)
# Focus entry.
self.__ent.focus_set()
# Schedule message discovery.
self.after_idle(self.get_messages)
示例3: restore_binding
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import ttk [as 别名]
def restore_binding(self):
if self.system == 'Windows':
def _on_mousewheel(event):
self.sampleList.scroll(-1*(event.delta//120))
return "break"
self.bind('<MouseWheel>', _on_mousewheel)
# TODO: add an option to select behaviour
# do not scroll the interface if mouse is on a ttk Combobox
#self.bind_class('TCombobox', '<MouseWheel>', lambda e: "break", "+")
## do not change ttk Combobox content on mouse wheel event
self.bind_class('TCombobox', '<MouseWheel>', lambda e: None)
elif self.system == 'Darwin':
def _on_mousewheel(event):
self.sampleList.scroll(-1*(event.delta))
self.bind('<MouseWheel>', _on_mousewheel)
#self.bind_class('TCombobox', '<MouseWheel>', lambda e: "break", "+")
self.bind_class('TCombobox', '<MouseWheel>', lambda e: None)
else:
def _on_up(event):
self.sampleList.scroll(-1)
def _on_down(event):
self.sampleList.scroll(1)
self.bind('<Button-4>', _on_up)
self.bind('<Button-5>', _on_down)
#self.bind_class('TCombobox', '<Button-4>', lambda e: "break", "+")
#self.bind_class('TCombobox', '<Button-5>', lambda e: "break", "+")
self.bind_class('TCombobox', '<Button-4>', lambda e: None)
self.bind_class('TCombobox', '<Button-5>', lambda e: None)
示例4: __init__
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import ttk [as 别名]
def __init__(self, parent, *arg, **kwarg):
super().__init__(*arg, **kwarg)
self.vscrollbar = tk.ttk.Scrollbar(self, orient=tk.VERTICAL, command=self.on_scroll)
self.vscrollbar.pack(fill=tk.Y, side=tk.RIGHT)
self.canvas = tk.Canvas(self, bd=0, highlightthickness=0, confine=0)
self.canvas.pack(side=tk.LEFT, fill=tk.BOTH, expand=True)
self.frame = tk.Frame(self.canvas)
self.frame_id = self.canvas.create_window(0, 0, window=self.frame, anchor=tk.NW)
self.parent = parent
self.stopButton = tk.Button(self.frame, image=GUI.res.stop_smallIcon, command=self.play_stop)
ToolTip(self.stopButton, follow_mouse=1, text="stop playback")
tk.Label(self.frame, text="#Num").grid(row=0, column=3)
tk.Label(self.frame, text="Name").grid(row=0, column=4)
tk.Label(self.frame, text="Cat.").grid(row=0, column=5)
tk.Label(self.frame, text="1-shot").grid(row=0, column=6)
tk.Label(self.frame, text="+12dB").grid(row=0, column=7)
tk.Label(self.frame, text="Tune").grid(row=0, column=8)
self.stopButton.grid(row=0, column=9, padx=5)
tk.Label(self.frame, text="Freq (Hz)").grid(row=0, column=10)
tk.Label(self.frame, text="Time (s)").grid(row=0, column=11)
tk.Label(self.frame, text="Stereo").grid(row=0,column=12)
tk.Label(self.frame, text="Data Size").grid(row=0, column=13)
tk.Frame(self.frame, width=2, bd=1, relief=tk.SUNKEN).grid(row=0, column=1, rowspan=999, sticky=tk.N+tk.S)
self.fill = tk.Label(self.frame)
self.fill.grid(row=998, column=2, columnspan=12, sticky=tk.NSEW)
tk.Grid.rowconfigure(self.frame, 998, weight=1)
self.fill.config(height=self.canvas.winfo_reqheight())
self.sliceEditDialog = None
self.selectV = tk.IntVar()
self.WAVDataSize = tk.IntVar()
self.samples = []
self.samples_garbage = []
self.e2s_samples = []
self.update_scrollbar()
# track changes to the canvas and frame width and sync them,
def _configure_frame(event):
# update the canvas's width to fit the inner frame
if self.canvas.winfo_reqwidth() != self.frame.winfo_reqwidth():
self.canvas.config(width=self.frame.winfo_reqwidth())
self.frame.bind('<Configure>', _configure_frame)
self.canvas.bind('<Configure>', self._on_configure)