Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clickable Container #59

Merged
merged 1 commit into from
Jul 8, 2022
Merged

Clickable Container #59

merged 1 commit into from
Jul 8, 2022

Conversation

FeodorFitsner
Copy link
Contributor

@FeodorFitsner FeodorFitsner commented Jul 8, 2022

Two new properties added:

  • Container.on_click
  • Container.ink

Example code:

import flet
from flet import Container, Page, Row, Text, alignment, colors

def main(page: Page):
    page.title = "Containers - clickable and not"
    page.horizontal_alignment = "center"
    page.vertical_alignment = "center"

    page.add(
        Row(
            [
                Container(
                    content=Text("Non clickable"),
                    margin=10,
                    padding=10,
                    alignment=alignment.center,
                    bgcolor=colors.AMBER,
                    width=150,
                    height=150,
                    border_radius=10,
                ),
                Container(
                    content=Text("Clickable without Ink"),
                    margin=10,
                    padding=10,
                    alignment=alignment.center,
                    bgcolor=colors.GREEN_200,
                    width=150,
                    height=150,
                    border_radius=10,
                    on_click=lambda e: print("Clickable without Ink clicked!"),
                ),
                Container(
                    content=Text("Clickable with Ink"),
                    margin=10,
                    padding=10,
                    alignment=alignment.center,
                    bgcolor=colors.CYAN_200,
                    width=150,
                    height=150,
                    border_radius=10,
                    ink=True,
                    on_click=lambda e: print("Clickable with Ink clicked!"),
                ),
                Container(
                    content=Text("Clickable transparent with Ink"),
                    margin=10,
                    padding=10,
                    alignment=alignment.center,
                    width=150,
                    height=150,
                    border_radius=10,
                    ink=True,
                    on_click=lambda e: print("Clickable transparent with Ink clicked!"),
                ),
            ],
            alignment="center",
        ),
    )

flet.app(target=main)

Result:

2022-07-08_15h35_18

Two new properties added:
- Container.on_click
- Container.ink
@FeodorFitsner FeodorFitsner merged commit b3763a6 into main Jul 8, 2022
@FeodorFitsner FeodorFitsner deleted the clickable-container branch July 8, 2022 21:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant