Make platform and distribution agnostic by allowing dynamic images path

This commit is contained in:
Marcel Stör 2017-01-07 22:48:44 +01:00
parent 5d451ed7a1
commit e0f8089b68
1 changed files with 15 additions and 15 deletions

View File

@ -1,7 +1,7 @@
# coding=utf-8
import wx
import sys, os, wx
import wx.html
import wx.lib.wxpTag
from Main import __version__
@ -12,27 +12,21 @@ from Main import __version__
class MyAboutBox(wx.Dialog):
text = '''
<html>
<body bgcolor="#DCDCDC">
<style>
body {
font-family: Arial;
background-color: #DCDCDC;
}
</style>
<body bgcolor="#DCDCDC" style="font-family: Arial; background-color: #DCDCDC;">
<center>
<img src="images/python-256.png" width="64" height="64" alt="Python">
<img src="images/icon-256.png" width="64" height="64" alt="NodeMCU">
<img src="images/espressif-256.png" width="64" height="64" alt="Espressif, producers of ESP8266 et.al.">
<img src="images/wxpython-256.png" width="64" height="43" alt="wxPython, cross-platform GUI framework">
<img src="{0}/images/python-256.png" width="64" height="64" alt="Python">
<img src="{0}/images/icon-256.png" width="64" height="64" alt="NodeMCU">
<img src="{0}/images/espressif-256.png" width="64" height="64" alt="Espressif, producers of ESP8266 et.al.">
<img src="{0}/images/wxpython-256.png" width="64" height="43" alt="wxPython, cross-platform GUI framework">
<h1>NodeMCU PyFlasher</h1>
<p>Version %s</p>
<p>Version {1}</p>
<p>Fork the <a style="color: #004CE5;" href="https://github.com/marcelstoer/nodemcu-pyflasher">project on
GitHub</a> and help improve it for all!</p>
<p>© 2016-2017 Marcel Stör. Licensed under MIT.</p>
<p>&copy; 2016-2017 Marcel St&ouml;r. Licensed under MIT.</p>
<p>
<wxp module="wx" class="Button">
@ -50,12 +44,18 @@ class MyAboutBox(wx.Dialog):
html = wx.html.HtmlWindow(self, -1, size=(420, -1))
if "gtk2" in wx.PlatformInfo or "gtk3" in wx.PlatformInfo:
html.SetStandardFonts()
txt = self.text % __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):
# 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__))
# ---------------------------------------------------------------------------