Soundwave
Soundwave

Reputation: 625

Clicking on ANY button calls a method without unbinding other functions

I am using Tkinter and Python3.

In my application there are multiple buttons, that are calling their own functions.

Now I would like to add a function, that gets called by clicking on any button, without unbinding the functions specific to the button itself.

What I am trying to do is:

Multiple buttons have their own function:

**Button1** calls **function A**
**Button2** calls **function B**
**Button3** calls **function C**

Whenever ANY button is called, ONLY Function D is called, a timer of 10 minutes is set, and when any button is called now, it calls his own function.

Upvotes: 0

Views: 30

Answers (1)

rzzzwilson
rzzzwilson

Reputation: 141

The simplest way is to have all three buttons call the one function, with all the state and logic contained within that one function. Each time any button is pressed the state determines whether that press event calls function D or the appropriate function for the button pressed (A, B or C).

If you cannot arrange that then just make functions A, B and C do nothing but call function D, which arranges to execute the D code or A, B or C code depending on the state.

Upvotes: 1

Related Questions