Started trying to get the year fields to not allow numbers

This commit is contained in:
Sumner Evans
2020-03-07 05:22:31 -07:00
parent 7404bc2910
commit f0270a4e7f

View File

@@ -223,14 +223,12 @@ class AlbumsPanel(Gtk.Box):
True,
)
def on_year_changed(self, entry: Gtk.Entry):
try:
year = int(entry.get_text())
except Exception:
# TODO (#123): prevent input of non-numerals
logging.error(
'failed, should do something to prevent non-numeric input')
return
def on_year_changed(self, entry: Gtk.Entry) -> bool:
sanitized = [d for d in entry.get_text() if d in '0123456789']
if len(sanitized) == 0:
return True
year = int(''.join(sanitized))
entry.set_text(str(year))
if self.to_year_entry == entry:
self.grid.update_params(to_year=year)
@@ -253,6 +251,8 @@ class AlbumsPanel(Gtk.Box):
True,
)
return False
def on_grid_cover_clicked(self, grid: Any, id: str):
self.emit(
'refresh-window',