Introduced MaskedInput widget

This commit is contained in:
Angelo Mottola
2024-07-22 00:38:41 +02:00
parent dd10561994
commit e437bf5bbe
11 changed files with 1109 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
from textual.app import App, ComposeResult
from textual.widgets import Label, MaskedInput
class MaskedInputApp(App):
# (1)!
CSS = """
MaskedInput.-valid {
border: tall $success 60%;
}
MaskedInput.-valid:focus {
border: tall $success;
}
MaskedInput {
margin: 1 1;
}
Label {
margin: 1 2;
}
"""
def compose(self) -> ComposeResult:
yield Label("Enter a valid credit card number.")
yield MaskedInput(
template="9999-9999-9999-9999;0", # (2)!
)
app = MaskedInputApp()
if __name__ == "__main__":
app.run()