Ability to save drawings

- Added `toolbox` to the common methods.
- `toolbox.save_drawings_under` can save drawings under a specific `topbar` widget. eg `chart.toolbox.save_drawings_under(chart.topbar[’symbol’]`)
- `toolbox.load_drawings` will load and display drawings stored under the tag/string given.
- `toolbox.export_drawings` will export all currently saved drawings to the given file path.
- `toolbox.import_drawings` will import the drawings stored at the given file path.

Fixes/Enhancements:
- `update` methods are no longer case sensitive.
- HorizontalLines no longer throw cyclic structure errors in the web console.
- `API` methods can now be normal methods or coroutines.
This commit is contained in:
louisnw
2023-07-20 21:52:17 +01:00
parent b2ceae59b7
commit 527130e618
10 changed files with 166 additions and 55 deletions

View File

@ -87,13 +87,17 @@ class Chart(LWC):
self._exit.clear()
return
elif not self._emit_q.empty():
key, chart_id, arg = self._emit_q.get()
name, chart_id, arg = self._emit_q.get()
self._api.chart = self._charts[chart_id]
if widget := self._api.chart.topbar._widget_with_method(key):
if name == 'save_drawings':
self._api.chart.toolbox._save_drawings(arg)
continue
method = getattr(self._api, name)
if hasattr(self._api.chart, 'topbar') and (widget := self._api.chart.topbar._widget_with_method(name)):
widget.value = arg
await getattr(self._api, key)()
await method() if asyncio.iscoroutinefunction(method) else method()
else:
await getattr(self._api, key)(*arg.split(';;;'))
await method(*arg.split(';;;')) if asyncio.iscoroutinefunction(method) else method(arg)
continue
value = self.polygon._q.get()
func, args = value[0], value[1:]