Skip to content

Commit

Permalink
Merge pull request #2237 from bosonogi/webview-demo-with-fs-handler
Browse files Browse the repository at this point in the history
Include usage of `wxMemoryFSHandler` in webview demo
  • Loading branch information
swt2c authored Nov 15, 2024
2 parents 31c9964 + fada0e8 commit 8908dd6
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion demo/HTML2_WebView.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ def __init__(self, parent, log, frame=None):
# Create the WebView
self.wv = webview.WebView.New(self, backend=backend)

# Register a virtual FS handler for the "memory" scheme
memory = wx.MemoryFSHandler()
wx.FileSystem.AddHandler(memory)
memory.AddFileWithMimeType('hello', 'Hello!', 'text/plain')
self.wv.RegisterHandler(wx.html2.WebViewFSHandler('memory'))

self.Bind(webview.EVT_WEBVIEW_NAVIGATING, self.OnWebViewNavigating, self.wv)
self.Bind(webview.EVT_WEBVIEW_LOADED, self.OnWebViewLoaded, self.wv)

Expand Down Expand Up @@ -79,7 +85,8 @@ def __init__(self, parent, log, frame=None):
self, -1, "", style=wx.CB_DROPDOWN|wx.TE_PROCESS_ENTER)
self.location.AppendItems(['http://wxPython.org',
'http://wxwidgets.org',
'http://google.com'])
'http://google.com',
'memory:hello'])
self.Bind(wx.EVT_COMBOBOX, self.OnLocationSelect, self.location)
self.location.Bind(wx.EVT_TEXT_ENTER, self.OnLocationEnter)
btnSizer.Add(self.location, 1, wx.EXPAND|wx.ALL, 2)
Expand Down

0 comments on commit 8908dd6

Please sign in to comment.