无法使tinyMCE在wxPython wx.HTML2控件中工作:

时间:2018-12-04 03:10:20

标签: ckeditor tinymce wxpython wx.html2

tinyMCE的演示代码可以在IE / Chrome上的网页上正常运行

<!DOCTYPE html>
<html>
<head>
  <script src='http://cloud.tinymce.com/5-testing/tinymce.min.js'></script>
  <script>
  tinymce.init({
    selector: '#mytextarea'
  });
  </script>
</head>

<body>
<h1>TinyMCE Quick Start Guide</h1>
  <form method="post">
    <textarea id="mytextarea">Hello, World!</textarea>
  </form>
</body>
</html>

但是当尝试加载到wxPython wx.HTML2控件中时,仅加载了文本部分,但编辑器功能不起作用?

wxPython代码

import wx, os
import wx.html2

class MyBrowser(wx.Dialog):
  def __init__(self, *args, **kwds):
    wx.Dialog.__init__(self, *args, **kwds)
    sizer = wx.BoxSizer(wx.VERTICAL)
    self.browser = wx.html2.WebView.New(self)
    sizer.Add(self.browser, 1, wx.EXPAND, 10)
    self.SetSizer(sizer)
    self.SetSize((700, 700))
    self.Bind(wx.html2.EVT_WEBVIEW_NAVIGATING, self.OnNavigate,self.browser)
    self.Bind(wx.html2.EVT_WEBVIEW_LOADED, self.OWVLoaded,self.browser)

  CATCH_STRING = "catch-this-click:"

  def OnNavigate(self,evt):
    targetUrl=evt.GetURL()
    #print "Navigate Target: ",targetUrl

    if self.CATCH_STRING in targetUrl:
      passed_data = targetUrl.split(self.CATCH_STRING,2)[1]
      print ("Click Caught!  Data = ",passed_data)
      evt.Veto() # prevent actual navigation.

    else:
      pass # let it do the normal thing...

  def OWVLoaded(self,evt):
      # the document is now loaded
      self.browser.RunScript("<script>https://cdn.ckeditor.com/ckeditor5/11.1.1/inline/ckeditor.js</script>")
      self.browser.RunScript('alert("Py - OWVloaded; got here");')




if __name__ == '__main__':
  app = wx.App()
  dialog = MyBrowser(None, -1)
#  url = os.path.join(os.getcwd(), 'test2.html')
  url = os.path.join(os.getcwd(), 'tinyMCE_test.html')
  print ("Py - loading url ",url)
  dialog.browser.LoadURL(url)
#  dialog.browser.LoadURL('http://www.themaninblue.com/experiment/widgEditor/')
  dialog.Show()
  app.MainLoop(

它将加载文件并显示,但编辑器不起作用。

我在使用CKEditor时遇到了同样的问题;

Python 3.6,wxPython 4.0.1和Windows 10 64位

是的,尽管我的头发是灰白的,但我还是有点菜鸟的。

行者

0 个答案:

没有答案