I'm working on a project using National Instruments boards to do data acquistion. I have functional C codes for doing the tasks, but would like to use Python, so the GUI programming is less painful. In my C-code, I use the API call setTimer, which raises a WM_TIMER event at regular intervals. Is there a similar, mechanism in a Tk loop? I tried using the following code.
def DAQ(self):
if self.do_DAQ:
result = self.myDAQ.getData()
currTime = time.time() - self.start_time
self.time_label.config(text="{:.1f} seconds".format(currTime))
self.volt_label.config(text="{:.4f} volts".format(result))
self.time_data[self.i] = currTime
self.volt_data[self.i] = result
self.i += 1
self.after(1962, self.DAQ)
The magic "1962" in the after() was determined by trial and error to give about a 2 second delay, but the time slices drift depending on what else is in the queue. Is there a way I can do this so my time slices are more accurate? Specifically, can I force Tk to do my DAQ event before other things in the queue?