From 2eeb9893dbe7a6a0b2612055493dc1fcddc9c6fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20St=C3=B6r?= Date: Sat, 10 Feb 2018 00:05:03 +0100 Subject: [PATCH] Major upgrade of all components - wxPython 4.0.1, finally... - Python 3 - esptool.py 2.2.1 --- About.py | 13 +++++++++---- HtmlPopupTransientWindow.py | 2 +- Main.py | 32 ++++++++++++++++++++------------ build-on-mac.spec | 3 +-- build-on-win.spec | 2 +- esptool.py | 37 ++++++++++++++++++++++--------------- 6 files changed, 54 insertions(+), 35 deletions(-) diff --git a/About.py b/About.py index f9185fe..7599645 100644 --- a/About.py +++ b/About.py @@ -1,7 +1,9 @@ # coding=utf-8 -import sys, os, wx +import sys +import os +import wx import wx.html import wx.lib.wxpTag import webbrowser @@ -29,10 +31,12 @@ class AboutDlg(wx.Dialog):

As with everything I offer for free, this is donation-ware. - Donate with PayPal + + Donate with PayPal +

-

© 2017 Marcel Stör. Licensed under MIT.

+

© 2018 Marcel Stör. Licensed under MIT.

@@ -57,7 +61,8 @@ def __init__(self, parent): self.SetClientSize(html.GetSize()) self.CentreOnParent(wx.BOTH) - def _get_bundle_dir(self): + @staticmethod + def _get_bundle_dir(): # set by PyInstaller, see http://pyinstaller.readthedocs.io/en/v3.2/runtime-information.html if getattr(sys, 'frozen', False): return sys._MEIPASS diff --git a/HtmlPopupTransientWindow.py b/HtmlPopupTransientWindow.py index 0d06847..eb22fe4 100644 --- a/HtmlPopupTransientWindow.py +++ b/HtmlPopupTransientWindow.py @@ -27,4 +27,4 @@ class HtmlWindow(wx.html.HtmlWindow): def OnLinkClicked(self, link): # get a hold of the PopupTransientWindow to close it self.GetParent().GetParent().Dismiss() - webbrowser.open(link.GetHref()) \ No newline at end of file + webbrowser.open(link.GetHref()) diff --git a/Main.py b/Main.py index 7e84e93..c82d48b 100644 --- a/Main.py +++ b/Main.py @@ -1,9 +1,12 @@ #!/usr/bin/env python import wx +import wx.adv import wx.lib.inspection import wx.lib.mixins.inspection -import sys, os + +import sys +import os import esptool import threading import json @@ -14,7 +17,7 @@ from esptool import NotImplementedInROMError from argparse import Namespace -__version__ = "2.2" +__version__ = "3.0" __flash_help__ = '''

This setting is highly dependent on your device!

