Skip to content
Advertisement

How to use input/command from selected button tkinter python

This may be tricky but I’ll try to put it clear. i have created two buttons, 1st button search folder and select individual filename as input, 2nd button select folder and take its directory as input and read all its files inside.

I want to create 3rd button(Execute) where it should know which button i selected and based on that it needs to do execute function.

Now,

JavaScript

My intention is to keep the same button to execute button for both the folder_selected and select_individual_file, but the execute button have to identify which input to take by writing the condition or something. Please help.

Advertisement

Answer

You can simply use single global variable and use os.path.isdir() and os.path.isfile() to check whether a folder or a file is selected:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement