Home > Enterprise >  How to make tkinter button call two different function depending on filetype?
How to make tkinter button call two different function depending on filetype?

Time:08-24

I have created file dialog window with tkinter and two different functions: one works with images, another with videos. How can I make tkinter button to call different functions when either of filetypes passed into file dialog.

CodePudding user response:

You can simply write a function that will check the extension and act accordigly:

def fun(filename):
    if filename.endswith(".txt"):
        fun_txt(filename)
    else:
        fun_doc(filename)
  • Related