CustomTkinter
CustomTkinter copied to clipboard
Feature request: disable/active tab of CTkTabview
It would be useful to be able disable/enable state tab(s) of CTkTabview:
import tkinter as tk
import customtkinter
tabview = customtkinter.CTkTabview(master=master, state=tk.ACTIVE)
tabview.grid(column=0, row=0)
tabview.add('Tab1')
tabview.add('Tab2')
tabview.tab("Tab2").configure(state=tk.DISABLED)
Result:
File "D:\dcspy_dev\venv\lib\site-packages\customtkinter\windows\widgets\ctk_frame.py", line 167, in configure
super().configure(require_redraw=require_redraw, **kwargs)
File "D:\dcspy_dev\venv\lib\site-packages\customtkinter\windows\widgets\core_widget_classes\ctk_base_class.py", line 135, in configure
check_kwargs_empty(kwargs, raise_error=True)
File "D:\dcspy_dev\venv\lib\site-packages\customtkinter\windows\widgets\utility\utility_functions.py", line 18, in check_kwargs_empty
raise ValueError(f"{list(kwargs_dict.keys())} are not supported arguments. Look at the documentation for supported arguments.")
ValueError: ['state'] are not supported arguments. Look at the documentation for supported arguments.
I have never use state
on tabview, but on button, entry and slider.
I didn't wrote state = tk.ACTIVE
I wrote state = "disabled"
(for disable) or state = "normal"
(for enable) and it worked.
So try for enable:
tabview.configure(state="normal")
and for disable;
tabview.configure(state="disabled")
You might have to change the color manually if you want different colors.
I want disable only one tab from CTkTabview
not whole CTkTabview
widget...
This working perfectly ok: tabview.configure(state="disabled") tabview.configure(state=tk.DISABLED)
Anyway, from tkinter\constants.py
:
...
DISABLED='disabled'
...
state = "disabled"
== state = tk.DISABLED
they are exactly same thing....
@emcek, now you can do that only through access to the protected variables. In your case the solution is:
tabview._segmented_button._buttons_dict["Tab2"].configure(state=customtkinter.DISABLED)
@TomSchimansky, it would be nice to add method that allows to do that legally
@emcek, now you can do that only through access to the protected variables. In your case the solution is:
tabview._segmented_button._buttons_dict["Tab2"].configure(state=customtkinter.DISABLED)
@TomSchimansky, it would be nice to add method that allows to do that legally
It is a pity that I came after many years and this feature is not available yet. Also this feature should be in "segmentedbutton". https://customtkinter.tomschimansky.com/documentation/widgets/segmentedbutton