【发布时间】:2020-12-14 17:06:45
【问题描述】:
我试图获得一个 tkinter gui,让用户登录我对 tkinter 真的很陌生。我制作了一个框架,当我使用网格将另一个框架小部件放在框架内时,它基于根而不是我认为正在发生的 inner_frame。在代码中,我制作了一个灰色框进行演示,但我不明白为什么它位于蓝色框下方而不是“登录”文本下方的黄色框内。感谢您的帮助。
from tkinter import *
root = Tk()
root.title("sighn in test")
#colors
background = "#273E47"
accent = "#d8973c"
red = "#bb4430"
white = "#edf2f4"
#this creates and places the background frame
main_buttons_frame = Frame(root, height = 500, width = 400, bg = background).grid(row = 0, column = 0)
#this creates and places the inner frame
inner_frame = Frame(main_buttons_frame, height = 450, width = 300, bg = accent).grid(row = 0, column = 0)
#this creates and places the "sighn in text"
top_text = Label(inner_frame, text = "sign in", font = ("helvitica", 30, "bold"), bg = accent, fg =
background).grid(row = 0, column = 0)
#this is a test to demonstrate
test_frame = Frame(inner_frame, bg = "grey", height = 100, width = 100).grid(row = 1, column = 0)
root.mainloop()
【问题讨论】:
标签: python user-interface tkinter grid frames