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, 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)) 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): 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, updater): # EULA description file path if hasattr(sys, '_MEIPASS'): eula_desc_file = os.path.join(sys._MEIPASS, EULA_DESCRIPTION) logo_image_file = os.path.join(sys._MEIPASS, LOGO_IMAGE) else: eula_desc_file = EULA_DESCRIPTION logo_image_file = LOGO_IMAGE # store accept checkbox status self.is_accepted = False wx.Frame.__init__(self, None, -1, TITLE, style=wx.STAY_ON_TOP | wx.DEFAULT_FRAME_STYLE ^ wx.RESIZE_BORDER) self.updater = updater # Get current display size display_size = wx.GetDisplaySize() # Set window size for layout window_width = WINDOW_WIDTH window_height = WINDOW_HEIGHT # Centering in display window_pos_x = (display_size[0] - window_width) / 2 window_pos_y = (display_size[1] - window_height) / 2 # Set main window layout self.SetSize(window_width, window_height) self.SetPosition((window_pos_x, window_pos_y)) # Define 3 panels layout (top_x, top_y, top_w, top_h) = (0, 0, window_width, window_height / 10) (htm_x, htm_y, htm_w, htm_h) = (0, top_y + top_h, window_width, window_height * 7.5 / 10) (ope_x, ope_y, ope_w, ope_h) = (0, htm_y + htm_h, window_width, window_height - top_h - htm_h) # Top panel (for subject) top_panel = wx.Window(self, -1, style=wx.SIMPLE_BORDER) top_panel.SetBackgroundColour(wx.WHITE) top_panel.SetSize(top_w, top_h) top_panel.SetPosition((top_x, top_y)) subject_txt = wx.StaticText(top_panel, -1, SUBJECT) font = subject_txt.GetFont() font.SetWeight(wx.FONTWEIGHT_BOLD) font.SetPointSize(14) subject_txt.SetFont(font) subject_txt.SetSize(top_w, top_h / 2) subject_txt.SetPosition((20, 0)) desc_txt = wx.StaticText(top_panel, -1, EXPLAIN) font = desc_txt.GetFont() font.SetPointSize(14) desc_txt.SetFont(font) desc_txt.SetSize(top_w, top_h / 2) desc_txt.SetPosition((40, top_h / 2)) s_logo_img = wx.Image(logo_image_file) image_size = s_logo_img.GetSize() image_bitmap = s_logo_img.ConvertToBitmap() logo_l = wx.StaticBitmap(top_panel, -1, image_bitmap) logo_l.SetSize(image_size[0], image_size[1]) logo_l.SetPosition((top_w - image_size[0] - 10, 5)) # HTML panel (for display EULA description) htm_panel = wx.Window(self, -1, style=wx.SIMPLE_BORDER) htm_panel.SetBackgroundColour(wx.Colour(0xF3, 0xEC, 0xD8, 0xFF)) htm_panel.SetSize(htm_w, htm_h) htm_panel.SetPosition((htm_x, htm_y)) # Operation panel (for take event) ope_panel = wx.Window(self, -1, style=wx.SIMPLE_BORDER) ope_panel.SetBackgroundColour(wx.Colour(0xF3, 0xEC, 0xD8, 0xFF)) ope_panel.SetSize(ope_w, ope_h) ope_panel.SetPosition((ope_x, ope_y)) accept_chk = wx.CheckBox(ope_panel, ACCEPT_CHK_ID, ACCEPT_CHK) accept_chk.SetValue(False) font = accept_chk.GetFont() font.SetPointSize(14) accept_chk.SetFont(font) accept_chk.SetSize(ope_w, ope_h / 2 - 10) accept_chk.SetPosition((20, 0)) self.ok_btn = wx.Button(ope_panel, OK_BTN_ID, "OK") font = self.ok_btn.GetFont() font.SetPointSize(14) self.ok_btn.SetFont(font) self.ok_btn.SetSize(70, 40) self.ok_btn.SetPosition((ope_w - 180, ope_h / 2 - 10)) # Disable 'OK' button by default self.ok_btn.Disable() cn_btn = wx.Button(ope_panel, CANCEL_BTN_ID, "Cancel") font = cn_btn.GetFont() font.SetPointSize(14) cn_btn.SetFont(font) cn_btn.SetSize(70, 40) cn_btn.SetPosition((ope_w - 100, ope_h / 2 - 10)) # Set event handler self.Bind(wx.EVT_BUTTON, self.eulaEventHandler, self.ok_btn) self.Bind(wx.EVT_BUTTON, self.eulaEventHandler, cn_btn) self.Bind(wx.EVT_CHECKBOX, self.eulaEventHandler, accept_chk) # Create HTML view html = wx.html.HtmlWindow(htm_panel) html.SetSize(htm_w, htm_h) html.SetPosition((0, 0)) # Set EULA HTML view from file eula_file = open(eula_desc_file, encoding='utf-8') html.SetPage(eula_file.read()) eula_file.close() # Show self.Fit() self.Show()
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)