TomSchimansky / CustomTkinter

A modern and customizable python UI-library based on Tkinter
MIT License
10.99k stars 1.04k forks source link

Feature request: disable/active tab of CTkTabview #840

Open emcek opened 1 year ago

emcek commented 1 year ago

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.
Buldes commented 1 year ago

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.

emcek commented 1 year ago

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....

RobbieKhan commented 1 year ago

@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

becauseimnoob commented 4 months ago

@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