Skip to content

Commit

Permalink
Fix tutorial dragging
Browse files Browse the repository at this point in the history
  • Loading branch information
laffra committed Dec 16, 2024
1 parent 26e1631 commit ab70de5
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 7 deletions.
11 changes: 4 additions & 7 deletions ltk/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1450,13 +1450,10 @@ def __init__(self, widget, buttons, content):
Div.__init__(self, buttons, content)
self.content = content
self.widget = widget
self.draggable({
"drag": proxy(lambda *args: (
find(".leader-line").remove(),
schedule(self.show_arrow, "ltk-step-draw-arrow", 0.1)
)),
})

self.draggable()
self.draggable("option", "drag", proxy(lambda *args: (
schedule(self.show_arrow, "ltk-step-draw-arrow")
)))
self.on("mouseenter", proxy(lambda event: self.show_arrow()))

def show(self):
Expand Down
55 changes: 55 additions & 0 deletions tutorial.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>LTK on MicroPython</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">

<link rel="stylesheet" href="https://pyscript.net/releases/2024.10.2/core.css">
<script type="module" src="https://pyscript.net/releases/2024.10.2/core.js"></script>

<script src="https://code.jquery.com/jquery-3.6.0.js"></script>
<script src="https://code.jquery.com/ui/1.13.2/jquery-ui.js"></script>
<script src=" https://cdnjs.cloudflare.com/ajax/libs/leader-line/1.0.3/leader-line.min.js"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.13.2/themes/base/jquery-ui.css">
</head>
<body>
<py-config>
[files]
"ltk/jquery.py" = "ltk/jquery.py"
"ltk/widgets.py" = "ltk/widgets.py"
"ltk/pubsub.py" = "ltk/pubsub.py"
"ltk/__init__.py" = "ltk/__init__.py"
"ltk/logger.py" = "ltk/logger.py"
"ltk/ltk.js" = "ltk/ltk.js"
"ltk/ltk.css" = "ltk/ltk.css"
</py-config>

<script type="py">
import ltk

def show_tutorial():
print("show tutorial")
try:
ltk.Tutorial([
(
"#show-button",
"click",
ltk.Preformatted("This is an LTK Tutorial").css("font-size", "2em"),
)
]).run()
except Exception as e:
print(e)

(
ltk.VBox(
ltk.Text("Tutorial Demo"),
ltk.Button("Show the tutorial", lambda event: show_tutorial())
.attr("id", "show-button")
)
.appendTo(ltk.window.document.body)
)
</script>

</body>
</html>

0 comments on commit ab70de5

Please sign in to comment.