英文:
tkinter, wm_state('zoomed') does not work on my app
问题
I'm running root.wm_state('zoomed')
on my GUI app but it's just slightly moving my Window towards the bottom right.
我在我的GUI应用程序上运行root.wm_state('zoomed')
,但它只是轻微地将我的窗口向右下方移动。
I have no clue why it's happening. Can anyone help?
我不知道为什么会发生这种情况。有人能帮忙吗?
Minimal reproducible example:
最小可重现示例:
import customtkinter as ctk
class MainApp(ctk.CTk):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.title("Test Window")
self.state('zoomed')
mapp = MainApp()
mapp.mainloop()
英文:
I'm running root.wm_state('zoomed')
on my GUI app but it's just slightly moving my Window towards the bottom right.
I have no clue why it's happening. Can anyone help?
Minimal reproducible example:
import customtkinter as ctk
class MainApp(ctk.CTk):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.title("Test Window")
self.state('zoomed')
mapp = MainApp()
mapp.mainloop()
答案1
得分: 0
As customtkinter
覆盖了 .mainloop()
并在覆盖的 .mainloop()
中调用 .deiconify()
,因此在 __init__()
中的 self.wm_state('zoomed')
的效果也被覆盖。
您可以通过将该行更改为 self.after(1, self.wm_state, 'zoomed')
来稍微延迟调用 self.wm_state('zoomed')
,以便它在 .deiconify()
之后调用。
import customtkinter as ctk
class MainApp(ctk.CTk):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.title("Test Window")
self.after(1, self.wm_state, 'zoomed')
mapp = MainApp()
mapp.mainloop()
Note: The code portion is not translated, as requested.
英文:
As customtkinter
overrides .mainloop()
and call .deiconify()
inside the override .mainloop()
if it is Windows platform, so the effect of self.wm_state('zoomed')
inside __init__()
is override as well.
You can delay the calling of self.wm_state('zoomed')
a bit by changing that line to self.after(1, self.wm_state, 'zoomed')
so it is called after the .deiconify()
.
import customtkinter as ctk
class MainApp(ctk.CTk):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.title("Test Window")
self.after(1, self.wm_state, 'zoomed')
mapp = MainApp()
mapp.mainloop()
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论