Oct-28-2022, 12:35 AM
Hello all,
I have a program where I receive a real-time data via TCP-IP using sockets, where I want to use one specific data to make a calculation in real-time. Below is the function I call to start a calculation by another function. The value which updates every one second is the "spm_value".
Could you please help me on that?
Thanks in advance!
I have a program where I receive a real-time data via TCP-IP using sockets, where I want to use one specific data to make a calculation in real-time. Below is the function I call to start a calculation by another function. The value which updates every one second is the "spm_value".
def on_btn(self):
if self.after_id:
self.after_cancel(self.after_id)
self.after_id = None
self.button.config(text="Start")
self.stroke_rate_entry.config(state="normal")
return
self.stroke_rate = spm_value
self.button.config(text="Pause")
self.stroke_rate_entry.config(state="disabled")
self.update_stroke()Here is the function where it makes the calculation. "self.stroke_rate" is the variable I created which is receiving the "spm_value"def update_stroke(self):
self.stroke_count += self.stroke_rate
self.stroke_redonded = round(self.stroke_count, 2)
self.stroke_amount_label.config(text=f"{self.stroke_redonded} STROKES")
self.ecd_label.config(text=f"{ecd_value} PPG")
self.after_id = self.after(1000, self.update_stroke).When I press the start button, it start to calculate the number, but it starts to calculate only using the last "spm_value" received at the moment the start button was pressed, the calculation is not updating in real-time too if the value changes.Could you please help me on that?
Thanks in advance!
