Jun-11-2020, 11:28 AM
Hello,
I have created a Tkinter GUI script which monitor a PLC unit's I/O's in real time.
Therefore , i created a Modbus TCP/IP communication to the PLC client so i receive the digital input register as a list of 30 elements.
In order to monitor those digital inputs and update their status i created LED symbols that turn green if the status is True and turn red if the status changes to False.
In order to change the status (acts like real time) i used .after() methods inside multiple functions that executes them every 0.5 second
The problem takes place when i adds more Led widgets like that which bound to one of the input register.
I think that the multiple usage of .after() method caused the problem , so as many bound widgets as i add , the more the gui gets slower and even stuck at some point.
Here is an example of a function with that method that i wrote:
I have created a Tkinter GUI script which monitor a PLC unit's I/O's in real time.
Therefore , i created a Modbus TCP/IP communication to the PLC client so i receive the digital input register as a list of 30 elements.
In order to monitor those digital inputs and update their status i created LED symbols that turn green if the status is True and turn red if the status changes to False.
In order to change the status (acts like real time) i used .after() methods inside multiple functions that executes them every 0.5 second
The problem takes place when i adds more Led widgets like that which bound to one of the input register.
I think that the multiple usage of .after() method caused the problem , so as many bound widgets as i add , the more the gui gets slower and even stuck at some point.
Here is an example of a function with that method that i wrote:
class dig_in_rec(): def __init__(self, canvas , index, x1,y1,x2,y2 ,label, img1 , img2): self.canvas = canvas self.index = index self.x1 = x1 self.y1 = y1 self.x2 = x2 self.y2 = y2 self.img1 = img1 self.img2 = img2 self.label=label def rec_create(self): in_arr = md.rd_dig_in(0, 30) self.label.place(x=self.x1, y=self.y1) if in_arr[self.index] == True: self.label.config(image=self.img1) elif in_arr[self.index] == False: self.label.config(image=self.img2) self.canvas.after(500, self.rec_create)