-
Duplicate Check
Describe the bugwhen I set 'self.page.dialog = self.success', env though success.open is false,it will show a alertdialog. Code sampleCode[Paste your code here]
class success_alert(ft.AlertDialog):
def __init__(self,page):
super().__init__()
self.modal = True
self.page = page
self.title = ft.Text("操作成功")
self.actions = [
ft.TextButton("确定", on_click=self.close_dlg),
ft.TextButton("取消", on_click=self.close_dlg),
]
self.actions_alignment = ft.MainAxisAlignment.END
def close_dlg(self,e):
self.open = False
self.page.update()
class function_container(ft.Container):
def __init__(self,page):
super().__init__()
self.add_user_alert = add_user_Alert(page)
self.content = ft.Row(
alignment=ft.MainAxisAlignment.CENTER,
spacing=25,
controls=[
ft.ElevatedButton("添加用户",on_click=self.add_user ),
ft.ElevatedButton("返回登录界面", ),
ft.ElevatedButton("备份", ),
]
)
def add_user(self,e):
self.page.dialog = self.add_user_alert
self.add_user_alert.open = True
self.page.update()
class add_user_Alert(ft.AlertDialog):
def __init__(self,page):
super().__init__()
self.modal = True
self.success = success_alert(page)
self.title = ft.Text("请输入待添加人员的消息")
self.id = ft.TextField(hint_text="请输入账号", autofocus=True)
self.name = ft.TextField(hint_text="请输入姓名", autofocus=True)
self.password = ft.TextField(hint_text="请输入密码", autofocus=True)
self.admin = ft.TextField(hint_text="请输入身份,1为普通,0为管理员", autofocus=True)
self.content =(ft.Container(ft.Column(controls=[self.id,self.name, self.password, self.admin])))
self.actions = [
ft.TextButton("确定", on_click=self.certain_dlg),
ft.TextButton("取消", on_click=self.close_dlg),
]
def close_dlg(self,e):
self.open = False
self.page.update()
def certain_dlg(self,e):
register_sql = f"insert into card values({int(self.id.value)},'{self.name.value}',0,'{self.admin.value}','{self.password.value}') "
root_cursor.execute(register_sql)
root_db.commit()
self.id.value = None
self.name.value = None
self.password.value = None
self.admin.value = None
self.close_dlg(e)
**self.page.dialog = self.success # this point
self.page.update()**
To reproduceimport flet as ft
class table_container(ft.Container): class button_container(ft.Container):
class success_alert(ft.AlertDialog):
class add_user_Alert(ft.AlertDialog): class function_container(ft.Container): class admin_view(ft.View):
def main(page: ft.Page):
ft.app(target=main) Expected behaviorNo response Screenshots / VideosCaptures[Upload media here] Operating SystemWindows Operating system detailswindows11 24h2 Flet version0.10.2 RegressionNo, it isn't SuggestionsNo response LogsLogs[Paste your logs here] Additional detailsNo response |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Please share well formated runnable code to reproduce the issue. |
Beta Was this translation helpful? Give feedback.
I'm sorry to have disturbed you. This bug has disappeared after I updated the latest version of Flet.