Replies: 4 comments 2 replies
-
What is meant by 'externally'? |
Beta Was this translation helpful? Give feedback.
-
I have the same question. What I do is to put that "bigger application" inside Flet import flet as ft
class GreeterControl(ft.UserControl):
def __init__(self):
super().__init__()
self.button1 = ft.ElevatedButton(text="Start Test", on_click=self.start_clicked, disabled=False)
self.button2 = ft.OutlinedButton(text="Stop Test", on_click=self.stop_clicked, disabled=True)
def build(self):
a_column = ft.Column(controls=[ft.Text(value="(Title) Test (Title)", italic=False, selectable=False,
style=ft.TextThemeStyle.DISPLAY_MEDIUM), ])
a_column.controls.append(ft.Text(value="Some text here..."))
a_column.controls.append(ft.Text(value="More text here..."))
a_column.controls.append(ft.Row(controls=[self.button1, self.button2]), )
return a_column
def start_clicked(self, e):
dummy_def("Start")
print("Running a test...")
self.button1.disabled = True
self.button2.disabled = False
self.update()
def stop_clicked(self, e):
dummy_def("Stop")
print("Running a test...")
self.button1.disabled = False
self.button2.disabled = True
self.update()
def main(page: ft.page):
page.title = "Flet example"
page.scroll = "always"
page.window_width = 999
page.window_height = 666
page.bgcolor = "#FFFFF8E1"
page.add(
ft.Column(
[
GreeterControl(),
ft.Text(value="Whatever you want to put here"),
ft.Text(value="Even more things here")
],
alignment=ft.alignment.center
)
)
def dummy_def(in_msg: str = ""):
print("this is \"dummy_def(\"{0}\")\" outside the Class, meaning \"{0}\" button is clicked.".format(in_msg))
if __name__ == '__main__':
ft.app(target=main) |
Beta Was this translation helpful? Give feedback.
-
you would either have to start a loop before than listens for some message or bind the add row function to a button or other action that is triggered in the ui |
Beta Was this translation helpful? Give feedback.
-
it would be easier to help if you gave an example of where and why your trying to call a function that isn't working with the current setup |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Question
Is there anyway I can add rows or call functions externally? I tried finding something similar in the docs but no luck so far.
Code sample
Error message
No response
------------------------------------------------------
Beta Was this translation helpful? Give feedback.
All reactions