Reputation: 372
I have a program with 2 threads reading data continuously, and a third thread comparing the data read.
For the moment my third thread stores the data in a dictionnary of struct, the dictionnary key being the id of a specific data and the struct being like that :
@dataclass
class dataValues:
"""Represents the different values of a data"""
thread_1_value : int
thread_2_value : int
Currently I have no GUI and everytime a data value changes, I store the change in my dictionary, clear my terminal screen and use print to display in the terminal every data whose value is different between the 2 threads.
I want to add a GUI and display them in a table containing 3 columns : The data ID, the thread 1 value and the thread 2 value.
From what I searched and understood, I can use tkinter to create a GUI, in tkinter use Treeview to create my table with its 3 columns. My problem is to link/bind the dictionary with the treeview.
Is there a way to create a link between a dictionary and a tkinter treeview so everytime the dictionary changes the treeview is updated ?
Upvotes: 1
Views: 446
Reputation: 385970
Is there a way to create a link between a dictionary and a tkinter treeview so everytime the dictionary changes the treeview is updated ?
No, there is not. You will have to iteratively step through the dictionary and add items to or remove items from the treeview one by one.
Upvotes: 1