gpt4 book ai didi

python - Tkinter 按钮在我的 Mac 上不显示文本,尽管代码在其他计算机上有效

转载 作者:太空宇宙 更新时间:2023-11-04 04:28:43 38 4
gpt4 key购买 nike

我有一个功能代码,除非我单击并按住按钮,否则不会在按钮上显示文本。释放按钮时,文本再次变为空白。我已经尝试在其他论坛上解决这个问题,

please note: THERE IS NOTHING WRONG WITH THE CODE ITSELF.

我的笔记本电脑运行代码的方式存在某种问题。我已经尝试重新安装 python3.7 以及 tcl-tk。我真的不知道还能做什么。

最佳答案

这是添加此行 from tkinter import ttk 的解决方案。

并且比起使用 ttk. 任何你想使用 Button、Label、Entry 等的地方:

ttk.Button(text="Login", width="30", command = login).pack()

这是代码,您可以尝试一下。

def main_screen():
from tkinter import ttk

global screen
screen = Tk()

screen.geometry("500x500")
screen.title("4rManager")

Label(text="Login/Register", font=("Calibri", 13)).pack()
ttk.Label(text="").pack()
ttk.Button(text="Login").pack()
ttk.Label(text="").pack()
ttk.Button(text="Register").pack()

screen.mainloop()

main_screen()

希望我有所帮助。

关于python - Tkinter 按钮在我的 Mac 上不显示文本,尽管代码在其他计算机上有效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53052576/

38 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com