def __init__(self, parent=None): wx.Dialog.__init__(self, parent, -1, _('About wxGlade')) html = wx.html.HtmlWindow(self, -1, size=(480, 250)) html.Bind(wx.html.EVT_HTML_LINK_CLICKED, self.OnLinkClicked) # 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()
def __init__(self, parent, sInitText): wx.Dialog.__init__(self, parent, -1, 'About NXP Zigbee License Installer') html = wx.html.HtmlWindow(self, -1, size=(320, -1)) html.SetPage(self.text % sInitText) btn = html.FindWindowById(wx.ID_OK) ir = html.GetInternalRepresentation() html.SetSize((ir.GetWidth() + 25, ir.GetHeight() + 25)) self.SetClientSize(html.GetSize()) self.CentreOnParent(wx.BOTH)
def __init__(self, parent, config): wx.Dialog.__init__(self, parent, -1, 'About EvilScribe version ' + config.app_version) html = wx.html.HtmlWindow(self, -1, size=(640, -1)) html.LoadPage('http://www.evilscribe.net') ir = html.GetInternalRepresentation() html.SetSize((ir.GetWidth()+24, ir.GetHeight()+25)) self.SetClientSize(html.GetSize()) self.CentreOnParent(wx.BOTH)
def __init__(self, parent): wx.Dialog.__init__(self, parent, wx.ID_ANY, "About BrewFlasher") html = HtmlWindow(self, wx.ID_ANY, size=(420, -1)) if "gtk2" in wx.PlatformInfo or "gtk3" in wx.PlatformInfo: html.SetStandardFonts() txt = self.text.format(self._get_bundle_dir(), __version__) html.SetPage(txt) ir = html.GetInternalRepresentation() html.SetSize((ir.GetWidth() + 25, ir.GetHeight() + 25)) self.SetClientSize(html.GetSize()) self.CentreOnParent(wx.BOTH)
def __init__(self, parent): wx.Dialog.__init__(self, parent, -1, u'关于 PMManager v1.0', style=wx.DEFAULT_DIALOG_STYLE) html = HtmlWin(self) html.SetPage(self.text) ir = html.GetInternalRepresentation() html.SetSize((ir.GetWidth() + 20, ir.GetHeight() + 5)) self.SetClientSize(html.GetSize()) self.CentreOnParent(wx.BOTH)
def _create_contents(self, parent): if parent.GetParent() is not None: title = parent.GetParent().GetTitle() else: title = "" # Set the title. self.title = "About %s" % title # Load the image to be displayed in the about box. image = self.image.create_image() path = self.image.absolute_path # The additional strings. additions = '<br />'.join(self.additions) # The width of a wx HTML window is fixed (and is given in the # constructor). We set it to the width of the image plus a fudge # factor! The height of the window depends on the content. width = image.GetWidth() + 80 html = wx.html.HtmlWindow(parent, -1, size=(width, -1)) # Get the version numbers. py_version = sys.version[0:sys.version.find("(")] wx_version = wx.VERSION_STRING # Get the text of the OK button. if self.ok_label is None: ok = "OK" else: ok = self.ok_label # Set the page contents. html.SetPage(_DIALOG_TEXT % (path, additions, py_version, wx_version, ok)) # Make the 'OK' button the default button. ok_button = parent.FindWindowById( wx.ID_OK) #html.Window.FindWindowById(wx.ID_OK) ok_button.SetDefault() # Set the height of the HTML window to match the height of the content. internal = html.GetInternalRepresentation() html.SetSize((-1, internal.GetHeight())) # Make the dialog client area big enough to display the HTML window. # We add a fudge factor to the height here, although I'm not sure why # it should be necessary, the HTML window should report its required # size!?! width, height = html.GetSize().Get() parent.SetClientSize((width, height + 10))
def __init__(self, parent, size=(400, 200)): wx.Dialog.__init__(self, parent, -1, u'关于 Web Publisher v1.1', size=size, style=wx.DEFAULT_DIALOG_STYLE) html = HtmlWin(self) html.SetPage(self.text) ir = html.GetInternalRepresentation() html.SetSize((ir.GetWidth() + 20, ir.GetHeight() + 5)) #html.SetSize( (400, 320) ) self.SetClientSize(html.GetSize()) self.CentreOnParent(wx.BOTH)
def __init__(self, parent): wx.Dialog.__init__(self, parent, -1, 'About the wxPython demo',) html = wx.html.HtmlWindow(self, -1, size=(420, -1)) if "gtk2" in wx.PlatformInfo: html.SetStandardFonts() py_version = sys.version.split()[0] html.SetPage(self.text % (wx.VERSION_STRING, ", ".join(wx.PlatformInfo[1:]), py_version )) btn = html.FindWindowById(wx.ID_OK) ir = html.GetInternalRepresentation() html.SetSize( (ir.GetWidth()+25, ir.GetHeight()+25) ) self.SetClientSize(html.GetSize()) self.CentreOnParent(wx.BOTH)
def __init__(self, parent, program_name, program_version, program_author, program_copyright, program_contact): wx.Dialog.__init__(self, parent, -1, 'About %s' % program_name, style=wx.TAB_TRAVERSAL) html = wx.html.HtmlWindow(self, -1, size=(420, -1)) html.SetPage(self.text % (program_name, program_version, program_author, program_copyright, program_contact)) btn = html.FindWindowById(wx.ID_OK) btn.SetDefault() btn.SetFocus() #this set the focus to the button when dialog pops up ir = html.GetInternalRepresentation() html.SetSize((ir.GetWidth()+25, ir.GetHeight()+25)) self.SetClientSize(html.GetSize()) self.CentreOnParent(wx.BOTH)
def __init__(self, parent): wx.Dialog.__init__( self, parent, -1, 'About the wxPython demo', ) html = wx.html.HtmlWindow(self, -1, size=(420, -1)) py_version = sys.version.split()[0] html.SetPage(self.text % ("0.1", wx.VERSION_STRING)) btn = html.FindWindowById(wx.ID_OK) ##btn.SetDefault() ir = html.GetInternalRepresentation() html.SetSize((ir.GetWidth() + 25, ir.GetHeight() + 25)) self.SetClientSize(html.GetSize()) self.CentreOnParent(wx.BOTH)
def __init__(self, parent): wx.Dialog.__init__( self, parent, -1, 'Help: repoman CVS commits', ) html = wx.html.HtmlWindow(self, -1, size=(420, -1)) py_version = sys.version.split()[0] html.SetPage(self.text % (__version__.version, py_version, wx.VERSION_STRING)) btn = html.FindWindowById(wx.ID_OK) btn.SetDefault() ir = html.GetInternalRepresentation() html.SetSize((ir.GetWidth() + 25, ir.GetHeight() + 25)) self.SetClientSize(html.GetSize()) self.CentreOnParent(wx.BOTH)
def __init__(self, parent, htmlText): """ display author note about the SC4M file""" wx.Dialog.__init__( self, parent, -1, 'SC4M Author notes', ) html = MyHtmlWindow(self, -1, size=(420, -1)) #html.LoadPage( "about.html" ) print type(htmlText) html.SetPage(htmlText) btn = html.FindWindowById(wx.ID_OK) ir = html.GetInternalRepresentation() html.SetSize((ir.GetWidth() + 25, ir.GetHeight() + 25)) self.SetClientSize(html.GetSize()) self.CentreOnParent(wx.BOTH)
def __init__(self, parent, title, error_msg): wx.Dialog.__init__( self, parent, -1, 'System Error', ) html = wx.html.HtmlWindow(self, -1, size=(420, -1)) if "gtk2" in wx.PlatformInfo: html.SetStandardFonts() py_version = sys.version.split()[0] txt = self.text % (title, error_msg) html.SetPage(txt) btn = html.FindWindowById(wx.ID_OK) ir = html.GetInternalRepresentation() html.SetSize((ir.GetWidth() + 25, ir.GetHeight() + 25)) self.SetClientSize(html.GetSize()) self.CentreOnParent(wx.BOTH)
def __init__(self, parent, text): wx.Dialog.__init__( self, parent, -1, 'GWiz Help', ) html = wx.html.HtmlWindow(self, -1, size=(420, -1)) if "gtk2" in wx.PlatformInfo: html.SetStandardFonts() map = { 'PY_VERSION': sys.version.split()[0], 'WX_VERSION': wx.VERSION_STRING, 'WX_PLATFORM': wx.PlatformInfo[1:] } #!!!KL modify this to scroll the text so that long help files will be #supported htmlCode = self.preamble + text + self.postamble t = Template(htmlCode) ## print "htmlCode before:%s" % htmlCode try: htmlCode = t.safe_substitute(map) except TypeError: #!!!KL safe_substitue seems to throw an exception ## print "exception TypeError" pass ## print "htmlCode after:%s" % htmlCode html.SetPage(htmlCode) btn = html.FindWindowById(wx.ID_OK) ir = html.GetInternalRepresentation() html.SetSize((ir.GetWidth() + 25, ir.GetHeight() + 25)) self.SetClientSize(html.GetSize()) self.CenterOnParent(wx.BOTH)
def _create_contents(self, parent): if parent.GetParent() is not None: title = parent.GetParent().GetTitle() else: title = "" # Set the title. self.title = "About %s" % title # Load the image to be displayed in the about box. image = self.image.create_image() # The width of a wx HTML window is fixed (and is given in the # constructor). We set it to the width of the image plus a fudge # factor! The height of the window depends on the content. width = image.GetWidth() + 80 html = wx.html.HtmlWindow(parent, -1, size=(width, -1)) # Set the page contents. html.SetPage(self._create_html()) # Make the 'OK' button the default button. ok_button = parent.FindWindowById( wx.ID_OK ) # html.Window.FindWindowById(wx.ID_OK) ok_button.SetDefault() # Set the height of the HTML window to match the height of the content. internal = html.GetInternalRepresentation() html.SetSize((-1, internal.GetHeight())) # Make the dialog client area big enough to display the HTML window. # We add a fudge factor to the height here, although I'm not sure why # it should be necessary, the HTML window should report its required # size!?! width, height = html.GetSize().Get() parent.SetClientSize((width, height + 10))
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': from wx.lib.dialogs import ScrolledMessageDialog try: license = open( os.path.join(common.wxglade_path, 'license.txt')) dlg = ScrolledMessageDialog(self, license.read(), _("wxGlade - License")) license.close() dlg.ShowModal() dlg.Destroy() except IOError: wx.MessageBox( _("Can't find the license!\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': from wx.lib.dialogs import ScrolledMessageDialog try: credits = open( os.path.join(common.wxglade_path, 'credits.txt')) dlg = ScrolledMessageDialog(self, credits.read(), _("wxGlade - Credits")) credits.close() dlg.ShowModal() dlg.Destroy() except IOError: wx.MessageBox(_("Can't find the credits file!\n"), _("Oops!"), wx.OK | wx.CENTRE | wx.ICON_EXCLAMATION) else: import webbrowser webbrowser.open(linkinfo.GetHref(), new=True) html = HtmlWin(self, -1, size=(400, -1)) if misc.check_wx_version(2, 5, 3): try: html.SetStandardFonts() except AttributeError: pass py_version = sys.version.split()[0] bgcolor = misc.color_to_string(self.GetBackgroundColour()) icon_path = os.path.join(common.wxglade_path, 'icons/wxglade_small.png') html.SetPage( self.text % (bgcolor, icon_path, common.version, py_version, 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()
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()
def __init__(self, parent): wx.Dialog.__init__(self, parent, -1, _('About Wammu')) copyrightline = u'Copyright © 2003 - 2011 Michal Čihař' # default system colours bgc = wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE) fgc = wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNTEXT) hfgc = wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNHIGHLIGHT) colours = 'text="#%02x%02x%02x" bgcolor="#%02x%02x%02x" link="#%02x%02x%02x"' % ( fgc.Red(), fgc.Green(), fgc.Blue(), bgc.Red(), bgc.Green(), bgc.Blue(), hfgc.Red(), hfgc.Green(), hfgc.Blue()) text = ''' <html> <body %s> <center><font color="#ffffff"><table bgcolor="#458154" width="100%%" cellspacing="0" cellpadding="0" border="1"> <tr> <td align="center"> %s </td> </tr> </table></font> <p>%s</p> <p> <font size=-3> %s <br><br> %s <br><br> %s </font> </p> <p> <wxp module="wx" class="Button"> <param name="id" value="ID_OK"> </wxp> </p> </center> </body> </html> ''' % (colours, '''<img src="%s"><br><h2> Wammu %s</h2> %s<br> %s<br> %s<br> ''' % (Wammu.Paths.AppIconPath('wammu'), Wammu.__version__, _('Running on Python %s') % sys.version.split()[0], _('Using wxPython %s') % wx.VERSION_STRING, _('Using python-gammu %(python_gammu_version)s and Gammu %(gammu_version)s') % { 'python_gammu_version': gammu.Version()[1], 'gammu_version': gammu.Version()[0] }), _('<b>Wammu</b> is a wxPython based GUI for Gammu.'), copyrightline, _(''' This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. '''), _(''' This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. ''')) html = wx.html.HtmlWindow(self, -1, size=(500, -1)) html.SetPage(text) btn = html.FindWindowById(wx.ID_OK) if btn is not None: btn.SetDefault() representation = html.GetInternalRepresentation() html.SetSize( (representation.GetWidth() + 25, representation.GetHeight() + 25) ) self.SetClientSize(html.GetSize()) self.CentreOnParent(wx.BOTH)