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

Can't import #3

Open
aesashi opened this issue Nov 9, 2024 · 1 comment
Open

Can't import #3

aesashi opened this issue Nov 9, 2024 · 1 comment

Comments

@aesashi
Copy link

aesashi commented Nov 9, 2024

No description provided.

@hahelui
Copy link

hahelui commented Feb 14, 2025

Me too. Here is my code, the toast example from the README:

import flet as ft
from fletmint import *


def main(page: ft.Page):
    page.fonts = {
        "JetBrainsMono": "C:\\path\\to\\font\\JetBrainsMono-Regular.ttf",
        "SourceCodePro": "/path/to/font/SourceCodePro.ttf",
    }
    page.theme_mode = ft.ThemeMode.DARK
    toast_manager = Toaster(page, expand=False, position=ToastPosition.TOP_RIGHT)

    def show_action(e):
        toast = Toast(
            content=ft.Row(
                [
                    ft.Row(
                        [
                            ft.Text("This is an custom action"),
                        ]
                    ),
                    ft.TextButton(
                        content=ft.Text(
                            "close",
                            style=ft.TextStyle(
                                size=13,
                                weight=ft.FontWeight.W_200,
                            ),
                        ),
                        style=ft.ButtonStyle(
                            shape=ft.ContinuousRectangleBorder(radius=8),
                            color=ft.colors.WHITE,
                            bgcolor=ft.colors.BLACK,
                        ),
                        on_click=lambda e: toast_manager.remove_toast(toast),
                    ),
                ],
                alignment=ft.MainAxisAlignment.SPACE_BETWEEN,
            )
        )
        toast_manager.show_toast(toast=toast)

    def show_promise(e):
        def long_running_task():
            import time

            time.sleep(5)  # long-running task
            # raise Exception("Something went wrong")
            return "long running task output"

        toast_manager.show_promise_toast(
            long_running_task,
            success_message="Task Completed Successfully",
            error_message="Task Failed",
            descriptive=True,  # shows the function's output as the toast's desctiption
        )

    toast_showcase = ft.Column([
        SecondaryButton(
            label="Action",
            on_click=show_action,
        ),
        SecondaryButton(
            label="Info",
            on_click=lambda e: toast_manager.show_toast(
                toast_type=ToastType.INFO,
                text="This is a info message",
            ),
        ),
        SecondaryButton(
            label="Success",
            on_click=lambda e: toast_manager.show_toast(
                toast_type=ToastType.SUCCESS,
                text="This is a success message",
            ),
        ),
        SecondaryButton(
            label="Warning",
            on_click=lambda e: toast_manager.show_toast(
                toast_type=ToastType.WARNING,
                text="This is a warning message",
            ),
        ),
        SecondaryButton(
            label="Error",
            on_click=lambda e: toast_manager.show_toast(
                toast_type=ToastType.ERROR,
                text="This is a error message",
            ),
        ),
        SecondaryButton(
            label="Promise",
            on_click=show_promise,
        ),
        ft.TextButton(
            content=ft.Text(
                "Remove latest toast",
                color="#e57373",
                size=13,
                weight=ft.FontWeight.W_200,
            ),
            style=ft.ButtonStyle(
                shape=ft.ContinuousRectangleBorder(radius=10),
                side=ft.BorderSide(color="#5a3b3b", width=1),
                bgcolor="#2a1c1c",
                color={
                    ft.MaterialState.HOVERED: "#211717",
                    ft.MaterialState.FOCUSED: "#211717",
                    ft.MaterialState.DEFAULT: "#211717",
                },
            ),
            on_click=lambda e: toast_manager.remove_toast(
                toast_manager.toasts[0]
            ),
        ),
    ])
    page.add(toast_showcase)


ft.app(target=main)

The error and the pip list:


(temp-custom-table) temp_custom_table git:master ❯ uv run toast.py                                                                                      ✹ ✭
Traceback (most recent call last):
  File "/home/sda1/Documents/python/temp_custom_table/toast.py", line 2, in <module>
    from fletmint import *
  File "/home/sda1/Documents/python/temp_custom_table/.venv/lib/python3.12/site-packages/fletmint/__init__.py", line 1, in <module>
    from .checkbox import CheckBox
  File "/home/sda1/Documents/python/temp_custom_table/.venv/lib/python3.12/site-packages/fletmint/checkbox.py", line 1, in <module>
    from flet import (
ImportError: cannot import name 'UserControl' from 'flet' (/home/sda1/Documents/python/temp_custom_table/.venv/lib/python3.12/site-packages/flet/__init__.py)
(temp-custom-table) temp_custom_table git:master ❯ uv pip list                                                                                        ⏎ ✹ ✭
Package               Version
--------------------- --------------
anyio                 4.8.0
arrow                 1.3.0
binaryornot           0.4.4
certifi               2025.1.31
chardet               5.2.0
charset-normalizer    3.4.1
click                 8.1.8
cookiecutter          2.6.0
flet                  0.26.0
flet-cli              0.26.0
flet-desktop          0.26.0
fletmint              0.1.6.2
h11                   0.14.0
httpcore              1.0.7
httpx                 0.28.1
idna                  3.10
jinja2                3.1.5
markdown-it-py        3.0.0
markupsafe            3.0.2
mdurl                 0.1.2
oauthlib              3.2.2
packaging             24.2
pip                   25.0.1
pygments              2.19.1
pypng                 0.20220715.0
python-dateutil       2.9.0.post0
python-slugify        8.0.4
pyyaml                6.0.2
qrcode                7.4.2
repath                0.9.0
requests              2.32.3
rich                  13.9.4
six                   1.17.0
sniffio               1.3.1
text-unidecode        1.3
toml                  0.10.2
types-python-dateutil 2.9.0.20241206
typing-extensions     4.12.2
urllib3               2.3.0
watchdog              4.0.2

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

No branches or pull requests

2 participants