Python Forum
[Tkinter] Unable to save filepath to config.ini file using filedialog.askopenfilename
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Unable to save filepath to config.ini file using filedialog.askopenfilename
#11
I got it! Here is what's working for me:

    def kw_txt1(self):    
        kwTXT1 = filedialog.askopenfilename(filetypes =[('Text File', '*.txt')])
        config = ConfigParser()
        config.read('config.ini')  
        print(kwTXT1)
        with open('config.ini', "w") as file_obj:
            config.set('Keyword Files', 'kwA', kwTXT1)
            config.write(file_obj)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] [split] I want to add a code to the "Save" button to save the data entered LOO 1 1,884 Jan-23-2023, 05:31 PM
Last Post: deanhystad
  [Tkinter] filedialog, open a file error liketocode 4 3,231 Dec-07-2022, 10:51 PM
Last Post: liketocode
  [Tkinter] Exclude hidden file, filedialog.askopenfile red380sl 1 3,117 Dec-01-2020, 07:04 PM
Last Post: DT2000
  Can you help me to understand the "asksaveasfile" and "askopenfilename" functions? aquerci 4 4,197 May-23-2020, 12:11 AM
Last Post: aquerci
  [Tkinter] Unable to get current contents of the entry field where the content is the file path pmpinaki 1 2,193 Apr-18-2020, 06:45 PM
Last Post: deanhystad
  [PyQt] saving text file by FileDialog option atlass218 14 4,494 Feb-19-2020, 09:22 AM
Last Post: atlass218
  [Tkinter] HOW TO: Set [Label].config() by variable name reference? gazoxtapod 4 4,881 Apr-17-2019, 09:57 PM
Last Post: gazoxtapod
  Save image from Clipboard Linux / save Pixbuf format M_Schneider 1 2,812 May-04-2018, 04:38 PM
Last Post: woooee
  tkinter filedialog and pickle - custom icon question. kim07133 0 2,727 Jan-08-2018, 12:10 PM
Last Post: kim07133
  [Tkinter] filedialog. FULL SCREEN issac_n 0 3,113 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