diff options
author | mike <michael.jmontcalm@gmail.com> | 2009-02-25 14:08:23 (GMT) |
---|---|---|
committer | mike <michael.jmontcalm@gmail.com> | 2009-02-25 14:08:23 (GMT) |
commit | 8d2fb3bad1ccf6866d69ecb251d7df6773930c7b (patch) | |
tree | de2f3b2e9547a13de5ad2b39a04d478bba62c12d | |
parent | 4c71b8de0511a87c0cbcc9d0061b5c8a01ea4b80 (diff) |
Tutorius v1: Adding stub for Executor
-rw-r--r-- | src/sugar/tutorius/tutorial.py | 55 |
1 files changed, 54 insertions, 1 deletions
diff --git a/src/sugar/tutorius/tutorial.py b/src/sugar/tutorius/tutorial.py index fc1d8ae..8c457ae 100644 --- a/src/sugar/tutorius/tutorial.py +++ b/src/sugar/tutorius/tutorial.py @@ -160,6 +160,40 @@ class Tutorial (object): continue +############################################################################### +# +# Object oriented model for the FSM +# + +class Action: + """Represents an action to take when entering a state. An action might be + show a dialog to the user, or to play a sound. + + The do() executes the interaction, while the undo() must clean up + everything. """ + def __init__(self): + self.name = "Default Action" + + def do(self): + logging.debug("Doing default action") + + def undo(self): + logging.debug("Undoing default action") + +class DialogAction(Action): + """This is a pop-up dialog that displays a short text to the user.""" + def __init__(self, label, posX, posY): + self.name = "Dialog Action" + self.label = label + self.pos = [posX, posY] + + def do(self): + self.dialog = TutoriusDialog(label) + self.dialog.move(self.pos[0], self,pos[1]) + + def undo(self): + self.dialog.destroy() + class State: """This is a step in a tutorial. The state represents a collection of actions to undertake when entering the state, and a description of an @@ -223,4 +257,23 @@ class FiniteStateMachine(State): act.undo def verify(self): - return self.current_state.verify()
\ No newline at end of file + return self.current_state.verify() + + +class Executor: + """This is a class that executes a tutorial graph, meaning that it handles + the creation and deletion of states, as well as handling the transitions + between the various states.""" + + def __init__(self): + self.current_state = None + + + def start(self, fsm): + if self.current_state == None: + self.current_state = fsm + + self.current_state.install_handlers() + self.current_state.setup() + +
\ No newline at end of file |