-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
202 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,31 @@ | ||
# LTK - Copyrights Reserved 2023 - chrislaffra.com - See LICENSE | ||
|
||
import inspect | ||
import ltk | ||
|
||
# Create a new widget, based on VBox | ||
class ImageWithLabel(ltk.VBox): | ||
classes = [ "custom" ] | ||
|
||
def __init__(self, src, label): | ||
ltk.VBox.__init__(self, | ||
# Add two widgets. Styling could be done in external CSS | ||
ltk.Image(src) | ||
# CSS selector would be ".custom .ltk-image" | ||
.css("width", 196), | ||
ltk.Text(label) | ||
# CSS selector would be ".custom .ltk-text" | ||
.css("width", "100%") | ||
.css("text-align", "center") | ||
) | ||
def create(): | ||
|
||
class CustomWidget(ltk.VBox): | ||
classes = [ "custom" ] | ||
|
||
def __init__(self, src, label): | ||
ltk.VBox.__init__(self, | ||
ltk.Image(src).css("width", 196), | ||
ltk.Text(label).css("width", "100%").css("text-align", "center") | ||
) | ||
self.element.css("border", "2px solid orange") | ||
|
||
def create(): | ||
# Create the custom widget and add an orange border for clarity | ||
custom_widget = ImageWithLabel( | ||
"https://chrislaffra.com/chris.png", | ||
"Chris laffra" | ||
).css("border", "2px solid orange") | ||
|
||
return ltk.VBox( | ||
ltk.H2("Showing a Card with a custom widget inside of it"), | ||
ltk.Card(custom_widget) | ||
.css("width", 200) | ||
.draggable(), | ||
ltk.Text("For clarity, we marked the custom widget orange.") | ||
.css("margin-top", 20), | ||
ltk.H4("Tip: drag the card."), | ||
ltk.Link(href="https://github.com/laffra/ltk/blob/main/examples/custom.py") | ||
.attr("target", "_blank") | ||
.text("source") | ||
).attr("name", "Custom") | ||
return ( | ||
ltk.VBox( | ||
ltk.H2("Showing a Card with a custom widget inside of it"), | ||
ltk.Card( | ||
CustomWidget("https://chrislaffra.com/chris.png", "Chris laffra") | ||
).css("width", 200).draggable(), | ||
ltk.Text("For clarity, we marked the custom widget orange.").css("margin-top", 20), | ||
ltk.H4("Tip: drag the card."), | ||
) | ||
.attr("name", "Custom") # example | ||
.attr("src", inspect.getsource(create)) # example | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,15 @@ | ||
# LTK - Copyrights Reserved 2023 - chrislaffra.com - See LICENSE | ||
|
||
import inspect | ||
import ltk | ||
|
||
|
||
def create(): | ||
return ( | ||
ltk.VBox( | ||
ltk.Text("Hello World 🎉") | ||
.css("padding", 100) | ||
.css("background-color", "orange") | ||
.css("font-size", 42), | ||
ltk.Link(href="https://github.com/laffra/ltk/blob/main/examples/helloworld.py") | ||
.attr("target", "_blank") | ||
.text("source") | ||
).attr("name", "Hello World") | ||
ltk.Text("Hello World 🎉") | ||
.css("padding", "100px 10px") | ||
.css("background-color", "orange") | ||
.css("font-size", 42) | ||
.attr("name", "Hello World") # example | ||
.attr("src", inspect.getsource(create)) # example | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,62 @@ | ||
# LTK - Copyrights Reserved 2023 - chrislaffra.com - See LICENSE | ||
|
||
from ltk.jquery import find | ||
from ltk.jquery import body | ||
from ltk.jquery import console | ||
from ltk.jquery import create | ||
from ltk.jquery import delete | ||
from ltk.jquery import document | ||
from ltk.jquery import find | ||
from ltk.jquery import find_list | ||
from ltk.jquery import time | ||
from ltk.jquery import number | ||
from ltk.jquery import schedule | ||
from ltk.jquery import repeat | ||
from ltk.jquery import repeat | ||
from ltk.jquery import get | ||
from ltk.jquery import delete | ||
from ltk.jquery import get_url_parameter | ||
from ltk.jquery import head | ||
from ltk.jquery import inject | ||
from ltk.jquery import inject_css | ||
from ltk.jquery import inject_script | ||
from ltk.jquery import jQuery | ||
from ltk.jquery import local_storage | ||
from ltk.jquery import number | ||
from ltk.jquery import parse_float | ||
from ltk.jquery import parse_int | ||
from ltk.jquery import post | ||
from ltk.jquery import proxy | ||
from ltk.jquery import get_url_parameter | ||
from ltk.jquery import set_url_parameter | ||
from ltk.jquery import push_state | ||
from ltk.jquery import repeat | ||
from ltk.jquery import repeat | ||
from ltk.jquery import schedule | ||
from ltk.jquery import set_url_parameter | ||
from ltk.jquery import time | ||
from ltk.jquery import to_js | ||
from ltk.jquery import inject | ||
|
||
|
||
from ltk.jquery import jQuery | ||
from ltk.jquery import console | ||
from ltk.jquery import window | ||
from ltk.jquery import document | ||
from ltk.jquery import body | ||
from ltk.jquery import head | ||
from ltk.jquery import parse_int | ||
from ltk.jquery import parse_float | ||
from ltk.jquery import local_storage | ||
|
||
|
||
from ltk.widgets import HBox | ||
from ltk.widgets import VBox | ||
from ltk.widgets import Div | ||
from ltk.widgets import Container | ||
from ltk.widgets import Card | ||
from ltk.widgets import Preformatted | ||
from ltk.widgets import Text | ||
from ltk.widgets import Input | ||
from ltk.widgets import Button | ||
from ltk.widgets import Tabs | ||
from ltk.widgets import Card | ||
from ltk.widgets import Code | ||
from ltk.widgets import Container | ||
from ltk.widgets import Div | ||
from ltk.widgets import File | ||
from ltk.widgets import Link | ||
from ltk.widgets import Table | ||
from ltk.widgets import TableRow | ||
from ltk.widgets import TableHeader | ||
from ltk.widgets import TableData | ||
from ltk.widgets import Image | ||
from ltk.widgets import MenuBar | ||
from ltk.widgets import MenuLabel | ||
from ltk.widgets import Menu | ||
from ltk.widgets import Popup | ||
from ltk.widgets import MenuPopup | ||
from ltk.widgets import MenuItem | ||
from ltk.widgets import H1 | ||
from ltk.widgets import H2 | ||
from ltk.widgets import H3 | ||
from ltk.widgets import H4 | ||
from ltk.widgets import HBox | ||
from ltk.widgets import Image | ||
from ltk.widgets import Input | ||
from ltk.widgets import Link | ||
from ltk.widgets import Menu | ||
from ltk.widgets import MenuBar | ||
from ltk.widgets import MenuItem | ||
from ltk.widgets import MenuLabel | ||
from ltk.widgets import MenuPopup | ||
from ltk.widgets import Popup | ||
from ltk.widgets import Preformatted | ||
from ltk.widgets import Table | ||
from ltk.widgets import TableData | ||
from ltk.widgets import TableHeader | ||
from ltk.widgets import TableRow | ||
from ltk.widgets import Tabs | ||
from ltk.widgets import Text | ||
from ltk.widgets import TextArea | ||
from ltk.widgets import VBox | ||
|
||
inject(__file__, "ltk.js", "ltk.css") |
Oops, something went wrong.