def setAddOpt(self, addOpt, addoptpanel): """ Part of "Prints" plugin API. Shows content of addOpt in the addoptpanel (must not be None). This function is only called if getAddOptVersion() != -1. """ fontDesc, wpseparator = \ addOpt[:2] ctrls = XrcControls(addoptpanel) addoptpanel.fontDesc = fontDesc ctrls.tfWikiPageSeparator.SetValue(wpseparator)
def getAddOptPanelsForTypes(self, guiparent, printTypes): """ Part of "Prints" plugin API. Construct all necessary GUI panels for additional options for the types contained in exportTypes. Returns sequence of tuples (<print type>, <panel for add. options or None>) The panels should use guiparent as parent. If the same panel is used for multiple export types the function can and should include all export types for this panel even if some of them weren't requested. Panel objects must not be shared by different print classes. """ if not "plain_text" in printTypes: return () res = wx.xrc.XmlResource.Get() panel = res.LoadPanel(guiparent, "PrintSubPlainText") ctrls = XrcControls(panel) config = self.mainControl.getConfig() def OnChoosePlainTextFont(evt): fontdata = wx.FontData() if panel.fontDesc: font = wx.FontFromNativeInfoString(panel.fontDesc) fontdata.SetInitialFont(font) dlg = wx.FontDialog(panel, fontdata) try: if dlg.ShowModal() == wx.ID_OK: # fontdata = dlg.GetFontData() font = dlg.GetFontData().GetChosenFont() panel.fontDesc = font.GetNativeFontInfoDesc() finally: dlg.Destroy() ctrls.tfWikiPageSeparator.SetValue(config.get("main", "print_plaintext_wpseparator")) panel.fontDesc = config.get("main", "print_plaintext_font") panel.Bind(wx.EVT_BUTTON, OnChoosePlainTextFont, id=GUI_ID.btnChoosePlainTextFont) return ( ("plain_text", panel), )
def getAddOpt(self, addoptpanel): """ Part of "Prints" plugin API. Reads additional options from panel addoptpanel. If getAddOptVersion() > -1, the return value must be a sequence of simple string, unicode and/or numeric objects. Otherwise, any object can be returned (normally the addoptpanel itself). Here, it returns a tuple with following items: fontDesc -- string describing font to use plain text wpseparator -- unistring with (escaped) separator between wiki words """ if addoptpanel is None: # Return default set in options config = self.mainControl.getConfig() return (config.get("main", "print_plaintext_font"), config.get("main", "print_plaintext_wpseparator")) else: fontDesc = addoptpanel.fontDesc ctrls = XrcControls(addoptpanel) wpseparator = ctrls.tfWikiPageSeparator.GetValue() return (fontDesc, wpseparator)