我对 Tkinter 还很陌生,我正在尝试制作一个登录屏幕。功能是存在的,但是我希望我的画布是 200x300px,但这似乎不起作用。它返回给我一个画布,刚好适合按钮和输入字段。请帮忙!
import tkinter as tk
class Login_Screen:
def __init__(self, master):
self.master = master
self.canvas = tk.Canvas(self.master, width=200, height=300)
self.frame = tk.Frame(self.canvas)
self.input_user_log = tk.Entry(self.frame)
self.button1 = tk.Button(self.frame, text="Log in", width=15, command=self.return_login_info)
self.input_user_log.pack()
self.canvas.pack()
self.button1.pack()
self.frame.pack()
def return_login_info(self):
print(self.input_user_log.get())
root = tk.Tk()
app = Login_Screen(root)
root.mainloop()
一只甜甜圈
相关分类