@@ -50,7 +53,9 @@ def write(self, string): else: wx.CallAfter(self.__out.AppendText, string) + # noinspection PyMethodMayBeStatic def flush(self): + # noinspection PyStatementEffect None # --------------------------------------------------------------------------- @@ -210,7 +215,7 @@ def on_pick_file(event): reload_button = wx.BitmapButton(panel, id=wx.ID_ANY, bitmap=bmp, size=(bmp.GetWidth() + 7, bmp.GetHeight() + 7)) reload_button.Bind(wx.EVT_BUTTON, on_reload) - reload_button.SetToolTipString("Reload serial device list") + reload_button.SetToolTip("Reload serial device list") file_picker = wx.FilePickerCtrl(panel, style=wx.FLP_USE_TEXTCTRL) file_picker.Bind(wx.EVT_FILEPICKER_CHANGED, on_pick_file) @@ -322,7 +327,8 @@ def _select_configured_port(self): break count += 1 - def _get_serial_ports(self): + @staticmethod + def _get_serial_ports(): ports = [""] for port, desc, hwid in sorted(list_ports.comports()): ports.append(port) @@ -332,7 +338,7 @@ def _set_icons(self): self.SetIcon(images.Icon.GetIcon()) def _build_status_bar(self): - self.statusBar = self.CreateStatusBar(2, wx.ST_SIZEGRIP) + self.statusBar = self.CreateStatusBar(2, wx.STB_SIZEGRIP) self.statusBar.SetStatusWidths([-2, -1]) status_text = "Welcome to NodeMCU PyFlasher %s" % __version__ self.statusBar.SetStatusText(status_text, 0) @@ -356,7 +362,8 @@ def _build_menu_bar(self): self.SetMenuBar(self.menuBar) - def _get_config_file_path(self): + @staticmethod + def _get_config_file_path(): return wx.StandardPaths.Get().GetUserConfigDir() + "/nodemcu-pyflasher.json" # Menu methods @@ -380,13 +387,12 @@ def log_message(self, message): # --------------------------------------------------------------------------- -class MySplashScreen(wx.SplashScreen): +class MySplashScreen(wx.adv.SplashScreen): def __init__(self): - wx.SplashScreen.__init__(self, images.Splash.GetBitmap(), - wx.SPLASH_CENTRE_ON_SCREEN | wx.SPLASH_TIMEOUT, - 2500, None, -1) + wx.adv.SplashScreen.__init__(self, images.Splash.GetBitmap(), + wx.adv.SPLASH_CENTRE_ON_SCREEN | wx.adv.SPLASH_TIMEOUT, 2500, None, -1) self.Bind(wx.EVT_CLOSE, self._on_close) - self.__fc = wx.FutureCall(2000, self._show_main) + self.__fc = wx.CallLater(2000, self._show_main) def _on_close(self, evt): # Make sure the default handler runs too so this window gets @@ -412,7 +418,7 @@ def _show_main(self): # ---------------------------------------------------------------------------- class App(wx.App, wx.lib.mixins.inspection.InspectionMixin): def OnInit(self): - wx.SystemOptions.SetOptionInt("mac.window-plain-transition", 1) + wx.SystemOptions.SetOption("mac.window-plain-transition", 1) self.SetAppName("NodeMCU PyFlasher") # Create and show the splash screen. It will then create and @@ -435,6 +441,8 @@ def main(): app.MainLoop() # --------------------------------------------------------------------------- + if __name__ == '__main__': __name__ = 'Main' main() + diff --git a/build-on-mac.spec b/build-on-mac.spec index 2d4d6e2..3bba16c 100644 --- a/build-on-mac.spec +++ b/build-on-mac.spec @@ -2,7 +2,6 @@ block_cipher = None - a = Analysis(['nodemcu-pyflasher.py'], binaries=None, datas=[("images", "images")], @@ -26,6 +25,6 @@ exe = EXE(pyz, upx=True, console=False , icon='images/icon-256.icns') app = BUNDLE(exe, - name='NodeMCU-PyFlasher.app', + name='NodeMCU-PyFlasher-3.0.app', icon='./images/icon-256.icns', bundle_identifier='com.frightanic.nodemcu-pyflasher') diff --git a/build-on-win.spec b/build-on-win.spec index 9b894f0..baaaf19 100644 --- a/build-on-win.spec +++ b/build-on-win.spec @@ -19,7 +19,7 @@ exe = EXE(pyz, a.binaries, a.zipfiles, a.datas, - name='NodeMCU-PyFlasher', + name='NodeMCU-PyFlasher-3.0', debug=False, strip=False, upx=True, diff --git a/esptool.py b/esptool.py index 3d1f0c9..571f6a3 100755 --- a/esptool.py +++ b/esptool.py @@ -33,7 +33,7 @@ import serial -__version__ = "2.2" +__version__ = "2.2.1" MAX_UINT32 = 0xffffffff MAX_UINT24 = 0xffffff @@ -183,10 +183,10 @@ def __init__(self, port=DEFAULT_PORT, baud=ESP_ROM_BAUD, trace_enabled=False): with ones which throw NotImplementedInROMError(). """ - if isinstance(port, serial.Serial): - self._port = port - else: + if isinstance(port, str): self._port = serial.serial_for_url(port) + else: + self._port = port self._slip_reader = slip_reader(self._port, self.trace) # setting baud rate in a separate step is a workaround for # CH341 driver on some Linux versions (this opens at 9600 then @@ -265,18 +265,21 @@ def checksum(data, state=ESP_CHECKSUM_MAGIC): """ Send a request and read the response """ def command(self, op=None, data=b"", chk=0, wait_response=True, timeout=DEFAULT_TIMEOUT): - if op is not None: - self.trace("command op=0x%02x data len=%s wait_response=%d timeout=%.3f data=%r", - op, len(data), 1 if wait_response else 0, timeout, data) - pkt = struct.pack(b'