The program I am writing can edit a single project at a time. This means that opening a new file/project implies closing the previous one. Now what I want to achieve is the following workflow:
- User has uncommitted changes to a project he never previously saved, so the project doesn't have a file name yet.
- User presses "open saved project".
- A dialogue "A" pops up and says: "Your current project has uncommitted changes, what would you like to do? Abort new project operation, discard changes to current project, or save them?".
- User selects "save" dialogue.
- Dialogue A closes.
- Dialogue B1 (file chooser configured for save operation) pops up.
- User select file name for project to save.
- Dialogue B1 closes, project gets saved.
- Dialogue B2 (same file chooser but configured for load operation) pops up.
- User select file to open.
- Dialogue B2 closes, project is loaded.
So really, in the above example steps 3 to 8 are a sort of "interruption" in the obvious workflow of opening a saved project, so when dialogue A and B1 open, the obvious workflow is halted, and it is resumed when those dialogue get responded.
My question is: how to implement this mechanism of halting/resuming the normal flow of operation? So far the way I implemented it is via a stack on which - any time I open a popup dialogue - I push the "resume-from-here callback", and any time I respond I pop the callback from.
...yet it seems as mine is a very common scenario for which there should 开发者_开发百科be an easier method (maybe a specific function of PyGTK!).
Many thanks in advance for your help/time!
Would GtkDialog.run()
be the method you need? You "run" the dialog, at the point where you need to ask the user, and when it returns you have your answer.
精彩评论