Skip to content

Commit

Permalink
Slight protocol optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
FeodorFitsner committed May 16, 2022
1 parent dbcaca1 commit 4b70802
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
19 changes: 12 additions & 7 deletions sdk/python/flet/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,18 @@ def default(self, obj):
if isinstance(obj, Message):
return obj.__dict__
elif isinstance(obj, Command):
return {
"i": obj.indent,
"n": obj.name,
"v": obj.values,
"a": obj.attrs,
"c": obj.commands,
}
d = {}
if obj.indent > 0:
d["i"] = obj.indent
if obj.name != None:
d["n"] = obj.name
if obj.values and len(obj.values) > 0:
d["v"] = obj.values
if obj.attrs and len(obj.attrs) > 0:
d["a"] = obj.attrs
if obj.commands and len(obj.commands) > 0:
d["c"] = obj.commands
return d
elif isinstance(obj, object):
return obj.__dict__
return json.JSONEncoder.default(self, obj)
Expand Down
4 changes: 2 additions & 2 deletions sdk/python/playground/counter.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ def on_click(e):


flet.app(
name="test1",
name="test2",
port=8550,
target=main,
view=flet.WEB_BROWSER,
# assets_dir="assets"
assets_dir="C:\\Projects\\flet-dev\\flet\\client\\build\\web",
# assets_dir="C:\\Projects\\flet-dev\\flet\\client\\build\\web",
)
6 changes: 1 addition & 5 deletions sdk/python/playground/dialog-test.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import logging
from ctypes import alignment
from datetime import datetime
from time import sleep
from tkinter import Button

import flet
from flet import Page, TextButton, alignment, border, border_radius, colors, padding
from flet import Page, TextButton
from flet.alert_dialog import AlertDialog
from flet.container import Container
from flet.elevated_button import ElevatedButton
from flet.text import Text

Expand Down
7 changes: 3 additions & 4 deletions sdk/python/playground/textfield-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@ def main(page: Page):
page.theme_mode = "light"
page.padding = padding.all(20)

prgb = ProgressBar(visible=False)
page.splash = ProgressBar(visible=False)

def chat_submit(e):
print(f"Submit FieldText: {e.control.value}")
e.control.value = ""
form.disabled = True
prgb.visible = True
page.splash.visible = True
page.update()
sleep(2)
form.disabled = False
prgb.visible = False
page.splash.visible = False
page.update()

chat_input = TextField(
Expand All @@ -59,7 +59,6 @@ def chat_submit(e):

form = Column(
[
prgb,
Text("Outlined TextField", style="headlineMedium"),
TextField(),
Text(
Expand Down

0 comments on commit 4b70802

Please sign in to comment.