Open mikolaj-rokicki opened 4 months ago
Can you please provide the source code?
I've made some basic code to demonstrate this issue:
import customtkinter as ctk
def rename():
tabview.rename('1', '3')
app = ctk.CTk()
tabview = ctk.CTkTabview(app)
tab1 = tabview.add('1')
tab2 = tabview.add('2')
tabview.grid(row = 0, column = 0)
button = ctk.CTkButton(app, command=rename)
button.grid(row = 1, column = 0)
label1 = ctk.CTkLabel(tab1, text='test label')
label1.grid(row = 0, column = 0)
label2 = ctk.CTkLabel(tab2, text='test label')
label2.grid(row = 0, column = 0)
app.mainloop()
When I'm changing name of not active tab, everything works well. But if i try to change name of opened tab, the button on top stops being blue and after i try to change tab i get same KeyError. ('3' on image should be blue)
I've managed to avoid error by adding bottom 2 lines to rename function of CTkTabview:
def rename(self, old_name: str, new_name: str):
if new_name in self._name_list:
raise ValueError(f"new_name '{new_name}' already exists")
# segmented button
old_index = self._segmented_button.index(old_name)
self._segmented_button.delete(old_name)
self._segmented_button.insert(old_index, new_name)
# name list
self._name_list.remove(old_name)
self._name_list.append(new_name)
# tab dictionary
self._tab_dict[new_name] = self._tab_dict.pop(old_name)
# changing current tab name
if old_name == self._current_name:
self._current_name = new_name
But it still doesn't work fully as intended
Hi,
I've noticed that you cannot change a name of currently opened tab of CTkTabview by rename function. It responds with errors:
_
_
Although its not severe issue, couse one can still change name when tab is inactive