is there any method to count how many times a function is called in python?
I’m using checkbutton in GUI. I have written a function for that checkbutton command, i need to perform some actions based on the checkbutton status, i mean based on whether it is ticked or not. My checkbutton and button syntax are like this
All = Checkbutton (text='All', command=Get_File_Name2,padx =48, justify = LEFT)
submit = Button (text='submit', command=execute_File,padx =48, justify = LEFT)
so i thougt of countin no. of times the command function is called, and based on its value i can decide whether it is ticked or not. please help
If checking whether the checkbutton is ticked or not is the only thing you need, why not just do
checkbutton.ticked = true?One way to implement this is to create a sub class out of Checkbutton (or – if you can – edit the existing Checkbutton class) and just add self.ticked attribute to it.
And edit your function so that it changes your CheckbuttonPlus -object’s ticked to
not ticked.I don’t know how your classes are constructed, but you should find the method from Checkbutton class that activates the function, and then overwrite it in CheckbuttonPlus -class (incase you cannot edit the existing Checkbutton class, in which case, you don’t even need CheckbuttonPlus class at all).
Edit: If you’re using Tkinter Checkbutton (looks quite like it), you might wanna check this:
Getting Tkinter Check Box State