more docs

This commit is contained in:
Will McGugan
2022-05-25 15:36:58 +01:00
parent 2b485cd4cc
commit 6bfc26c1ec
43 changed files with 463 additions and 124 deletions

View File

@@ -0,0 +1,22 @@
from datetime import datetime
from textual.app import App
from textual.widget import Widget
class Clock(Widget):
def on_mount(self):
self.styles.content_align = ("center", "middle")
self.set_interval(1, self.refresh)
def render(self):
return datetime.now().strftime("%c")
class ClockApp(App):
def compose(self):
yield Clock()
app = ClockApp()
app.run()

View File

@@ -0,0 +1,22 @@
from datetime import datetime
from textual.app import App
from textual.widget import Widget
class Clock(Widget):
def on_mount(self):
self.styles.content_align = ("center", "middle")
self.set_interval(1, self.refresh)
def render(self):
return datetime.now().strftime("%c")
class ClockApp(App):
def on_mount(self):
self.mount(Clock())
app = ClockApp()
app.run()

View File

@@ -0,0 +1,9 @@
from textual.app import App
class ExampleApp(App):
pass
app = ExampleApp()
app.run()

View File

@@ -0,0 +1,29 @@
from textual.app import App
class ExampleApp(App):
COLORS = [
"white",
"maroon",
"red",
"purple",
"fuchsia",
"olive",
"yellow",
"navy",
"teal",
"aqua",
]
def on_mount(self):
self.styles.background = "darkblue"
def on_key(self, event):
if event.key.isdigit():
self.styles.background = self.COLORS[int(event.key)]
self.bell()
app = ExampleApp()
app.run()

View File

@@ -0,0 +1,17 @@
from textual.app import App
from textual.widget import Widget
class WidthApp(App):
CSS = """
Widget {
background: blue;
width: 50%;
}
"""
def compose(self):
yield Widget()
app = WidthApp()