def interactWithMathMl(self, mathMl): mathcontent = MathContent(A8M_PM.mathrule, mathMl) if _config.Access8MathConfig["settings"]["interaction_frame_show"]: show_main_frame(mathcontent) else: parent = api.getFocusObject() vw = A8MInteraction(parent=parent) vw.set(data=mathcontent, name="") vw.setFocus()
def OnExampleClick(self, evt): import copy from __init__ import A8MInteraction index = self.mathrulesList.GetFirstSelected() mathrule = copy.deepcopy(self.mathrules[index]) mathMl = mathrule[1].example mathcontent = MathContent(A8M_PM.mathrule, mathMl) parent = api.getFocusObject() vw = A8MInteraction(parent=parent) vw.set(data=mathcontent, name="") vw.setFocus()
def onLatexAdd(self, evt): # latex to mathml from xml.etree.ElementTree import tostring import latex2mathml.converter global main_frame parent = main_frame if main_frame else gui.mainFrame with wx.TextEntryDialog(parent=parent, message=_("Write LaTeX Content")) as dialog: if dialog.ShowModal() == wx.ID_OK: data = dialog.GetValue() data = latex2mathml.converter.convert(data) mathml = data mathcontent = MathContent(A8M_PM.mathrule, mathml) show_main_frame(mathcontent)
def script_interacte(self, gesture): with SectionManager() as manager: if manager.pointer and manager.pointer['type'] == 'math': mathMl = latex2mathml(manager.pointer['data'][2:-2]) mathcontent = MathContent(A8M_PM.mathrule, mathMl) if _config.Access8MathConfig["settings"]["interaction_frame_show"]: show_main_frame(mathcontent) else: parent = api.getFocusObject() vw = A8MInteraction(parent=parent) vw.set(data=mathcontent, name="") vw.setFocus() else: ui.message(_("This block cannot be interacted"))
def onAsciiMathAdd(self, evt): # asciimath to mathml from xml.etree.ElementTree import tostring import asciimathml global main_frame parent = main_frame if main_frame else gui.mainFrame with wx.TextEntryDialog(parent=parent, message=_("Write AsciiMath Content")) as dialog: if dialog.ShowModal() == wx.ID_OK: data = dialog.GetValue() data = asciimathml.parse(data) mathml = tostring(data) mathml = mathml.decode("utf-8") mathml = mathml.replace('math>', 'mrow>') mathcontent = MathContent(A8M_PM.mathrule, mathml) show_main_frame(mathcontent)
def getSpeechForMathMl(self, mathMl): self.mathcontent = MathContent(A8M_PM.mathrule, mathMl) return translate_SpeechCommand(self.mathcontent.pointer.serialized())