def open_file():
my_text.delete("1.0", END)
#get filename
text_file = filedialog.askopenfilename(initialdir="C:/", title="Open File", filetyßes=(("Text Files", "*.txt")))
Ich habe ein Tutorial auf YouTube nachgemacht um einen Text Editor zu erstellen.
Ich bin momentan bei der Funktion um Datein zu öffnen.
Also funktioniert bisher, außer es kommt beim öffnen immer ein Fehler der aber laut dem Py Terminal diese Zeile ist
text_file = filedialog.askopenfilename(initialdir="C:/", title="Open File", filetypes=(("Text Files", "*.txt")))
Kann mir jemand sagen was an dieser Zeile falsch ist?
Hier mal den Console Log
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\xyz\AppData\Local\Programs\Python\Python37\lib\tkinter\__init__.py", line 1705, in __call__
return self.func(*args)
File "C:\xyz\editor.py", line 16, in open_file
text_file = filedialog.askopenfilename(initialdir="C:/Benutzer", title="Open File", filetypes=(("Text Files", "*.txt")))
)))
File "C:\xyz\AppData\Local\Programs\Python\Python37\lib\tkinter\filedialog.py", line 375, in askopenfilename
return Open(**options).show()
File "C:\xyz\AppData\Local\Programs\Python\Python37\lib\tkinter\commondialog.py", line 43, in show
s = w.tk.call(self.command, *w._options(self.options))
_tkinter.TclError: bad file type "*.txt", should be "typeName {extension ?extensions ...?} ?{macType ?macTypes ...?}?"