I'm trying to write a simple Python Tkinter file chooser that is compatible both with Python2.7 and Python3.x
Python3 Version
from tkinter import Tk
from tkinter.filedialog import askopenfilename
root = Tk()
root.withdraw()
filename = askopenfilename(title="Select file")
root.update()
root.destroy()
Python2.7 Version
from Tkinter import Tk
from tkFileDialog import askopenfilename
root = Tk()
root.withdraw()
filename = askopenfilename(title="Select file")
root.update()
root.destroy()
How can I come up with a unified solution?