I need to check if the same file exists when I try to save a file in File Save Dialog. İf it does,
it shouldnt allow me to do it and force me to change the name. How can I do this in WxPython?
Thanks in advance.
Here is my save code:
#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()
SOLVED:
I added “wx.OVERWRITE_PROMPT” flag to the style.