Python Forum
Can you help me to understand the "asksaveasfile" and "askopenfilename" functions?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Can you help me to understand the "asksaveasfile" and "askopenfilename" functions?
#5
(May-21-2020, 10:59 PM)menator01 Wrote: Here is a link with example
https://stonesoupprogramming.com/2018/03...le-dialog/

the examples are very clear in that web site, but it doesn't help me to reach my goal. I already explained what I want to do in my last reply:

    def __Save(self):
        # this code creates a file excel named "final_document.xlsx" in the same directory where I run the script.
        # how can I integrate this kind of code with "filedialog.asksaveasfile()" function? what I want is first
        # creating the excel file in RAM (without give a specific location) and then, save it where I want and with 
        # the name that I want, using "filedialog.asksaveasfile()" function. the save process must be done via GUI!  
        # how can I reach my goal?
        #
        # wb = xw.Workbook("final_document.xlsx")
        # ws = wb.add_worksheet("RESULT")
        # ws.write(0, 0, self.first_word)
        # ws.write(0, 1, self.second_word)
        # wb.close()
        #

I understood the "askopenfilename" function but I still don't understand how to save a file already created by my code. my goal is take two or more files with "askopenfilename" function and use a button widget to activate my code (read the input files and create a new file, in my example a file excel). when this process is completed, somthing like "asksaveasfile" function has to ask to the user where to save the new file. from what I understood "asksaveasfile" returns a new file in write mode, but it's not what I want to do. what I want to do is very similar to when you write a word document. when you finished to write, you have to save the document in a directory, and Word asks to you "where do you wanna save your document just written?"
Reply


Messages In This Thread
RE: Can you help me to understand the "asksaveasfile" and "askopenfilename" functions? - by aquerci - May-23-2020, 12:11 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] Unable to save filepath to config.ini file using filedialog.askopenfilename JackMack118 10 4,898 Dec-29-2019, 08:12 PM
Last Post: JackMack118

Forum Jump:

User Panel Messages

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