def set_clipboard_word(self): """Store the formatted output in the clipboard in a Microsoft Word friendly format. Microsoft Word interprets the clipboard contents as an equation. Other programs will see it as plain text containing XML. """ QApplication.clipboard().setText(generic.word_equation_from_mathml( self.view.page().mainFrame().evaluateJavaScript(generic.MML_JS)))
def set_clipboard_word(self, event): """Store the formatted output in the clipboard in a Microsoft Word friendly format. Microsoft Word interprets the clipboard contents as an equation. Other programs will see it as plain text containing XML. Note ---- Currently, wx has no way of obtaining returned results from JavaScript functions. In order to do this, any data that needs to be read from the page is stored in the page title, which is accessible from wx. This is a hack that will be changed when wx implements the required functionality. """ self.view.RunScript("document.title = {}".format(generic.MML_JS)) mml = generic.word_equation_from_mathml(self.view.GetCurrentTitle()) print(mml.encode('utf-8')) if wx.TheClipboard.Open(): wx.TheClipboard.SetData(_TextDataObject(mml)) wx.TheClipboard.Close()