```python
from tkinter import *
from tkinter import messagebox
from ttkbootstrap import *
from db import db
from Mainpage import MainPage
class LoginPage:
def __init__(self,master):
self.root=master
self.root.geometry("300x180")
self.root.title("登录页")
self.username = StringVar()
self.password = StringVar()
self.page = Frame(self.root,width=700,height=700)
self.page.pack()
Label(self.page).grid(row=0, column=0)
Label(self.page, text="账号:").grid(row=1, column=1)
Entry(self.page, textvariable=self.username).grid(row=1, column=2)
Label(self.page, text="密码:").grid(row=2, column=1, pady=20)
Entry(self.page, textvariable=self.password, show="*").grid(row=2, column=2)
Button(self.page, text="登录", command=self.page).place(x=10,y=100)
Button(self.page, text="退出", command=self.page.quit).place(x=40,y=100)
def login(self):
name = self.username.get()
pas = self.password.get()
flag, message = db.check_login(name, pas)
if flag:
messagebox.showinfo(title="成功", message=message)
self.page.destroy()
MainPage(self.root)
else:
messagebox.showinfo(title="警告", message=message)
if __name__ == '__main__':
root = Tk()
LoginPage(master=root)
root.mainloop()
按钮用绝对布局为什么显示不完整
![img](https://img-mid.csdnimg.cn/release/static/image/mid/ask/0914897dca7a40948ea966cc6018605e.png "#left")