Frame(框架)组件是在屏幕上的一个矩形区域。Frame 主要是作为其他组件的框架基础,或为其他组件提供间距填充。
如何使用Frame标签
root=tk.Tk()
root.title('登录界面 v1.0.0') #设置主窗口标题
root.geometry('500x300')#窗口大小
login_frame=tk.Frame(root,width=500,height=300)#宽高一定要设置,默认为0
login_frame.pack()
tk.Label(self.login_frame, image = self.img_png,width=76.8,height=43.2).place(relx=0.45,rely=0.2)
tk.Label(login_frame, text = '账号', bg='lightskyblue', fg='white', font=('Arial', 12), width=5, height=1).place(relx=0.29,rely=0.4)
tk.Label(login_frame, text = '密码', bg='lightskyblue', fg='white', font=('Arial', 12), width=5, height=1).place(relx=0.29,rely=0.5)
tk.Entry(login_frame,width=20,highlightthickness = 1,textvariable=self.username,highlightcolor = 'lightskyblue',relief='groove').place(relx=0.4,rely=0.4 )
tk.Entry(login_frame,show='*',highlightthickness = 1,textvariable=self.password,highlightcolor = 'lightskyblue',relief='groove').place(relx=0.4,rely=0.5)
root.mainloop()
一定要设置宽高
可以参考这位大佬写的。Tkinter组件详解