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

2024-04-24 03:38:19 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个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()

Tags: textmovetkinterplacebuttonrootframepack
1条回答
网友
1楼 · 发布于 2024-04-24 03:38:19

allContent.update()放在allContent.sash_place之前。这对我3.4.2来说很有用。我是从here得到这个想法的,它说使用update_idletask,但它不起作用,它只显示没有这两种方法的代码。在

相关问题 更多 >