I have a piece of code that gives me a bit of trouble. When I run it, I expect it to run the filedialog.askopenfilename only. However it also opens a small Tk window on the top-left corner of the screen. I am not sure why since there is nothing in my code (that I know of) calling for such Tk window.
Could you explain this for me?
from getpass import getuser
from sys import platform
from tkinter import filedialog
import os
userID = getuser()
try:
if platform == "linux" or platform == "linux2":
userpath = os.path.join("/", "home", userID, "Checklist_PDFs")
print(userpath)
filedialog.askopenfilename(initialdir=userpath, title="Select a file")
elif platform == "darwin":
userpath = os.path.join("/", "home", userID, "Checklist_PDFs")
print(userpath)
elif platform == "win32":
userpath = os.path.join("c:", "\\", "Users", userID, "My Documents", "Checklist_PDFs")
print(userpath)
except:
print("My note: cannot execute")