[英]Choose Location of image.save in pygame
所以對於我必須制作一個畫圖程序的 Pygame 項目,我想要它,以便用戶可以將 canvas 保存到硬盤上他們想要的任何位置。
我將其設置為:
cover = canvas.copy()
if saveRect.collidepoint(sp()):
if mb[0] == 1:
image.save(cover,"Untitled 1.png")
但是,如何使用戶可以在 Windows Explorer 中選擇確切的位置和文件名?
您可以使用tkinter 的 tkFileDialog 。
您可以像這樣在 python 3 中使用 tkinter.filedialog.asksaveasfilename:
win = tkinter.Tk()
win.withdraw()
name = asksaveasfilename(filetypes=[('Png files', '*.png'), ('Bmp files', '*.bmp')], defaultextension=('Png files', '*.png'))
win.destroy()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.