(self, model_index)
Handle cell click event
Handle cell click event
Handle cell click event
def cell_clicked(self, model_index):
        """Handle cell click event"""
        i, j = model_index.row(), model_index.column()
        if not i or not j:
            return
        n = self.tablemodel.rowCount()
        index = self.tablemodel.index
        selection = None
        if i == j == 1 or i == j == n - 1:
            selection = QItemSelection(index(2, 2), index(n - 1, n - 1))
        elif i in (1, n - 1):
            selection = QItemSelection(index(2, j), index(n - 1, j))
        elif j in (1, n - 1):
            selection = QItemSelection(index(i, 2), index(i, n - 1))

        if selection is not None:
            self.tableview.selectionModel().select(
                selection, QItemSelectionModel.ClearAndSelect)
def cell_clicked ( self , model_index ) : i , j = model_index . row ( ) , model_index . column ( ) if not i or not j : return n = self . tablemodel . rowCount ( ) index = self . tablemodel . index selection = None if i == j == 1 or i == j == n - 1 : selection = QItemSelection ( index ( 2 , 2 ) , index ( n - 1 , n - 1 ) ) elif i in ( 1 , n - 1 ) : selection = QItemSelection ( index ( 2 , j ) , index ( n - 1 , j ) ) elif j in ( 1 , n - 1 ) : selection = QItemSelection ( index ( i , 2 ) , index ( i , n - 1 ) ) if selection is not None : self . tableview . selectionModel ( ) . select ( selection , QItemSelectionModel . ClearAndSelect )