当我尝试在“文件保存”对话框中保存文件时,我需要检查是否存在相同的文件。如果有, 它不应该允许我这样做并迫使我改变名称。我怎么能在WxPython中做到这一点?
提前致谢。
这是我的保存代码:
#Dosya tipi filtreleri
wildcard = "BENGI files (*.bengi)|*.bengi|" \
"SQLITE file (*.sdb)|*.sdb|" \
"All files (*.*)|*.*"
dlg = wx.FileDialog(
self, message="Save file as ...", defaultDir=DesktopPath,
defaultFile="_nokta_listesi", wildcard=wildcard, style=wx.SAVE
)
# Varsayılan dosya tipi filtresi
dlg.SetFilterIndex(0)
# Show the dialog and retrieve the user response. If it is the OK response,
# process the data.
if dlg.ShowModal() == wx.ID_OK:
path = dlg.GetPath()
# Create a database in disk
con=apsw.Connection(path)
# Copy from memory to disk
with con.backup("main", self.conn2, "main") as backup:
backup.step() # copy whole database in one go
con.close(True)
dlg.Destroy()
答案 0 :(得分:2)
<强>解决:强>
我在样式中添加了“wx.OVERWRITE_PROMPT”标志。