点击注册按钮后,跳转到注册窗口,但是注册窗口设置的ttkbootstrap样式显示不出来
resiter
from tkinter import *
from tkinter import messagebox
from ttkbootstrap import *
class Resiter:
def __init__(self):
self.roo=Tk()
self.roo.geometry("300x300")
self.roo.title("注册页面")
self.page=Frame(self.roo,width=300,height=400)
self.page.pack()
Label(self.page,text="账号:").place(x=55,y=35)
Entry(self.page).place(x=90,y=30)
Label(self.page,text="密码:").place(x=55,y=100)
Entry(self.page,show="*").place(x=90,y=95)
Label(self.page,text="再次输入:").place(x=30,y=165)
Entry(self.page,show="*").place(x=90,y=160)
Button(self.page,text="注册",bootstyle=SUCCESS,command=self.resiter).place(x=60,y=220)
Button(self.page,text="退出",bootstyle=SUCCESS,command=self.roo.destroy).place(x=200,y=220)
self.roo.mainloop()
def resiter(self):
messagebox.showinfo(title="",message="注册成功")
self.roo.destroy()
```python
LoginPage
from tkinter import *
from tkinter import messagebox
from db import db
from Mainpage import MainPage
from resiter import *
from ttkbootstrap import *
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, text="账号:").place(x=55,y=29)
Entry(self.page, textvariable=self.username).place(x=85,y=25)
Label(self.page, text="密码:").place(x=55,y=69)
Entry(self.page, textvariable=self.password, show="*").place(x=85,y=65)
Button(self.page, text="登录", command=self.login).place(x=60,y=119)
Button(self.page, text="注册", command=self.resiter).place(x=190,y=119)
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)
def resiter(self):
Resiter()
if __name__ == '__main__':
root =Tk()
LoginPage(master=root)
root.mainloop()