Skip to content
Discussion options

You must be logged in to vote
import flet as ft
from typing import Optional,Callable

@ft.control
class ceshi(ft.Container):
    expand :bool | int | None=True
    bgcolor:ft.Colors=ft.Colors.BLUE_100

    click_callback: Optional[Callable] = None



    def init(self):
        
        self._click_callback=self.click_callback
        self.click_callback=None

        self.on_click=self._on_click




    def _on_click(self,e):
        print(e)
        if self._click_callback is not None:
            self._click_callback(e)

if __name__ == "__main__":
    def main(page:ft.Page):

        a=ceshi(
        click_callback=lambda e :print(f"click_callback====:{e}")
        )

        page.add(
            a
        )

    …

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@Qye-Leisure
Comment options

Comment options

You must be logged in to vote
2 replies
@Qye-Leisure
Comment options

@Qye-Leisure
Comment options

Answer selected by Qye-Leisure
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
help wanted Extra attention is needed
1 participant