File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -81,8 +81,13 @@ def runExample():
8181 else :
8282 print (charButton , end = "" )
8383
84- # Flush the stdout buffer to give immediate user feedback
85- sys .stdout .flush ()
84+ # Some platforms won't print until newline character, so a flush is
85+ # needed to update. However some platforms (eg. MicroPython) don't
86+ # include sys.stdout.flush(), so wrap in a try block
87+ try :
88+ sys .stdout .flush ()
89+ except :
90+ pass
8691
8792 time .sleep (.25 )
8893
Original file line number Diff line number Diff line change @@ -140,7 +140,13 @@ def clearEntry(userEntry):
140140def printEntry (userEntry ):
141141
142142 print ("\r UserEntry:%s" % ('' .join (userEntry )), end = "" )
143- sys .stdout .flush ()
143+ # Some platforms won't print until newline character, so a flush is
144+ # needed to update. However some platforms (eg. MicroPython) don't
145+ # include sys.stdout.flush(), so wrap in a try block
146+ try :
147+ sys .stdout .flush ()
148+ except :
149+ pass
144150
145151
146152if __name__ == '__main__' :
You can’t perform that action at this time.
0 commit comments