Hello,
I am loading some html into webview. It contains some javascript, which will select some text in a textarea tag and change the window.title. I have a listener for the title-changed event, where I am trying to get hold of the text selected by javascript. This is working as expected on windows. On linux, the HasSelection is returning true, but the GetSelectedSource is returning an empty string. Which one is the expected behaviour?
By the way, this is on wxpython-3.0.1.
Here is the code for you to test.
import wx
import wx.html2
class MyApp(wx.Frame):
def init(self, title):
wx.Frame.init(self, None, title=title, size=(600, 400))
vbox = wx.BoxSizer(wx.HORIZONTAL)
self.webview = wx.html2.WebView.New(self)
self.webview.Bind(wx.html2.EVT_WEBVIEW_TITLE_CHANGED, self.title_changed)
self.webview.ClearHistory()
vbox.Add(self.webview, 1, flag=wx.EXPAND)
self.SetSizer(vbox)
def title_changed(self, evt):
txt = self.webview.GetCurrentTitle()
print('current title = ' + txt)
if self.webview.HasSelection():
src = self.webview.GetSelectedSource()
print('src = ' + str(src))
if name == ‘main’:
html_str = “”"
Some Title
“”"
app = wx.App()
browser = MyApp('Tester')
browser.webview.SetPage(html_str, '')
browser.Maximize()
browser.Show()
app.MainLoop()
``
Thank you.