Pause for an event in python tkinter -
Pause for an event in python tkinter -
i using python 2.7 tkinter gui on raspberry pi automate material testing. testing, multiple samples must tested , takes time swap out samples. want prompt text saying "please insert sample 1 press come in on keyboard" , have function pause until come in has been pressed. instead of pressing come in utilize tkinter button. ideas without using external libraries? have tried while loop in seek , exit loop 1 time button pressed, since loop running button not register.
sample code (removed lots of code , left relevant):
class app: def __init__(self,master): #self.wiltron = wiltron_54128a_gpib() self.var = tk.stringvar() self.var.trace("w",self.gettest) self.okbutton = tk.intvar() self.okbutton.trace("w",self.okbutton) frame = frame(master) frame.pack() #initial gui values self.var.set('choose test') testchoices = ['test'] app.testoption = tk.optionmenu(frame, self.var, *testchoices) app.testoption.grid(row=0, column=0) okbutton = tk.button(frame, text=" ok ", command=self.okbutton).grid(row=2, column=1) #test routine functions def gettest(self, *args): test = self.var.get() sf = "ic network analyzer" root.title(sf) ##### if test == "test": sample1 = self.wiltron.sample_data() print 'change out sample press ok' #this need pause until next sample has been inserted sample2 = self.wiltron.sample_data() #ect. ##### def okbutton(self): #whatever need create button exit pause
use tkmessagebox
import tkinter import tkmessagebox print "sample #1" tkmessagebox.showinfo("message", "insert sample , press ok") print "sample #2"
python python-2.7 tkinter keyboardinterrupt
Comments
Post a Comment