mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Introduced MaskedInput widget
This commit is contained in:
32
docs/examples/widgets/masked_input.py
Normal file
32
docs/examples/widgets/masked_input.py
Normal 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()
|
||||
Reference in New Issue
Block a user