lib.selection.*

Grid selection representation

Provides

  • Selection: Represents grid selection independently from PyQt

class lib.selection.Selection(block_top_left, block_bottom_right, rows, columns, cells)[source]

Bases: object

Represents grid selection

Parameters:
  • block_top_left (List[Tuple[int, int]]) – Top left edges of all selection rectangles

  • block_bottom_right (List[Tuple[int, int]]) – Top left edges of all selection rectangles

  • rows (List[int]) – Selected rows

  • columns (List[int]) – Selected columns

  • cells (List[Tuple[int, int]]) – Individually selected cells as list of (row, column)

cell_generator(shape, table=None)[source]

Returns a generator of cell key tuples

Parameters:
  • shape – Grid shape

  • table – Third component of each returned key

Return type:

Generator

If table is None 2-tuples (row, column) are yielded else 3-tuples

get_absolute_access_string(shape, table)[source]

Get access string for absolute addressing

Parameters:
  • shape (Tuple[int, int, int]) – Grid shape, for which the generated keys are valid

  • table (int) – Table for all returned keys. Must be valid table in shape

Return type:

str

Returns:

String, with which the selection can be accessed

get_bbox()[source]

Returns bounding box

A bounding box is the smallest rectangle that contains all selections. Non-specified boundaries are None.

Return type:

Tuple[Tuple[int, int], Tuple[int, int]]

Returns:

((top, left), (bottom, right)) of bounding box

get_bottom_borders_selection(border_choice, shape)[source]

Get selection of cells, for which the bottom border attributes need to be adjusted on border line and border color changes.

border_choice names are:
  • “All borders”

  • “Top border”

  • “Bottom border”

  • “Left border”

  • “Right border”

  • “Outer borders”

  • “Inner borders”

  • “Top and bottom borders”

Parameters:

border_choice (str) – Border choice name

Returns:

Selection of cells that need to be adjusted on border change

Return type:

Selection

get_grid_bbox(shape)[source]

Returns bounding box within grid shape limits

A bounding box is the smallest rectangle that contains all selections. Non-specified boundaries are filled i from size.

Parameters:

shape (Tuple[int, int, int]) – Grid shape

Return type:

Tuple[Tuple[int, int], Tuple[int, int]]

Returns:

((top, left), (bottom, right)) of bounding box

get_relative_access_string(shape, current)[source]

Get access string relative to current cell

It is assumed that the selected cells are in the same table as the current cell.

Parameters:
  • shape (Tuple[int, int, int]) – Grid shape, for which the generated keys are valid

  • current (Tuple[int, int, int]) – Current cell for relative addressing

Return type:

str

Returns:

String, with which the selection can be accessed

get_right_borders_selection(border_choice, shape)[source]

Get selection of cells, for which the right border attributes need to be adjusted on border line and border color changes.

border_choice names are:
  • “All borders”

  • “Top border”

  • “Bottom border”

  • “Left border”

  • “Right border”

  • “Outer borders”

  • “Inner borders”

  • “Top and bottom borders”

Parameters:

border_choice (str) – Border choice name

Returns:

Selection of cells that need to be adjusted on border change

Return type:

Selection

insert(point, number, axis)[source]

Inserts number of rows/columns/tables into selection

Insertion takes place at point on axis.

Parameters:
  • point (int) – At this point the rows/columns are inserted or deleted

  • number (int) – Number of rows/columns to be inserted or deleted if negative

  • axis (int) – If 0, rows are affected, if 1, columns, axis in 0, 1

property parameters: Tuple[List[Tuple[int, int]], List[Tuple[int, int]], List[int], List[int], List[Tuple[int, int]]]

Tuple of selection parameters of self (self.block_tl, self.block_br, self.rows, self.columns,

self.cells)

Type:

return

shifted(rows, columns)[source]

Get a shifted selection

Negative values for rows and columns may result in a selection that addresses negative cells.

Parameters:
  • rows (int) – Number of rows that the selection is shifted down

  • columns (int) – Number of columns that the selection is shifted right

Returns:

New selection that is shifted by rows and columns

Return type:

Selection

single_cell_selected()[source]
Return type:

bool

Returns:

True iif a single cell is selected via self.cells