Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9233309
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:31:24+00:00 2026-06-18T06:31:24+00:00

I have a saving routine that should prompt the user in the following way:

  • 0

I have a saving routine that should prompt the user in the following way:

  • If the currently selected file name exists, prompt for overwrite
  • If the currently selected file name is empty (i.e. “”), set up a dialog to ask user to insert file name
  • If the currently selected file name does not exist, save it!

My code is currently like below, but I feel like there should be a better way of doing this. As it is now the user is prompted with a dialog with choices “Yes, No, Cancel”, but I would want it to be “Yes, Save as, Cancel”. I really could not find any way to change the “No” button to a “Save as” button that opens a dialog where the user can insert the wanted file name. Any suggestions of improving this?

def saveProject(window):

if os.path.exists(window.getGlobalSettings().getCurrentFileName()): #File exists from before   
    dlg = wx.MessageDialog(window,
                "Overwrite existing project file " + window.getGlobalSettings().getCurrentFileName() + "?",
                "Overwrite existing project file",
                wx.SAVE|wx.CANCEL|wx.ICON_QUESTION)

    result = dlg.ShowModal()
    dlg.Destroy()

    if result == wx.ID_YES:
        save(window,currentFileName)
        return True
    elif result == wx.ID_SAVEAS:
        #TODO: do shit here
        return False
    elif result == wx.ID_NO:
        return False
    elif result == wx.ID_CANCEL:
        return False

elif window.getGlobalSettings().getCurrentFileName == "":
    #TODO: do shit here
    return False

else:
    save(window,window.getGlobalSettings().getCurrentFileName())
    return True

UPDATE

The code was successfully changed to:

def saveProject(window):

dlg = wx.FileDialog(window, "Save project as...", os.getcwd(), "", "*.kfxproject", \
                    wx.SAVE|wx.OVERWRITE_PROMPT)
result = dlg.ShowModal()
inFile = dlg.GetPath()
dlg.Destroy()

if result == wx.ID_OK:          #Save button was pressed
    save(window,inFile)
    return True
elif result == wx.ID_CANCEL:    #Either the cancel button was pressed or the window was closed
    return False
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T06:31:25+00:00Added an answer on June 18, 2026 at 6:31 am

    You’re using the wrong dialog type. Use FileDialog instead:

    • It already includes the “prompt for a confirmation if a file will be overwritten” feature with wx.FD_OVERWRITE_PROMPT
    • That’s what everyone else uses so users will expect this kind of dialog and be confused when they get something else

    I couldn’t find a way to replace “Save” with “Save as” in the dialog (it just has wx.FD_SAVE) but most people won’t notice that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem with saving the path in doctrine from a file upload.
I have a C# object that I am saving to RavenRB (build 1.0.960), the
I have seen two different approaches in saving user preferences. APPROACH 1: Serializing them
I am maintaining an old system that have saving issue when a string contains
Currently, I have a link to a powerpoint file and when you click the
I have a routine procedure DrawStuff(ACanvas: TCanvas; const ARect: TRect) that draws something to
I have the following inline code that I can't change due is outputted by
I am saving out and loading mixed data types. I either have the saving
Hi I have a problem saving 2 tables of my database at the same
I am using CakePHP framework with MySQL database and I have problem in saving

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.