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

Tutorial - Add initial and final actions #11

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions ltk/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1083,13 +1083,17 @@ def hide(self):
class Tutorial():
tag = None

def __init__(self, steps):
def __init__(self, steps, initial_action=None, final_action=None):
self.steps = steps
self.index = 0
self.current = None
self.steps = steps
self.initial_action = initial_action
self.final_action = final_action

def run(self):
if self.initial_action:
eval(self.initial_action)
self.index = 0
self.show()

Expand All @@ -1110,6 +1114,10 @@ def next(self):
self.index += 1
if self.index < len(self.steps):
self.show()
if self.index == len(self.steps)-1:
self.show()
if self.final_action:
eval(self.final_action)

def event(self, index):
if index == self.index:
Expand Down Expand Up @@ -1243,4 +1251,4 @@ def handle_keydown(event):
ltk.find('.btn').on(
"click",
ltk.proxy(lambda event: ltk.find(event.target).attr("id"))
)
)