I'm trying to run this function as long as entry is 1 or 2. but after the first valid input (1 or 2) the second one doesn't do anything and seems to get stuck in the loop
(the function prints the chosen file name + the input number)
from tkinter import Tk
from tkinter.filedialog import askopenfilename
Tk().withdraw() # there's no need to open the full GUI
def my_filebrowser(command):
filename = askopenfilename()
print(filename, command)
while True:
command = int(input('enter command: '))
if command == 1:
my_filebrowser(command)
elif command == 2:
my_filebrowser(command)
else:
break
how should I change the code in order to use the tkinter file browser (askopenfilename() function) multiple times?