要解决按钮在框架中不显示的问题,你可以尝试以下方法:
Frame
小部件作为按钮的父容器。import tkinter as tk
root = tk.Tk()
frame = tk.Frame(root)
frame.pack()
button = tk.Button(frame, text="按钮")
button.pack()
root.mainloop()
button = tk.Button(frame, text="按钮", width=10, height=2)
pack()
或grid()
方法来调整小部件的显示位置。frame.pack() # 或 frame.grid(row=0, column=0)
button.pack() # 或 button.grid(row=0, column=0)
button = tk.Button(frame, text="按钮", bg="white", fg="black")
通过使用上述方法之一,你应该能够解决按钮在框架中不显示的问题。
上一篇:按钮在控制器中不起作用的手势
下一篇:按钮在链接组件上方