@@ -54,12 +54,12 @@ def check_mac(s):
5454 return True
5555
5656class Progress :
57- def __init__ (self ):
57+ def __init__ (self , txt = 'Flashing progress: 0.0%' ):
5858 layout = [
59- [sg .Text ('Flashing progress: 0.0%' , key = 'txt' )],
59+ [sg .Text (txt , key = 'txt' )],
6060 [sg .ProgressBar (1.0 , orientation = 'h' , size = (20 ,20 ), key = 'progress' )],
6161 ]
62- self .self . window = sg .Window ("Progress" , layout , modal = True , finalize = True )
62+ self .window = sg .Window ("Progress" , layout , modal = True , finalize = True )
6363 def update (self , val ):
6464 self .window ['progress' ].update (val )
6565 self .window ['txt' ].update (f'Flashing progress: { val * 100 :.1f} %' )
@@ -166,9 +166,10 @@ def flashBootloader(device: dai.DeviceInfo):
166166 print ("Flashing bootloader canceled." )
167167 return
168168
169+ pr = Progress ('Connecting...' )
170+
169171 bl = dai .DeviceBootloader (device , True )
170172
171- pr = Progress ()
172173 progress = lambda p : pr .update (p )
173174 if type == dai .DeviceBootloader .Type .AUTO :
174175 type = bl .getType ()
@@ -443,9 +444,13 @@ def run(self) -> None:
443444 self .getConfigs ()
444445 self .unlockConfig ()
445446 elif event == "Flash newest Bootloader" :
446- self .closeDevice () # We will reconnect, as we need to set allowFlashingBootloader to True
447+ # We will reconnect, as we need to set allowFlashingBootloader to True
448+ self .closeDevice ()
447449 flashBootloader (self .device )
448- self .window .Element ('currBoot' ).update (self .bl .getVersion ())
450+ # Device will reboot, close previous and reset GUI
451+ self .closeDevice ()
452+ self .resetGui ()
453+ self .getDevices ()
449454 elif event == "Flash configuration" :
450455 self .flashConfig ()
451456 self .getConfigs ()
@@ -591,7 +596,9 @@ def getDevices(self):
591596 deviceTxt = deviceInfo .getMxId ()
592597 listedDevices .append (deviceTxt )
593598 self .devices [deviceTxt ] = deviceInfo
594- self .window .Element ('devices' ).update ("Select device" , values = listedDevices )
599+
600+ # Update the list regardless
601+ self .window .Element ('devices' ).update ("Select device" , values = listedDevices )
595602 except Exception as ex :
596603 PrintException ()
597604 sg .Popup (f'{ ex } ' )
0 commit comments