#!/bin/python3 # Tom Trebisky 9-29-2021 # Just an experiment to see if I can make a simple file # open dialog -- and I can! # Best of all, it works perfectly without any fiddling # on windows, which is exactly what we hope for with Python. import tkinter as tk from tkinter import filedialog root = tk.Tk() root.withdraw() file_path = filedialog.askopenfilename() print ( file_path )
Apparently tkinter comes already installed with a Windows install of python. The official word is that tkinter is just part of the Python distribution on Windows, which is both surprising and pleasing.
Also note that tkinter is the name you use with Python 3, whereas with Python 2 you would have used Tkinter. If nothing else this is a quick way to glance at somebody elses script and determine if it is Python 2 or 3.
git pull python opener.pyIt works! I find this surprising (and nice).
I am curious about the exact nature of tkinter in the Python world. I have read misinformation that tkinter drags in Tcl and Tk under the hood. Maybe this was true long ago, but at this point tkiner is a standard part of the python interpreter with no Tcl in sight! I am not clear if and how it shadows Tk development in the Tcl world or whether it has forked in its own direction. By and large I don't deeply care, but am glad that Tcl is not lurking anywhere.
Tom's Mineralogy Info / [email protected]