File: textbox_filter_numbers.py

package info (click to toggle)
python-guizero 1.4.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,828 kB
  • sloc: python: 6,744; makefile: 28; sh: 17
file content (10 lines) | stat: -rw-r--r-- 289 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
from guizero import App, TextBox, Text

def filter_numbers():
    numeric_filter = filter(str.isdigit, textbox.value)
    textbox.value = "".join(numeric_filter)

app = App()
text = Text(app, text="Enter numbers only")
textbox = TextBox(app, width=40, command=filter_numbers)
app.display()