From 862eb4bcb8258a8ce51ba22ee7f8868f8f7c15ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20St=C3=B6r?= Date: Sat, 18 Feb 2017 22:18:43 +0100 Subject: [PATCH] Fix GH link in about dialog, fixes #4 --- About.py | 18 ++++++++++++------ Main.py | 4 ++-- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/About.py b/About.py index 4daebf3..6177280 100644 --- a/About.py +++ b/About.py @@ -4,12 +4,13 @@ import sys, os, wx import wx.html import wx.lib.wxpTag +import webbrowser from Main import __version__ # --------------------------------------------------------------------------- -class MyAboutBox(wx.Dialog): +class AboutDlg(wx.Dialog): text = ''' @@ -26,7 +27,7 @@ class MyAboutBox(wx.Dialog):

Fork the project on GitHub and help improve it for all!

-

© 2016-2017 Marcel Stör. Licensed under MIT.

+

© 2017 Marcel Stör. Licensed under MIT.

@@ -40,22 +41,27 @@ class MyAboutBox(wx.Dialog): ''' def __init__(self, parent): - wx.Dialog.__init__(self, parent, -1, "About NodeMCU PyFlasher") - html = wx.html.HtmlWindow(self, -1, size=(420, -1)) + wx.Dialog.__init__(self, parent, wx.ID_ANY, "About NodeMCU PyFlasher") + 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__) + 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 __get_bundle_dir(self): + def _get_bundle_dir(self): # set by PyInstaller, see http://pyinstaller.readthedocs.io/en/v3.2/runtime-information.html if getattr(sys, 'frozen', False): return sys._MEIPASS else: return os.path.dirname(os.path.abspath(__file__)) + +class HtmlWindow(wx.html.HtmlWindow): + def OnLinkClicked(self, link): + webbrowser.open(link.GetHref()) + # --------------------------------------------------------------------------- diff --git a/Main.py b/Main.py index 808726d..4a77e33 100644 --- a/Main.py +++ b/Main.py @@ -272,8 +272,8 @@ class NodeMcuFlasher(wx.Frame): self.Close(True) def _on_help_about(self, event): - from About import MyAboutBox - about = MyAboutBox(self) + from About import AboutDlg + about = AboutDlg(self) about.ShowModal() about.Destroy()