Python tkinter, do something before subprocess starts -
i'm having problem python tkinter program. want press button start subprocess , indicate subprocess running changing label's value. subprocess takes time , problem label waits subprocess finished change, don't understand, because used variable first change label , go on subprocess. here code:
def program_final(): start = false while true: if start == false: v.set("scanning...") label.pack() start = true else: # p = subprocess.popen('sudo nfc-poll', shell=true, stdout=subprocess.pipe, stderr=subprocess.stdout) # opens subporocess starts nfc-polling in background p = subprocess.popen('ping 8.8.8.8', shell=true, stdout=subprocess.pipe, stderr=subprocess.stdout) counter = 0 output = "" lines = [] while true: line = p.stdout.readline() # while loop iterates through output lines of lines.insert(counter, line) # subproccess , saves whole result list counter = counter +1 # result needed set output if counter == 9: break if lines[6][7:10] == 'uid': # check if uid line present output = output + "tag found!\n" + lines[6][7:] # if yes output string gets added uid of tag elif lines[6][7:10] != 'uid': # if uid line not present means no tag found output = output + "no tag found!\n" # output set no tag found text.delete(1.0, end) # old tag infos getting deleted out of texfield text.insert(insert, output) # tag infos or 'no tag found' message added textfield break
thanks in advance.
tkinter update graphic when there nothing else do. can force gui refresh if use update method on widgets want update.
tk.updates()
Comments
Post a Comment