Is there a way to bind a Function to a Tabview change in CustomTkinter?

43 views Asked by At

I was making a desktop application using customktinter library, and in that application i have used CTkTabview to make different tab for different functionality and i wanted a funtion to be fire when ever i change a tab like we can do it in tkinter using bind

I tried to use the bind() like we can in tkinter for notebook, but it does not work and i tried to see about this in the decumentation of customtkinter but there is nothing related to this init. So, i will be very thank full if someone could tell me a way to do this or if there is a way around it.

1

There are 1 answers

0
fastattack On BEST ANSWER

To call a function every time the CTkTabView tab is changed, you can use the command argument for CTkTabView.

During the creation you should add command=function_to_call without the parentheses at the end of the function name.

For example a CTkTabView with a command looks like:

tabview = customtkinter.CTkTabview(master, command=function_to_call)
tabview.add("first tab")
tabview.add("second tab")

And then if you want to known which tab is active in the tabview, you can use the tabview.get() method.

Hope I helped you, have a nice day.