add selection exceptions
This commit is contained in:
@@ -186,9 +186,14 @@ class ShowDetailsScreen(Screen):
|
|||||||
|
|
||||||
|
|
||||||
def handle_remove_pattern(self, screenResult):
|
def handle_remove_pattern(self, screenResult):
|
||||||
|
|
||||||
|
try:
|
||||||
row_key, col_key = self.patternTable.coordinate_to_cell_key(self.patternTable.cursor_coordinate)
|
row_key, col_key = self.patternTable.coordinate_to_cell_key(self.patternTable.cursor_coordinate)
|
||||||
self.patternTable.remove_row(row_key)
|
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,6 +63,7 @@ class ShowsScreen(Screen):
|
|||||||
|
|
||||||
def getSelectedShowId(self):
|
def getSelectedShowId(self):
|
||||||
|
|
||||||
|
try:
|
||||||
# Fetch the currently selected row when 'Enter' is pressed
|
# Fetch the currently selected row when 'Enter' is pressed
|
||||||
#selected_row_index = self.table.cursor_row
|
#selected_row_index = self.table.cursor_row
|
||||||
row_key, col_key = self.table.coordinate_to_cell_key(self.table.cursor_coordinate)
|
row_key, col_key = self.table.coordinate_to_cell_key(self.table.cursor_coordinate)
|
||||||
@@ -70,10 +73,12 @@ class ShowsScreen(Screen):
|
|||||||
|
|
||||||
return selected_row_data[0]
|
return selected_row_data[0]
|
||||||
|
|
||||||
|
except CellDoesNotExist:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def action_new_show(self):
|
def action_new_show(self):
|
||||||
self.app.push_screen(ShowDetailsScreen(), self.handle_new_screen)
|
self.app.push_screen(ShowDetailsScreen(), self.handle_new_screen)
|
||||||
|
|
||||||
@@ -93,11 +98,18 @@ class ShowsScreen(Screen):
|
|||||||
|
|
||||||
def handle_edit_screen(self, screenResult):
|
def handle_edit_screen(self, screenResult):
|
||||||
|
|
||||||
|
try:
|
||||||
|
|
||||||
row_key, col_key = self.table.coordinate_to_cell_key(self.table.cursor_coordinate)
|
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_name, screenResult['name'])
|
||||||
self.table.update_cell(row_key, self.column_key_year, screenResult['year'])
|
self.table.update_cell(row_key, self.column_key_year, screenResult['year'])
|
||||||
|
|
||||||
|
except CellDoesNotExist:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def action_delete_show(self):
|
def action_delete_show(self):
|
||||||
|
|
||||||
@@ -108,9 +120,15 @@ class ShowsScreen(Screen):
|
|||||||
|
|
||||||
|
|
||||||
def handle_delete_show(self, screenResult):
|
def handle_delete_show(self, screenResult):
|
||||||
|
|
||||||
|
try:
|
||||||
row_key, col_key = self.table.coordinate_to_cell_key(self.table.cursor_coordinate)
|
row_key, col_key = self.table.coordinate_to_cell_key(self.table.cursor_coordinate)
|
||||||
self.table.remove_row(row_key)
|
self.table.remove_row(row_key)
|
||||||
|
|
||||||
|
except CellDoesNotExist:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def loadShows(self):
|
def loadShows(self):
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user