Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trouble getting started #51

Closed
stuaxo opened this issue Dec 16, 2015 · 3 comments
Closed

Trouble getting started #51

stuaxo opened this issue Dec 16, 2015 · 3 comments

Comments

@stuaxo
Copy link

stuaxo commented Dec 16, 2015

from transitions import Machine

states = [
    "leaderboard",
    "chapter_teaser"
    "chapter_chosen",
    "adding_to_leaderboard"
]

transitions = [
    { 'trigger': 'advance', 'source': 'leaderboard', 'dest': 'chapter_teaser' },
    { 'trigger': 'advance', 'source': 'chapter_teaser', 'dest': 'chapter_chosen' },
    { 'trigger': 'advance', 'source': 'chapter_chosen', 'dest': 'adding_to_leaderboard' },
    { 'trigger': 'advance', 'source': 'adding_to_leaderboard', 'dest': 'leaderboard' }
]

class LeaderBoardDisplay(object):
    pass

leaderboard = LeaderBoardDisplay()

machine = Machine(leaderboard, states=states, transitions=transitions, initial='leaderboard')

I've been trying to use the state machine above, but can't work out the method to go to the next state.

Also, machine.anything_at_all returns None, instead of an exception.

@tyarkoni
Copy link
Member

You're missing a comma after "chapter_teaser" in the states. Adding that should fix it.

@tyarkoni
Copy link
Member

Oh, and you would go to the next state by calling the appropriate trigger; in your case, the trigger is advance() for all transitions, so leaderboard.advance().

@stuaxo
Copy link
Author

stuaxo commented Dec 18, 2015

Cheers :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants