-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
74 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,83 @@ | ||
import time | ||
import invent | ||
|
||
|
||
class Builder: | ||
def get_widgets(self): | ||
def __init__(self): | ||
self._app = invent.ui.App( | ||
name="Untitled Cool App", | ||
content=[ | ||
invent.ui.Page( | ||
name="Page 1", | ||
content=[] | ||
) | ||
] | ||
) | ||
|
||
|
||
@property | ||
def app(self): | ||
return self._app | ||
|
||
def get_available_widgets(self): | ||
""" | ||
Return a dictionary of available widgets in the form: | ||
{ | ||
"Button": { | ||
"properties": { | ||
"channel": { | ||
"property_type": "TextProperty", | ||
"description": "The channel[s] to which the widget broadcasts.", | ||
"required": false, | ||
"default_value": null, | ||
"min_length": null, | ||
"max_length": null | ||
}, | ||
"id": { | ||
"property_type": "TextProperty", | ||
"description": "The id of the widget instance in the DOM.", | ||
"required": false, | ||
"default_value": null, | ||
"min_length": null, | ||
"max_length": null | ||
}, | ||
}, | ||
"message_subjects": [ | ||
"click", "hold", "double-click" | ||
], | ||
"preview" : "<button>Button</button>" | ||
}, | ||
... | ||
} | ||
""" | ||
|
||
... | ||
|
||
def get_app(self): | ||
"""Might need this to return the app as a plain ol' dictionary.""" | ||
|
||
return self._app.as_dict() | ||
|
||
def get_page(self, page_id_or_index): | ||
... | ||
|
||
def add_page(self): | ||
... | ||
|
||
def do_something(self, obj): | ||
"""Do something""" | ||
def update_page(self, page, **properties_to_update): | ||
... | ||
|
||
from pyscript import display | ||
display(f"builder.do_something: {time.gmtime()}") | ||
display(str(obj)) | ||
display(str(type(obj))) | ||
display(str(dir(obj))) | ||
def delete_page(self, page): | ||
... | ||
|
||
if hasattr(obj, 'a'): | ||
display(str(obj.a)) | ||
def add_widget_to_page(self, page, widget_definition, parent=None): | ||
# Create widget instance from definition. | ||
... | ||
|
||
# Add it to the parent widget (if no parent). | ||
... | ||
|
||
def delete_widget_from_page(self, widget_ref): | ||
... |