Python Forum
[Tkinter] filedialog, open a file error
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] filedialog, open a file error
#3
Gee...Thx ! I'm still begginer so i miss things that are so obvious

def openFile():
    filepath = filedialog.askopenfilename(initialdir="C:\\Test",
                                          title="Open file okay?",
                                          filetypes=(("text files", "*.txt"),
                                          ("all files", "*.*")))
    if len(filepath) == 0:
        return

    file = open(filepath, 'r')
    print(file.read())
    file.close()
Reply


Messages In This Thread
filedialog, open a file error - by liketocode - Dec-07-2022, 07:55 PM
RE: filedialog, open a file error - by deanhystad - Dec-07-2022, 08:18 PM
RE: filedialog, open a file error - by liketocode - Dec-07-2022, 09:19 PM
RE: filedialog, open a file error - by deanhystad - Dec-07-2022, 09:24 PM
RE: filedialog, open a file error - by liketocode - Dec-07-2022, 10:51 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] Exclude hidden file, filedialog.askopenfile red380sl 1 3,225 Dec-01-2020, 07:04 PM
Last Post: DT2000
  [Tkinter] How do I open a file and the plot it? HelixFossil 3 3,639 Apr-16-2020, 03:50 AM
Last Post: HelixFossil
  [PyQt] saving text file by FileDialog option atlass218 14 4,816 Feb-19-2020, 09:22 AM
Last Post: atlass218
  [Tkinter] Unable to save filepath to config.ini file using filedialog.askopenfilename JackMack118 10 5,149 Dec-29-2019, 08:12 PM
Last Post: JackMack118
  [PyQt] I get the error when I try to open the sample Why can pyqt5 installed onatdogan 3 3,159 Dec-25-2018, 03:00 PM
Last Post: Larz60+
  [PyQt] QFSFileEngine::open: No file name specified MegasXLR 1 4,084 May-25-2018, 04:06 PM
Last Post: MegasXLR
  tkinter filedialog and pickle - custom icon question. kim07133 0 2,807 Jan-08-2018, 12:10 PM
Last Post: kim07133
  [Tkinter] filedialog. FULL SCREEN issac_n 0 3,195 Dec-05-2017, 07:33 AM
Last Post: issac_n

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020