Skip to content

Commit

Permalink
Fix page size parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
FeodorFitsner committed May 6, 2022
1 parent 7002390 commit 8b632e1
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 5 deletions.
4 changes: 2 additions & 2 deletions sdk/python/flet/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,15 +439,15 @@ def scroll(self, value: ScrollMode):
def window_width(self):
w = self._get_attr("winWidth")
if w != None and w != "":
return int(w)
return float(w)
return 0

# window_height
@property
def window_height(self):
h = self._get_attr("winHeight")
if h != None and h != "":
return int(h)
return float(h)
return 0

# on_close
Expand Down
1 change: 1 addition & 0 deletions sdk/python/playground/buttons.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
Text,
TextButton,
icons,
theme,
)

logging.basicConfig(level=logging.DEBUG)
Expand Down
12 changes: 9 additions & 3 deletions sdk/python/playground/simple2.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@

def main(page):
page.title = "TextField Examples"
page.theme_mode = "light"
page.add(Text("Hello, world!"))
page.update()
page.theme_mode = "dark"
page.vertical_alignment = "center"
page.horizontal_alignment = "center"
page.add(Text("Hello, world!", expand=True))

def page_resize(e):
print("New page size:", page.window_width, page.window_height)

page.on_resize = page_resize


flet.app(name="test1", port=8550, target=main, view=flet.FLET_APP)
22 changes: 22 additions & 0 deletions sdk/python/playground/splash-test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from time import sleep

import flet
from flet import ElevatedButton, ProgressBar


def main(page):
def button_click(e):
page.splash = ProgressBar()
btn.disabled = True
page.update()
sleep(3)
page.splash = None
btn.disabled = False
page.update()

btn = ElevatedButton("Do some lengthy task!", on_click=button_click)

page.add(btn)


flet.app(target=main)

0 comments on commit 8b632e1

Please sign in to comment.