so for my Pygame project where I have to make a Paint program, I want it so that the user can save the canvas to wherever they want on their Hard Drive.
I have it set up as:
cover = canvas.copy()
if saveRect.collidepoint(sp()):
if mb[0] == 1:
image.save(cover,"Untitled 1.png")
However, how do I make it so that the user can choose the exact location and file name in the Windows Explorer?
You could use tkFileDialog of tkinter .
You can use tkinter.filedialog.asksaveasfilename in python 3 like this:
win = tkinter.Tk()
win.withdraw()
name = asksaveasfilename(filetypes=[('Png files', '*.png'), ('Bmp files', '*.bmp')], defaultextension=('Png files', '*.png'))
win.destroy()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.