Skip to content

Commit ab70de5

Browse files
committed
Fix tutorial dragging
1 parent 26e1631 commit ab70de5

File tree

2 files changed

+59
-7
lines changed

2 files changed

+59
-7
lines changed

ltk/widgets.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1450,13 +1450,10 @@ def __init__(self, widget, buttons, content):
14501450
Div.__init__(self, buttons, content)
14511451
self.content = content
14521452
self.widget = widget
1453-
self.draggable({
1454-
"drag": proxy(lambda *args: (
1455-
find(".leader-line").remove(),
1456-
schedule(self.show_arrow, "ltk-step-draw-arrow", 0.1)
1457-
)),
1458-
})
1459-
1453+
self.draggable()
1454+
self.draggable("option", "drag", proxy(lambda *args: (
1455+
schedule(self.show_arrow, "ltk-step-draw-arrow")
1456+
)))
14601457
self.on("mouseenter", proxy(lambda event: self.show_arrow()))
14611458

14621459
def show(self):

tutorial.html

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<title>LTK on MicroPython</title>
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=device-width,initial-scale=1">
7+
8+
<link rel="stylesheet" href="https://pyscript.net/releases/2024.10.2/core.css">
9+
<script type="module" src="https://pyscript.net/releases/2024.10.2/core.js"></script>
10+
11+
<script src="https://code.jquery.com/jquery-3.6.0.js"></script>
12+
<script src="https://code.jquery.com/ui/1.13.2/jquery-ui.js"></script>
13+
<script src=" https://cdnjs.cloudflare.com/ajax/libs/leader-line/1.0.3/leader-line.min.js"></script>
14+
<link rel="stylesheet" href="https://code.jquery.com/ui/1.13.2/themes/base/jquery-ui.css">
15+
</head>
16+
<body>
17+
<py-config>
18+
[files]
19+
"ltk/jquery.py" = "ltk/jquery.py"
20+
"ltk/widgets.py" = "ltk/widgets.py"
21+
"ltk/pubsub.py" = "ltk/pubsub.py"
22+
"ltk/__init__.py" = "ltk/__init__.py"
23+
"ltk/logger.py" = "ltk/logger.py"
24+
"ltk/ltk.js" = "ltk/ltk.js"
25+
"ltk/ltk.css" = "ltk/ltk.css"
26+
</py-config>
27+
28+
<script type="py">
29+
import ltk
30+
31+
def show_tutorial():
32+
print("show tutorial")
33+
try:
34+
ltk.Tutorial([
35+
(
36+
"#show-button",
37+
"click",
38+
ltk.Preformatted("This is an LTK Tutorial").css("font-size", "2em"),
39+
)
40+
]).run()
41+
except Exception as e:
42+
print(e)
43+
44+
(
45+
ltk.VBox(
46+
ltk.Text("Tutorial Demo"),
47+
ltk.Button("Show the tutorial", lambda event: show_tutorial())
48+
.attr("id", "show-button")
49+
)
50+
.appendTo(ltk.window.document.body)
51+
)
52+
</script>
53+
54+
</body>
55+
</html>

0 commit comments

Comments
 (0)