From 51ff0bae85c50bb509a05582e2e4d019bdbeeda6 Mon Sep 17 00:00:00 2001 From: laffra Date: Mon, 13 Nov 2023 13:45:56 +0100 Subject: [PATCH] Include relevant parts into the source --- examples/table.py | 10 +++++----- examples/tictactoe.py | 25 +++++++++++-------------- main.py | 2 +- 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/examples/table.py b/examples/table.py index fd25c97..ca5fb39 100644 --- a/examples/table.py +++ b/examples/table.py @@ -16,13 +16,13 @@ def get_averages(): "Australia": 21.65, } -resize_options = ltk.to_js({ - "handles": "e", - "alsoResize": ".country", -}) - def create(): + resize_options = ltk.to_js({ + "handles": "e", + "alsoResize": ".country", + }) + return ( ltk.Container( ltk.create("

HTML Table created in Python

"), diff --git a/examples/tictactoe.py b/examples/tictactoe.py index 379a7f2..4f437c1 100644 --- a/examples/tictactoe.py +++ b/examples/tictactoe.py @@ -3,23 +3,20 @@ import inspect import ltk -def choose(event): - square = ltk.find(event.target) - if not square.text(): - square.append( - ltk.Text("X" if ltk.find(".choice").length % 2 else "O") - .addClass("choice") - ) - -def enter(event): - ltk.find(".square").css("background", "white") - square = ltk.jQuery(event.target) - if not square.text(): - square.css("background", "lightblue") +def create(): + def choose(event): + if not ltk.find(event.target).text(): + ltk.find(event.target).append( + ltk.Text("X" if ltk.find(".choice").length % 2 else "O") + .addClass("choice") + ) + def enter(event): + ltk.find(".square").css("background", "white") + if not ltk.jQuery(event.target).text(): + ltk.jQuery(event.target).css("background", "lightblue") -def create(): return ( ltk.Div( ltk.H2("Tic Tac Toe Game"), diff --git a/main.py b/main.py index 7116776..d0323cd 100644 --- a/main.py +++ b/main.py @@ -19,7 +19,7 @@ def cleanup(src): ltk.VBox( ltk.H2("The source:"), ltk.TextArea(cleanup(example.attr("src"))) - .css("height", 400) + .css("height", 500) .css("border-width", 0) .css("font-family", "Courier") )