开发者

How to resume program workflow at the right place after dialogue response?

开发者 https://www.devze.com 2023-03-15 22:56 出处:网络
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:

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:

  1. User has uncommitted changes to a project he never previously saved, so the project doesn't have a file name yet.
  2. User presses "open saved project".
  3. 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?".
  4. User selects "save" dialogue.
  5. Dialogue A closes.
  6. Dialogue B1 (file chooser configured for save operation) pops up.
  7. User select file name for project to save.
  8. Dialogue B1 closes, project gets saved.
  9. Dialogue B2 (same file chooser but configured for load operation) pops up.
  10. User select file to open.
  11. 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号