Please can someone help here? The code should automatically transfer changes made in the UserID class (i.e. pressing the Delete button) to the RegisterUser class. So I can program there changes depending on the actions in the UserID class. All functions for this in the UserID class are also executed (I checked by print commands in the terminal). What does not arrive is the transfer to the RegisterUser class. And I don't know why.
Relevant code from RegisterUser class:
import flet as ft
from microservices.user_id import UserID
class RegisterUser(ft.UserControl):
def __init__(self, user_id):
super().__init__()
self.user_id = user_id
self.user_id.on_changed = self.on_changed
def buil(self):
...
return ...
def on_changed(self, variable):
print(f"user_id changed to {variable}")
relevant code from UserID class:
import flet as ft
class UserID(ft.UserControl):
def __init__(self):
super().__init__()
self.on_changed = lambda x: None
self.variable = None
def build(self):
...
self.user_textfield_row = ft.Row(
spacing=10,
controls=[
self.user_textfield,
ft.IconButton(ft.icons.DELETE_OUTLINE,tooltip="delete entry",
icon_color="#567189", icon_size = 30, on_click = self.delete_clicked),
ft.IconButton(ft.icons.CHECK_CIRCLE_OUTLINED, tooltip="submit your ID",
icon_size=30, icon_color ="#567189", on_click=self.on_user_submit)
],
alignment=ft.MainAxisAlignment.CENTER
)
return: ...
def set_variable(self, value):
self.variable = value
print(value)
self.start()
def start(self):
if self.on_changed:
self.on_changed(self.variable)
print(self.on_changed)
def delete_clicked(self, e):
self.date_textfield.value =""
print("Doing something...")
variable = self.user_textfield.value
self.user_textfield.value = ""
self.user_textfield.focus()
self.something = "delete clicked"
self.set_variable(value=self.something)
I've been trying for days and just can't find a solution. Thanks a lot
i also tried to write a callback function. But unfortunately also unsuccessful. The code should automatically transfer a change of the UserID class to the RegisterUser class and imply further changes there.