[Python] Create custom control forms in flet

Discussão em 'Python' iniciado por Stack, Junho 8, 2025.

  1. Stack

    Stack Membro Participativo

    hello guys : my task is to create a custom control forms using classes, i have watched several tutorials and some of them use old flet versions, therefore their code does not work in the current version, so i have implemented following style :

    import flet as ft
    from flet import *
    class GreetingControl(ft.Text,ft.ElevatedButton):
    def __init__(self,text,button_value):
    ft.Text().__init__(text)
    ft.ElevatedButton().__init__(text =button_value)
    self.Row =ft.Row(controls=[ft.Text,ft.ElevatedButton])

    def main(page:ft.Page):
    page.title ="OOP in flet"
    page.add(GreetingControl(text ="hello",button_value="execute"),
    GreetingControl(text="hello",button_value="canceal"))




    ft.app(target=main)


    my goal is following : [​IMG]

    but it generates error :

    AttributeError: 'GreetingControl' object has no attribute '_Control__uid'. Did you mean: '_Control__page'?


    i am new and studying one by one , so please let me know how to implement multiple inheritance in flet?

    Continue reading...

Compartilhe esta Página