Tkinter filedialog issue

I have the following code that is returning some odd errors:

import tkinter
from tkinter import filedialog

root = tkinter.Tk()
root.withdraw() #use to hide tkinter window

def search_for_file_path ():
    currdir = "I:/_From_Goobi"
    tempdir = filedialog.askdirectory(parent=root, initialdir=currdir, title='Please select a directory')
    if len(tempdir) > 0:
        print ("\nYou chose: %s\n" % tempdir)
    return tempdir
2023-11-03 17:12:04,531 INFO  - Completed loading classifications from database
2023-11-03 17:12:04,532 INFO  - Unable to monitor for Configuration updates because the endpoint service is not currently serving them (The system cannot find the file specified (0x80070002))
2023-11-03 17:12:04,532 ERROR - Monitor initialization failed with error 80070002 (1). Automatic configuration updates will not be received
2023-11-03 17:12:05,060 ERROR - 14364 Unable to get icon for location (The operation completed successfully.): I:\_From_Goobi\2022_063RR_001-TurbulentOcean
2023-11-03 17:12:05,061 ERROR - 24692 Unable to get icon for location (The operation completed successfully.): I:\_From_Goobi\AKDC
2023-11-03 17:12:05,061 ERROR - 25424 Unable to get icon for location (The operation completed successfully.): I:\_From_Goobi\theses
2023-11-03 17:12:05,062 ERROR - 25424 Unable to get icon for location (The operation completed successfully.): I:\_From_Goobi\Retro
2023-11-03 17:12:06,480 ERROR - 25424 Unable to get icon for location (The operation completed successfully.): I:\_From_Goobi\AKDC\AKDC_2023_001RR_001
2023-11-03 17:12:06,480 ERROR - 24692 Unable to get icon for location (The operation completed successfully.): I:\_From_Goobi\AKDC\AKDC_2023_001RR_002

You chose: I:/_From_Goobi/AKDC

It looks to be having an issue getting the icon from whatever directory I am in. However it does get past this and continue to run the code after it. So it’s more of a pain to have the messages come up every time it runs versus actually not running the script.

Another weird thing is it didn’t happen on my old computer running Win 10, but it does on this new one running Win 11.

If I try a Google search on the “0x80070002” all I get is hits about Windows Update errors.

I am pretty sure that these messages are from Window or the Goobi document software and have nothing to do with tkinter. What happens if you pass initialdir = "C:/"?

I changed the above to just C:\ but still got the same results, just now referencing the folders and files on C:\

1 Like

Perhaps this is an incompatibility between Win11 and the tk functions involved. You could try running your code with a debugger or putting debugging prints in filedialog to see which line(s) result in messages.

I have been having this same issue lately, but I am on Windows 10. Any time tkinter opens a dialog box, I get output very similar to yours.

I have had no luck in even suppressing the messages. Messing with warning or loggers has no effect.