def selected_row(view):
 if (view.selectionMode() in [QAbstractItemView.MultiSelection, QAbstractItemView.ExtendedSelection]):
  raise ValueError("invalid 'selectionMode'")
 sel_model = view.selectionModel()
 indexes = sel_model.selectedRows()
 if indexes:
  assert (len(indexes) == 1)
  return indexes[0].row()
 else:
  return None

def selected_row ( view ) : if ( view . selectionMode ( ) in [ QAbstractItemView . MultiSelection , QAbstractItemView . ExtendedSelection ] ) : raise ValueError ( "invalid 'selectionMode'" ) sel_model = view . selectionModel ( ) indexes = sel_model . selectedRows ( ) if indexes : assert ( len ( indexes ) == 1 ) return indexes [ 0 ] . row ( ) else : return None
return the index of selected row in a view the views selection mode must be a qabstractitemview .