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