Skip to content

Commit

Permalink
Fixes for Gallery (#351)
Browse files Browse the repository at this point in the history
* Icon, Column -> constrained control

* Do not use input() to block the script on Windows

Fix #314

* Disable websocket logging completely

Fix #321
  • Loading branch information
FeodorFitsner authored Sep 18, 2022
1 parent 409acf9 commit 831342c
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package/lib/src/controls/icon.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class IconControl extends StatelessWidget {
var color = HexColor.fromString(
Theme.of(context), control.attrString("color", "")!);

return baseControl(
return constrainedControl(
Icon(
getMaterialIcon(name),
size: size,
Expand Down
19 changes: 19 additions & 0 deletions sdk/python/flet/column.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
ScrollMode,
)
from flet.ref import Ref
from flet.types import AnimationValue, OffsetValue, RotateValue, ScaleValue


class Column(ConstrainedControl):
Expand All @@ -26,6 +27,15 @@ def __init__(
bottom: OptionalNumber = None,
expand: Union[None, bool, int] = None,
opacity: OptionalNumber = None,
rotate: RotateValue = None,
scale: ScaleValue = None,
offset: OffsetValue = None,
animate_opacity: AnimationValue = None,
animate_size: AnimationValue = None,
animate_position: AnimationValue = None,
animate_rotation: AnimationValue = None,
animate_scale: AnimationValue = None,
animate_offset: AnimationValue = None,
visible: Optional[bool] = None,
disabled: Optional[bool] = None,
data: Any = None,
Expand All @@ -52,6 +62,15 @@ def __init__(
bottom=bottom,
expand=expand,
opacity=opacity,
rotate=rotate,
scale=scale,
offset=offset,
animate_opacity=animate_opacity,
animate_size=animate_size,
animate_position=animate_position,
animate_rotation=animate_rotation,
animate_scale=animate_scale,
animate_offset=animate_offset,
visible=visible,
disabled=disabled,
data=data,
Expand Down
9 changes: 4 additions & 5 deletions sdk/python/flet/flet.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,10 @@ def exit_gracefully(signum, frame):
if view == WEB_BROWSER and url_prefix == None:
open_in_browser(conn.page_url)
try:
if is_windows():
input()
else:
terminate.wait()
except (Exception) as e:
while True:
if terminate.wait(1):
break
except KeyboardInterrupt:
pass

conn.close()
Expand Down
26 changes: 23 additions & 3 deletions sdk/python/flet/icon.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,28 @@

from beartype import beartype

from flet.control import Control, OptionalNumber
from flet.constrained_control import ConstrainedControl
from flet.control import OptionalNumber
from flet.ref import Ref
from flet.types import AnimationValue, OffsetValue, RotateValue, ScaleValue


class Icon(Control):
class Icon(ConstrainedControl):
def __init__(
self,
name: Optional[str] = None,
ref: Optional[Ref] = None,
expand: Union[None, bool, int] = None,
opacity: OptionalNumber = None,
rotate: RotateValue = None,
scale: ScaleValue = None,
offset: OffsetValue = None,
animate_opacity: AnimationValue = None,
animate_size: AnimationValue = None,
animate_position: AnimationValue = None,
animate_rotation: AnimationValue = None,
animate_scale: AnimationValue = None,
animate_offset: AnimationValue = None,
tooltip: Optional[str] = None,
visible: Optional[bool] = None,
disabled: Optional[bool] = None,
Expand All @@ -24,11 +35,20 @@ def __init__(
size: OptionalNumber = None,
):

Control.__init__(
ConstrainedControl.__init__(
self,
ref=ref,
expand=expand,
opacity=opacity,
rotate=rotate,
scale=scale,
offset=offset,
animate_opacity=animate_opacity,
animate_size=animate_size,
animate_position=animate_position,
animate_rotation=animate_rotation,
animate_scale=animate_scale,
animate_offset=animate_offset,
tooltip=tooltip,
visible=visible,
disabled=disabled,
Expand Down
1 change: 0 additions & 1 deletion sdk/python/flet/list_tile.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
class ListTile(ConstrainedControl):
def __init__(
self,
text: Optional[str] = None,
ref: Optional[Ref] = None,
width: OptionalNumber = None,
height: OptionalNumber = None,
Expand Down
4 changes: 4 additions & 0 deletions sdk/python/flet/reconnecting_websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ def __init__(self, url) -> None:
if is_localhost_url(url)
else _REMOTE_CONNECT_TIMEOUT_SEC
)
# disable websocket logging completely
# https://github.com/websocket-client/websocket-client/blob/master/websocket/_logging.py#L22-L51
ws_logger = logging.getLogger("websocket")
ws_logger.setLevel(logging.FATAL)

@property
def on_connect(self, handler):
Expand Down

0 comments on commit 831342c

Please sign in to comment.