""" About box with general info @copyright: 2002-2007 Alberto Griggio @copyright: 2014-2016 Carsten Grohmann @license: MIT (see LICENSE.txt) - THIS PROGRAM COMES WITH NO WARRANTY """ import codecs import wx import wx.html import wx.lib.wxpTag import config import misc import os.path class wxGladeAboutBox(wx.Dialog): text = '''
Version %s on Python %s and wxPython %s

License: MIT (see LICENSE.txt)

Home page: http://wxglade.sourceforge.net

For credits, see CREDITS.txt.

''' def __init__(self, parent=None): wx.Dialog.__init__(self, parent, -1, _('About wxGlade')) class HtmlWin(wx.html.HtmlWindow): def OnLinkClicked(self, linkinfo): href = linkinfo.GetHref() if href == 'show_license': if config.license_file: from wx.lib.dialogs import ScrolledMessageDialog try: license_file = codecs.open( config.license_file, encoding='UTF-8') dlg = ScrolledMessageDialog( self, license_file.read(), _("wxGlade - License") ) license_file.close() dlg.ShowModal() dlg.Destroy() except IOError: wx.MessageBox( _('License file "LICENSE.txt" not found!\n' 'You can get a copy at \n' 'http://www.opensource.org/licenses/' 'mit-license.php'), _('Error'), wx.OK | wx.CENTRE | wx.ICON_EXCLAMATION) else: wx.MessageBox( _('License file "LICENSE.txt" not found!\n' 'You can get a copy at \n' 'http://www.opensource.org/licenses/' 'mit-license.php'), _('Error'), wx.OK | wx.CENTRE | wx.ICON_EXCLAMATION) elif href == 'show_credits': if config.credits_file: from wx.lib.dialogs import ScrolledMessageDialog try: credits_file = codecs.open( config.credits_file, encoding='UTF-8') dlg = ScrolledMessageDialog( self, credits_file.read(), _("wxGlade - Credits") ) credits_file.close() dlg.ShowModal() dlg.Destroy() except IOError: wx.MessageBox( _('Credits file "CREDITS.txt" not found!'), _('Error'), wx.OK | wx.CENTRE | wx.ICON_EXCLAMATION) else: wx.MessageBox( _('Credits file "CREDITS.txt" not found!'), _('Error'), wx.OK | wx.CENTRE | wx.ICON_EXCLAMATION) else: import webbrowser webbrowser.open(linkinfo.GetHref(), new=True) html = HtmlWin(self, -1, size=(400, 250)) # it's recommended at least for GTK2 based wxPython if "gtk2" in wx.PlatformInfo: html.SetStandardFonts() bgcolor = misc.color_to_string(self.GetBackgroundColour()) icon_path = os.path.join(config.icons_path, 'wxglade_small.png') html.SetPage(self.text % (bgcolor, icon_path, config.version, config.py_version, config.wx_version)) ir = html.GetInternalRepresentation() ir.SetIndent(0, wx.html.HTML_INDENT_ALL) html.SetSize((ir.GetWidth(), ir.GetHeight())) szr = wx.BoxSizer(wx.VERTICAL) szr.Add(html, 0, wx.TOP|wx.ALIGN_CENTER, 10) szr.Add(wx.StaticLine(self, -1), 0, wx.LEFT|wx.RIGHT|wx.EXPAND, 20) szr2 = wx.BoxSizer(wx.HORIZONTAL) btn = wx.Button(self, wx.ID_OK, _("OK")) btn.SetDefault() szr2.Add(btn) if wx.Platform == '__WXGTK__': extra_border = 5 # border around a default button else: extra_border = 0 szr.Add(szr2, 0, wx.ALL|wx.ALIGN_RIGHT, 20 + extra_border) self.SetAutoLayout(True) self.SetSizer(szr) szr.Fit(self) self.Layout() if parent: self.CenterOnParent() else: self.CenterOnScreen() # end of class wxGladeAboutBox