I am trying to figure out how possibly I could reuse the tabview with textboxes in my GUI python app using CTK. My current approach deletes all tabviews and creates new one with textbox to fill with data.
This is very problematic since it really distorts and lags my GUI everytime tabviews are re-created. I am looking for way that I could re-use the existing tabviews, or have set created default 3 tabviews each with textbox inside and just re-write the data and the Tabview titles. I struggle to make this, is there any way Iam missing? I would greatly appreciate any way that deals with the lag/Gui Distortion
def update_tabview(self, data_list):
if self._prev_data_list == data_list:
return
self._prev_data_list = data_list.copy() if data_list else None
my_tabview = self.tabview
current_tabs = my_tabview._name_list.copy()
for tab in current_tabs:
my_tabview.delete(tab)
if len(data_list) == 0:
my_tabview.add("Default TabView")
else:
for data in data_list:
name = data["name"]
my_tabview.add(name)
textbox = ctk.CTkTextbox(my_tabview.tab(name), wrap="word",
font=("Helvetica", 14, "bold"), width=380, height=260)
textbox.grid(row=0, column=0, padx=(5, 5), pady=(5, 10), sticky="nsew")
textbox.insert(tk.END, "TEXT" + "\n" + "\n")
textbox.insert(tk.END, data["a"] + "\n")
textbox.insert(tk.END, "\n" + "TEXT" + "\n\n")
for text in data["b"]:
textbox.insert(tk.END, text + "\n")
textbox.insert(tk.END, "\n" + "TEXT" + "\n\n")
for text in data["c"]:
textbox.insert(tk.END, text + "\n")
textbox.insert(tk.END, "\n" + "TEXT" + "\n\n")
for text in data["d"]:
textbox.insert(tk.END, text + ", ")
textbox.configure(state='disabled')