how do you put 2 functions into a tkinter button


I don't think you can put two functions to be triggered in a tkinter button; however, you could use a helper function that executes several other functions:

def handle_button_command():

def Store_SQLite():

def do_also_that():

button = Button(window1, text="Create", command=handle_button_command)
  • 1
    Possibly use a lambda for this? – Daniel Nov 24 '17 at 8:37
  • 4
    Possibly - I find the helper more readable though - matter of taste. – Reblochon Masque Nov 24 '17 at 8:38
  • 2
    @Coal_: functions are nearly always better than using lambda. – Bryan Oakley Nov 24 '17 at 13:46

You could also go like:

Button(command=lambda : [some_function(), some_other_function(), some_another_function()])

be mindful that their order do matter. I'd also rather use a handle function like in Reblochon Masque's answer though.

  • 3
    I think this would be a terrible solution. The right solution is to create a proper function, and call that function from a button. That function can then call as many other functions as it wants. Trying to crowd a bunch of code into a lambda creates code that is hard to understand, hard to debug, and hard to maintain. – Bryan Oakley Nov 24 '17 at 13:45
