I'm playing around with Tkinter and it works while I am asking just one input after another. Like 'askopenfilename'. But getting many pop-ups isn't so comfy. I would like to build just one Frame to take all inputs at once.
And so far what I found is just the Frame with buttons (from some tutorials) to ask FileName or Directory, but I can't manage to be able to read the users choice.
import Tkinter, Tkconstants, tkFileDialog
class TkFileDialogExample(Tkinter.Frame):
def __init__(self, root):
Tkinter.Frame.__init__(self, root)
# define buttons
Tkinter.Button(self, text='askopenfilename', command=self.askopenfilename).pack()
Tkinter.Button(self, text='askdirectory', command=self.askdirectory).pack()
def askopenfilename(self):
return tkFileDialog.askopenfilename()
def askdirectory(self):
return tkFileDialog.askdirectory()
if __name__=='__main__':
root = Tkinter.Tk()
TkFileDialogExample(root).pack()
root.mainloop()
And that just builds the frame whith which I am ok, but it loops non stop and I am not able to get what the user have choosen. I have thought maybe I simply could get the value that comes with a function (since it is return) of a button?
Should I necessary have to create an empty list, array, dic to store the values of functions like suggested here: Returning a value after calling a function with a button in Tkinter, which I haven't tried yet...
Or is there other way, just to read it 'from the Buttons'?