繁体   English   中英

在 WxPython 的文件保存对话框中检查覆盖

[英]Check overwrite in File Save dialog in WxPython

当我尝试在文件保存对话框中保存文件时,我需要检查是否存在相同的文件。 如果确实如此,它不应该允许我这样做并强迫我更改名称。 我怎样才能在 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()

解决了:

我在样式中添加了“wx.OVERWRITE_PROMPT”标志。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM