Skip to content

Commit

Permalink
Add more simplified Ref control
Browse files Browse the repository at this point in the history
  • Loading branch information
Daxexs committed Mar 27, 2024
1 parent ef228ee commit 907380e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/flet_easy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
AddPagesy,
Keyboardsy,
Pagesy,
Ref,
Resizesy,
ResponsiveControlsy,
Viewsy,
Expand Down
13 changes: 12 additions & 1 deletion src/flet_easy/inheritance.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from dataclasses import dataclass
from functools import wraps
from inspect import iscoroutinefunction
from typing import Any, Callable, List
from typing import Any, Callable, List, TypeVar

from flet import (
AppBar,
Expand All @@ -18,6 +18,7 @@
OptionalNumber,
PaddingValue,
Page,
Ref,
ScrollMode,
Text,
alignment,
Expand All @@ -26,6 +27,8 @@
from flet_core import Control
from flet_core.session_storage import SessionStorage

T = TypeVar("T")


class SessionStorageEdit(SessionStorage):
def __init__(self, page):
Expand Down Expand Up @@ -455,3 +458,11 @@ async def __handle_canvas_resize(self, e):

if self.show_resize_terminal:
print(f"{e.width} x {e.height}")


class Ref(Ref[T]):
"""Get the reference of the control used by flet, it is linked to the created component. It is similar to flet, but more reduced by getting the value of the control with (c)."""

@property
def c(self) -> T:
return super().current

0 comments on commit 907380e

Please sign in to comment.