30
30
import zipfile
31
31
32
32
class Window (QMainWindow ):
33
- def __init__ (self , app , noscan ):
33
+ def __init__ (self , app , flags ):
34
34
super (Window , self ).__init__ ()
35
35
36
- self .noscan = noscan
36
+ self .flags = flags
37
37
self .initUI ()
38
38
app .aboutToQuit .connect (self .on_exit )
39
39
self .sysname = None
@@ -865,18 +865,27 @@ def initUI(self):
865
865
self .show ()
866
866
867
867
# scan if the user isn't suppressing this
868
- if not self .noscan :
869
- self .on_board_request (True )
870
- self .board .cmd (Board .SCAN , self .on_scan_result )
871
- else :
868
+ if "noscan" in self .flags :
872
869
# ask user for port
873
870
self .timer = QTimer (self )
874
871
self .timer .singleShot (100 , self .open_port_dialog )
875
-
872
+ #if "pybricks_ble" in self.flags:
873
+ # import pybricks_ble
874
+ # self.pybricks = pybricks_ble.Pybricks()
875
+ else :
876
+ self .on_board_request (True )
877
+ self .board .cmd (Board .SCAN , self .on_scan_result )
878
+
876
879
if __name__ == '__main__' :
877
880
# get own name. If name contains "noscan" then don't do
878
881
# a automatic scan but ask for a port instead
879
- noscan = "noscan" in os .path .splitext (os .path .basename (sys .argv [0 ]))[0 ].lower ()
882
+ flags = [ ]
883
+ if "noscan" in os .path .splitext (os .path .basename (sys .argv [0 ]))[0 ].lower ():
884
+ flags .append ("noscan" )
885
+
886
+ # pybricks is too limited to support it in uPIDE. It has no os modules ...
887
+ # if "pybricks_ble" in os.path.splitext(os.path.basename(sys.argv[0]))[0].lower():
888
+ # flags.append("pybricks_ble")
880
889
881
890
app = QApplication (sys .argv )
882
891
app_icon = QIcon ()
@@ -891,5 +900,5 @@ def initUI(self):
891
900
tr .load (QLocale .system ().name (), Window .resource_path ("assets/i18n" ))
892
901
app .installTranslator (tr )
893
902
894
- a = Window (app , noscan )
903
+ a = Window (app , flags )
895
904
sys .exit (app .exec_ ())
0 commit comments