# 引入tk
import tkinter as tk
class UserLogin(object):
""" 初始化窗口 """
def __init__(self, master=None):
self.root = master
self.root.geometry("250x220+125+110") # 窗体大小,注意:之间的间隔是“x”而不是“*”,后面的+是用来做居中显示
self.username = StringVar() # 用户名字段
self.password = StringVar() # 密码字段
self.create_page() # 调用函数
def create_page(self):
self.page = Frame(self.root) # 创建一个新页面
self.page.pack() # 显示
root = tk.Tk()
# 获取窗口大小
# print(root.winfo_screenwidth(), root.winfo_screenheight()) # 电脑屏幕大小
# print(root.winfo_reqwidth(), root.winfo_reqheight()) # 创建改程序的窗口大小
root.title('这是定义的显示在左上角的名称') # 程序名称
UserLogin(root)
root.mainloop() # 进入循环队列
# 引入tk
import tkinter as tk
class UserLogin(objec