1+ # Big thx to Michael Kandziora for this GUI port to PyQt5
12import re
23import sys
34import threading
4- import os
5- import platform
6- import distro # Added import
5+ import os
6+ import platform
7+ import distro
78
8- from PyQt5 .QtWidgets import (QApplication , QMainWindow , QWidget , QVBoxLayout ,
9- QHBoxLayout , QPushButton , QLabel , QComboBox ,
9+ from PyQt5 .QtWidgets import (QApplication , QMainWindow , QWidget , QVBoxLayout ,
10+ QHBoxLayout , QPushButton , QLabel , QComboBox ,
1011 QFileDialog , QTextEdit , QGroupBox , QGridLayout )
11- from PyQt5 .QtGui import QColor , QTextCursor , QPalette , QColor
12+ from PyQt5 .QtGui import QColor , QTextCursor , QPalette , QColor
1213from PyQt5 .QtCore import pyqtSignal , QObject
1314
1415from esp_flasher .helpers import list_serial_ports
@@ -94,7 +95,6 @@ def init_ui(self):
9495
9596 vbox = QVBoxLayout ()
9697
97-
9898 port_group_box = QGroupBox ("Serial Port" )
9999 port_layout = QGridLayout ()
100100 port_label = QLabel ("Select Port:" )
@@ -108,7 +108,6 @@ def init_ui(self):
108108 port_layout .addWidget (reload_button , 0 , 2 )
109109 port_group_box .setLayout (port_layout )
110110
111-
112111 firmware_group_box = QGroupBox ("Firmware" )
113112 firmware_layout = QGridLayout ()
114113 firmware_label = QLabel ("Select Firmware:" )
@@ -118,7 +117,6 @@ def init_ui(self):
118117 firmware_layout .addWidget (self .firmware_button , 0 , 1 )
119118 firmware_group_box .setLayout (firmware_layout )
120119
121-
122120 actions_group_box = QGroupBox ("Actions" )
123121 actions_layout = QHBoxLayout ()
124122 self .flash_button = QPushButton ("Flash ESP" )
@@ -129,15 +127,13 @@ def init_ui(self):
129127 actions_layout .addWidget (self .logs_button )
130128 actions_group_box .setLayout (actions_layout )
131129
132-
133130 console_group_box = QGroupBox ("Console" )
134131 console_layout = QVBoxLayout ()
135132 self .console = QTextEdit ()
136133 self .console .setReadOnly (True )
137134 console_layout .addWidget (self .console )
138135 console_group_box .setLayout (console_layout )
139136
140-
141137 vbox .addWidget (port_group_box )
142138 vbox .addWidget (firmware_group_box )
143139 vbox .addWidget (actions_group_box )
@@ -177,7 +173,7 @@ def view_logs(self):
177173 worker .start ()
178174
179175def main ():
180-
176+
181177 os_name = platform .system ()
182178 if os_name == 'Darwin' :
183179 os .environ ['QT_QPA_PLATFORM' ] = 'cocoa'
@@ -190,11 +186,10 @@ def main():
190186 elif os_name == 'Windows' :
191187 os .environ ['QT_QPA_PLATFORM' ] = 'windows'
192188 else :
193- os .environ ['QT_QPA_PLATFORM' ] = 'offscreen'
189+ os .environ ['QT_QPA_PLATFORM' ] = 'offscreen'
194190
195191 app = QApplication (sys .argv )
196192
197-
198193 app .setStyle ("Fusion" )
199194 palette = QPalette ()
200195 palette .setColor (QPalette .Window , QColor (53 , 53 , 53 ))
@@ -210,7 +205,7 @@ def main():
210205 palette .setColor (QPalette .Link , QColor (42 , 130 , 218 ))
211206 palette .setColor (QPalette .Highlight , QColor (42 , 130 , 218 ))
212207 palette .setColor (QPalette .HighlightedText , QColor (0 , 0 , 0 ))
213- app .setPalette (palette )
208+ app .setPalette (palette )
214209
215210 main_window = MainWindow ()
216211 main_window .show ()
0 commit comments