|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
我建立一个filesavebox 然后 filetypes =["*.txt","*.py"] 如图 选项也出现了文件类型选择界面,但是选择txt格式保存 还是普通文件格式 求大佬带带小弟
附上代码:
- def WarnWindows():
- if text_old !=text_new[:-1]:
- choice = g.buttonbox("检测到文件内容发生改变,请选择以下操作:", "警告", ("覆盖保存", "放弃保存", "另存为..."))
- if choice =="覆盖保存":
- f=open(textAdd,"w")
- f.write(text_new)
- g.msgbox("保存完毕")
- if choice =="放弃保存":
- choices=g.ccbox("确定放弃吗?", "警告",choices=["确定","取消"])
- print(choices)
- if choices==1:
- exit()
- elif choices==0:
- WarnWindows()
-
- if choice == "另存为...":
- saveAdd= g.filesavebox("选择你的保存路径","保存", default="D:/",filetypes=["*.txt","*.py"])
- # f=open(saveAdd+".txt","w")
- f=open(saveAdd,"w")
- f.write(text_new)
- g.msgbox("保存完毕")
-
- WarnWindows()
- f.close()
复制代码
就是不会加到文件的名字中
g.filesavebox(...,...,..., filetype = "*.txt, *.py") 你写的
但内部是 filetype = filetype,传入的只有 filename
|
|