- Updated chart.exit() to destroy objects and terminate the webview process. - Fixed WxChart not expanding correctly and removed its width and height parameters. - Fixed KeyboardInterrupt error message when using show(block=True).
28 lines
796 B
Python
28 lines
796 B
Python
from lightweight_charts.js import LWC
|
|
try:
|
|
import wx.html2
|
|
except ImportError:
|
|
pass
|
|
|
|
|
|
class WxChart(LWC):
|
|
def __init__(self, parent, volume_enabled=True):
|
|
super().__init__(volume_enabled)
|
|
self.webview = wx.html2.WebView.New(parent)
|
|
|
|
self.webview.Bind(wx.html2.EVT_WEBVIEW_LOADED, self._on_js_load)
|
|
self.webview.SetPage(self._html, '')
|
|
|
|
self.second_load = False
|
|
|
|
def run_script(self, script): self.webview.RunScript(script)
|
|
|
|
def _on_js_load(self, e: wx.html2.WebViewEvent):
|
|
if not self.second_load:
|
|
self.second_load = True
|
|
return
|
|
self.loaded = True
|
|
for func, args, kwargs in self.js_queue:
|
|
getattr(super(), func)(*args, **kwargs)
|
|
|
|
def get_webview(self): return self.webview |