From 8d2fb3bad1ccf6866d69ecb251d7df6773930c7b Mon Sep 17 00:00:00 2001 From: mike Date: Wed, 25 Feb 2009 14:08:23 +0000 Subject: Tutorius v1: Adding stub for Executor --- 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 -- cgit v0.9.1