just a little feedback with your script. You really don’t need the following line since you already have imported tkinter as tk.
from tkinter import filedialog
Just prefix filedialog with tk wherever it is used and you should be fine. You’re already doing this with other tkinter names so it is not a stretch.
I also noticed that you have created two variables (a global and a local) with the same name. Although there shouldn’t by any name collision, you should still think of naming variables with distinct names. The variable in question is fenster.
>>> import tkinter as tk
>>> tk.filedialog
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
tk.filedialog
AttributeError: module 'tkinter' has no attribute 'filedialog'
>>>
Importing a module does not automatically import submodules, and tkinter does not do so. Importing a submodule does add its name to the module, but then the prefix is not needed.
>>> from tkinter import filedialog
>>> tk.filedialog
<module 'tkinter.filedialog' from 'C:\\Programs\\Python314\\Lib\\tkinter\\filedialog.py'>