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): 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): def compose(self):

@ -12,6 +12,8 @@ from .show_delete_screen import ShowDeleteScreen
from .help_screen import HelpScreen from .help_screen import HelpScreen
from textual.widgets._data_table import CellDoesNotExist
class ShowsScreen(Screen): class ShowsScreen(Screen):
@ -61,16 +63,19 @@ class ShowsScreen(Screen):
def getSelectedShowId(self): def getSelectedShowId(self):
# Fetch the currently selected row when 'Enter' is pressed try:
#selected_row_index = self.table.cursor_row # Fetch the currently selected row when 'Enter' is pressed
row_key, col_key = self.table.coordinate_to_cell_key(self.table.cursor_coordinate) #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)
if row_key is not None: return selected_row_data[0]
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): 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): def action_delete_show(self):
@ -108,8 +120,14 @@ class ShowsScreen(Screen):
def handle_delete_show(self, screenResult): 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): def loadShows(self):

Loading…
Cancel
Save