add selection exceptions

click-textual
Maveno 1 year ago
parent 9df5973676
commit 84baeb2d87

@ -186,8 +186,13 @@ class ShowDetailsScreen(Screen):
def handle_remove_pattern(self, screenResult):
row_key, col_key = self.patternTable.coordinate_to_cell_key(self.patternTable.cursor_coordinate)
self.patternTable.remove_row(row_key)
try:
row_key, col_key = self.patternTable.coordinate_to_cell_key(self.patternTable.cursor_coordinate)
self.patternTable.remove_row(row_key)
except CellDoesNotExist:
pass
def compose(self):

@ -12,6 +12,8 @@ from .show_delete_screen import ShowDeleteScreen
from .help_screen import HelpScreen
from textual.widgets._data_table import CellDoesNotExist
class ShowsScreen(Screen):
@ -61,16 +63,19 @@ class ShowsScreen(Screen):
def getSelectedShowId(self):
# Fetch the currently selected row when 'Enter' is pressed
#selected_row_index = self.table.cursor_row
row_key, col_key = self.table.coordinate_to_cell_key(self.table.cursor_coordinate)
try:
# Fetch the currently selected row when 'Enter' is pressed
#selected_row_index = self.table.cursor_row
row_key, col_key = self.table.coordinate_to_cell_key(self.table.cursor_coordinate)
if row_key is not None:
selected_row_data = self.table.get_row(row_key)
return selected_row_data[0]
if row_key is not None:
selected_row_data = self.table.get_row(row_key)
return selected_row_data[0]
except CellDoesNotExist:
return None
return None
@ -93,10 +98,17 @@ class ShowsScreen(Screen):
def handle_edit_screen(self, screenResult):
row_key, col_key = self.table.coordinate_to_cell_key(self.table.cursor_coordinate)
try:
row_key, col_key = self.table.coordinate_to_cell_key(self.table.cursor_coordinate)
self.table.update_cell(row_key, self.column_key_name, screenResult['name'])
self.table.update_cell(row_key, self.column_key_year, screenResult['year'])
except CellDoesNotExist:
pass
self.table.update_cell(row_key, self.column_key_name, screenResult['name'])
self.table.update_cell(row_key, self.column_key_year, screenResult['year'])
def action_delete_show(self):
@ -108,8 +120,14 @@ class ShowsScreen(Screen):
def handle_delete_show(self, screenResult):
row_key, col_key = self.table.coordinate_to_cell_key(self.table.cursor_coordinate)
self.table.remove_row(row_key)
try:
row_key, col_key = self.table.coordinate_to_cell_key(self.table.cursor_coordinate)
self.table.remove_row(row_key)
except CellDoesNotExist:
pass
def loadShows(self):

Loading…
Cancel
Save