@@ -17,7 +17,10 @@ def close():
17
17
win .popupWait .destroy ()
18
18
19
19
def received ():
20
- return receive ()
20
+ rec = receive ()
21
+ print (f"Rec: { rec } of type { type (rec )} " )
22
+ if rec == None : rec == ['' ]
23
+ return rec
21
24
22
25
def show (rootWin ,scriptpath ,rmtSend ,rmtReceive ):
23
26
global win ,send ,receive
@@ -60,8 +63,8 @@ def show(rootWin,scriptpath,rmtSend,rmtReceive):
60
63
lb .pack (side = tk .LEFT )
61
64
62
65
popupWait .varDelay = tk .StringVar ()
63
- popupWait .delayList = ("No delay" ,"0.1 sec" ,"0.5 sec" ,"1 sec" ,"2 sec" ,"5 sec" )
64
- popupWait .delayTimes = (0 ,0.1 ,0.5 ,1.0 ,2.0 ,5.0 )
66
+ popupWait .delayList = ("No delay" ,"0.01 sec" , "0. 1 sec" ,"0.5 sec" ,"1 sec" ,"2 sec" ,"5 sec" )
67
+ popupWait .delayTimes = (0 ,0.01 , 0. 1 ,0.5 ,1.0 ,2.0 ,5.0 )
65
68
popupWait .varDelay .set ('0.5 sec' )
66
69
ddDelay = tk .OptionMenu (footerframe ,popupWait .varDelay ,* popupWait .delayList )
67
70
ddDelay .pack (side = tk .LEFT ,padx = (3 ,0 ))
@@ -77,6 +80,12 @@ def show(rootWin,scriptpath,rmtSend,rmtReceive):
77
80
ddDelay .configure (bd = '0p' )
78
81
ddDelay .configure (highlightthickness = 0 )
79
82
83
+ popupWait .varSkipVars = tk .BooleanVar (value = True )
84
+ cbSkipVars = tk .Checkbutton (footerframe ,text = "Skip Vars:" ,variable = popupWait .varSkipVars )
85
+ cbSkipVars .configure (background = footerbgcolor ,activebackground = footersgcolor ,fg = footerfgcolor ,activeforeground = footerfgcolor ,highlightbackground = footerbgcolor ,selectcolor = footerbgcolor )
86
+ cbSkipVars .pack (side = tk .LEFT )
87
+ cbSkipVars .configure (relief = tk .FLAT )
88
+
80
89
popupWait .cmdRun = tk .Button (footerframe , text = "Run" ,command = process )
81
90
popupWait .cmdRun .pack (side = tk .RIGHT )
82
91
popupWait .cmdRun .configure (relief = tk .FLAT )
@@ -217,25 +226,34 @@ def errhndlr(errStack):
217
226
pyi .setErrorHandler (errhndlr )
218
227
# reroute print to infobos
219
228
def print2InfoBox (msg ):
220
- popupWait .varInfo .set (bytes2String .ascii (msg .encode ('utf-8' )))
221
- pyi .addSystemFunction ('print' ,print2InfoBox ,[[str ,int ,bool ,float ],])
229
+ print (f"msg type { type (msg )} " )
230
+ if isinstance (msg ,bytes ):
231
+ popupWait .varInfo .set (bytes2String .raw (msg ).strip ())
232
+ elif isinstance (msg ,str ):
233
+ popupWait .varInfo .set (msg .strip ())
234
+ else :
235
+ popupWait .varInfo .set (msg )
236
+ pyi .addSystemFunction ('print' ,print2InfoBox ,[[str ,int ,bool ,float ,bytes ],])
237
+ def printAscii2InfoBox (msg ):
238
+ popupWait .varInfo .set (bytes2String .ascii (msg ).strip ())
239
+ pyi .addSystemFunction ('printa' ,printAscii2InfoBox ,[[bytes ],])
222
240
def printHex2InfoBox (msg ):
223
- popupWait .varInfo .set (bytes2String .hex (msg . encode ( 'utf-8' ) ))
224
- pyi .addSystemFunction ('printh' ,printHex2InfoBox ,[[str , int , bool , float ],])
241
+ popupWait .varInfo .set (bytes2String .hex (msg ). strip ( ))
242
+ pyi .addSystemFunction ('printh' ,printHex2InfoBox ,[[bytes ],])
225
243
def printDec2InfoBox (msg ):
226
- popupWait .varInfo .set (bytes2String .dec (msg . encode ( 'utf-8' ) ))
227
- pyi .addSystemFunction ('printd' ,printDec2InfoBox ,[[str , int , bool , float ],])
244
+ popupWait .varInfo .set (bytes2String .dec (msg ). strip ( ))
245
+ pyi .addSystemFunction ('printd' ,printDec2InfoBox ,[[bytes ],])
228
246
def printRaw2InfoBox (msg ):
229
- popupWait .varInfo .set (bytes2String . raw ( msg . encode ( 'utf-8' )) )
230
- pyi .addSystemFunction ('printr' ,printRaw2InfoBox ,[[str , int , bool , float ],])
247
+ popupWait .varInfo .set (f" { msg } " )
248
+ pyi .addSystemFunction ('printr' ,printRaw2InfoBox ,[[bytes ],])
231
249
# add send (over serial) command
232
250
pyi .addSystemFunction ('send' ,send ,[[str ,],])
233
251
# add received var (to be updated each x msecs)
234
252
pyi .importSystemFunction (pyi ,__name__ ,"received" )
235
253
236
254
#run script
237
255
scriptStart = time .time ()
238
- runSuccess = pyi .runScript (delaytime = delayTime )
256
+ runSuccess = pyi .runScript (delaytime = delayTime , skipVarDelay = popupWait . varSkipVars . get () )
239
257
scriptDuration = time .time ()- scriptStart
240
258
if runSuccess and isProcessingScript :
241
259
msgbox = messagePopup .show (win ,type = "info" ,title = "Script finished" , message = f"Script '{ popupWait .scriptname } ' finished in { scriptDuration :.4f} seconds!" )
0 commit comments