Skip to content

Commit

Permalink
Add leader-line so that Tutorial works by default
Browse files Browse the repository at this point in the history
  • Loading branch information
laffra committed Dec 14, 2024
1 parent 418eb4b commit 26e1631
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 1 deletion.
3 changes: 3 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/6.65.7/mode/python/python.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/6.65.7/codemirror.min.css" >

<!-- Import for drawing arrows -->
<script defer src="leader-line.min.js"></script>

<!-- Import Styles for the kitchensink demo -->
<link rel="stylesheet" href="kitchensink.css">
</head>
Expand Down
1 change: 1 addition & 0 deletions kitchensink.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,4 @@ def activate_tab(event, ui=None):

def load():
logger.info("Kitchensink Ready")

2 changes: 2 additions & 0 deletions leader-line.min.js

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions ltk/ltk.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,22 @@
}
};

window.addArrow = (from, to, label) => {
try {
const start = from[0];
const end = to[0];
if (start && end) {
return $(new LeaderLine(start, end, {
dash: { },
size: 3,
middleLabel: LeaderLine.pathLabel(label || "")
})).appendTo($("body"));
}
} catch(e) {
// ignore
}
}

$.fn.isInViewport = function() {
const offset = $(this).offset();
if (!offset) return true
Expand Down
1 change: 1 addition & 0 deletions ltk/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1467,6 +1467,7 @@ def show(self):
self.appendTo(find("body"))
self.css(to_js({
"visibility": "visible",
"position": "absolute",
"opacity": 1,
"left": self.widget.offset().left + self.widget.outerWidth() + 100,
"top": self.widget.offset().top,
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "pyscript-ltk"
version = "0.2.18"
version = "0.2.19"
description = "A little toolkit for writing UIs in PyScript"
readme = "README.md"
authors = [{ name = "Chris Laffra", email = "chris@chrislaffra.com" }]
Expand Down

0 comments on commit 26e1631

Please sign in to comment.