mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
input docs an exampels
This commit is contained in:
23
docs/examples/guide/input/key02.py
Normal file
23
docs/examples/guide/input/key02.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.widgets import TextLog
|
||||
from textual import events
|
||||
|
||||
|
||||
class KeyLogger(TextLog):
|
||||
def on_key(self, event: events.Key) -> None:
|
||||
self.write(event)
|
||||
|
||||
|
||||
class InputApp(App):
|
||||
"""App to display key events."""
|
||||
|
||||
CSS_PATH = "input02.css"
|
||||
|
||||
def compose(self) -> ComposeResult:
|
||||
yield KeyLogger()
|
||||
yield KeyLogger()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = InputApp()
|
||||
app.run()
|
||||
Reference in New Issue
Block a user