主函数main.py
from tkinter import *
from LoginPage import *
root = Tk()
root.title('小程序')
LoginPage(root)
root.mainloop()
登陆界面函数LoginPage.py
from tkinter import *
from tkinter.messagebox import *
from MainPage import *
class LoginPage(object):
def __init__(self, master=None):
self.root = master #定义内部变量root
self.root.geometry('%dx%d' % (300, 180)) #设置窗口大小
self.username = StringVar()
self.password = StringVar()
self.createPage()
def createPage(self):
self.page = Frame(self.root) #创建Frame
self.page.pack()
Label(self.page).grid(row=0, stick=W)
Label(self.page, text = '账户: ').grid(row=1, stick=W, pady=10)
Entry(self.page, textvariable=self.username).grid(row=1, column=1, st