如何让sash_place()在启动时工作?

时间:2014-12-09 10:11:32

标签: python tkinter

我有一个Tkinter PanedWindow,如果我使用带有函数的sash_place(0,50,50),它可以正常工作。如果,无论是谁,我想最初放置它,它什么都不做。如何在启动时放置窗扇?

import Tkinter as tk

def move():
    allContent.sash_place(0,100,100)

root = tk.Tk()
root.geometry("1280x720+80+50")

# the toolbar
toolBar = tk.Frame(root, bg="blue")
toolBar.pack(anchor="nw")
# buttons
button_2 = tk.Button(toolBar, text="move", command=move)
button_2.pack(side="left",)

# main window
allContent = tk.PanedWindow(root, background="red", orient="horizontal", relief="ridge", bd=5, sashrelief="raised")

contentLeft = tk.Frame(allContent)
allContent.add(contentLeft)

contentRight = tk.Frame(allContent)
allContent.add(contentRight)
allContent.pack(fill="both", expand=1)

statusBar  = tk.Label(root, text="Status")
statusBar.pack(anchor="sw") 

allContent.sash_place(0,100,100) # How do I get this to work here?

root.mainloop()

1 个答案:

答案 0 :(得分:4)

allContent.update()放在allContent.sash_place之前。这适用于3.4.2。我从here得到了这个想法,它说使用update_idletasks,它不起作用,只显示没有的代码。