本文整理汇总了Python中tkinter.ttk.Frame.winfo_width方法的典型用法代码示例。如果您正苦于以下问题:Python Frame.winfo_width方法的具体用法?Python Frame.winfo_width怎么用?Python Frame.winfo_width使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.ttk.Frame
的用法示例。
在下文中一共展示了Frame.winfo_width方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ScrollFrame
# 需要导入模块: from tkinter.ttk import Frame [as 别名]
# 或者: from tkinter.ttk.Frame import winfo_width [as 别名]
class ScrollFrame(Frame):
def __init__(self,parent):
Frame.__init__(self, master=parent)
canvas = tkinter.Canvas(self, highlightthickness=0)
self.innerFrame = Frame(canvas)
myscrollbar = Scrollbar(self, orient="vertical")
myscrollbar.configure(command=canvas.yview)
def scrollbarSet(top, bottom):
# Hides and shows the scroll frame depending on need
if float(top) > 0 or float(bottom) < 1:
myscrollbar.grid(row=0, column=1, sticky="NS")
else:
pass
myscrollbar.grid_remove()
myscrollbar.set(top, bottom)
canvas.configure(yscrollcommand = scrollbarSet)
configureFunc = lambda _ : canvas.configure(scrollregion=canvas.bbox("all"))
frameID = canvas.create_window((0,0), window=self.innerFrame, anchor='nw')
self.innerFrame.bind("<Configure>",configureFunc)
canvas.grid(row=0, column=0, sticky="NSEW")
myscrollbar.grid(row=0, column=1, sticky="NS")
self.grid_rowconfigure(0, weight=1)
self.grid_columnconfigure(0, weight=0)
#canvas.bind("<Configure>", lambda e : canvas.itemconfig(frameID, width=e.width))
canvas.bind("<Configure>", lambda e : canvas.configure(width=self.innerFrame.winfo_width()))