tabulous package

Subpackages

Submodules

tabulous.color module

class tabulous.color.BrightenedColormap(func: Union[Callable[[Any], Union[str, Iterable[int]]], Mapping[str, Union[str, Iterable[int]]]], factor: float)[source]

Bases: tabulous.color.ConvertedColormap

classmethod from_colormap(cmap: Union[Callable[[Any], Union[str, Iterable[int]]], Mapping[str, Union[str, Iterable[int]]]], factor: float) Union[Callable[[Any], Union[str, Iterable[int]]], Mapping[str, Union[str, Iterable[int]]]][source]

Convert a colormap into an new one with given brightening factor.

class tabulous.color.ColorTuple(r: int, g: int, b: int, a: int = 255)[source]

Bases: NamedTuple

8-bit color tuple.

a: int

Alias for field number 3

b: int

Alias for field number 2

brighten(ratio: float) tabulous.color.ColorTuple[source]

Set the saturation of the color.

equals(other)[source]
classmethod from_hlsa(*hlsa) tabulous.color.ColorTuple[source]

Create a ColorTuple from HSLA.

classmethod from_hsva(*hsva) tabulous.color.ColorTuple[source]

Create a ColorTuple from HSVA.

classmethod from_html(html: str) tabulous.color.ColorTuple[source]

Create a ColorTuple from a HTML color string.

g: int

Alias for field number 1

property hlsa: tuple[float, float, float, float]

Return the color as HSLA.

property hsva: tuple[float, float, float, float]

Return the color as HSVA.

property html: str

Return a HTML color string.

mix(other, ratio: float = 0.5, alpha: bool = False) tabulous.color.ColorTuple[source]

Mix the color with another color.

property opacity: float

Return the opacity as a float between 0 and 1.

r: int

Alias for field number 0

class tabulous.color.ConvertedColormap(func: Union[Callable[[Any], Union[str, Iterable[int]]], Mapping[str, Union[str, Iterable[int]]]])[source]

Bases: object

class tabulous.color.InvertedColormap(func: Union[Callable[[Any], Union[str, Iterable[int]]], Mapping[str, Union[str, Iterable[int]]]])[source]

Bases: tabulous.color.ConvertedColormap

classmethod from_colormap(cmap: Union[Callable[[Any], Union[str, Iterable[int]]], Mapping[str, Union[str, Iterable[int]]]]) Union[Callable[[Any], Union[str, Iterable[int]]], Mapping[str, Union[str, Iterable[int]]]][source]

Convert a colormap into return an inverted one.

class tabulous.color.OpacityColormap(func: Union[Callable[[Any], Union[str, Iterable[int]]], Mapping[str, Union[str, Iterable[int]]]], opacity: float)[source]

Bases: tabulous.color.ConvertedColormap

classmethod from_colormap(cmap: Union[Callable[[Any], Union[str, Iterable[int]]], Mapping[str, Union[str, Iterable[int]]]], opacity: float) Union[Callable[[Any], Union[str, Iterable[int]]], Mapping[str, Union[str, Iterable[int]]]][source]

Convert a colormap into an new one with given alpha channel.

tabulous.color.normalize_color(color: Union[str, Iterable[int]]) tabulous.color.ColorTuple[source]

Normalize a color-like object to a ColorTuple.

tabulous.color.rgba_to_str(rgba: tuple[int, int, int, int]) str[source]

tabulous.core module

tabulous.core.current_viewer() TableViewerBase[source]

Get the current table viewer widget.

tabulous.core.open_sample(sample_name: str, plugin_name: str = 'seaborn') TableViewerBase[source]

Open a sample data.

tabulous.core.read_csv(path: str | Path, *args, **kwargs) TableViewerBase[source]

Read CSV file and add it to the current viewer.

tabulous.core.read_excel(path: str | Path, *args, **kwargs) TableViewerBase[source]

Read Excel file and add all the sheets to the current viewer.

tabulous.core.set_current_viewer(viewer: TableViewerBase) TableViewerBase[source]

Set a table viewer as the current one.

tabulous.core.view_spreadsheet(data, *, name: str | None = None, editable: bool = True, copy: bool = True) TableViewerBase[source]

View a table as a spreadsheet in the current viewer.

tabulous.core.view_table(data, *, name: str | None = None, editable: bool = False, copy: bool = True) TableViewerBase[source]

View a table in the current viewer.

tabulous.exceptions module

class tabulous.exceptions.ExceptionHandler(hook: Callable[[type[Exception], Exception, types.TracebackType], Any])[source]

Bases: object

Handle exceptions in the GUI thread.

exception tabulous.exceptions.SelectionRangeError[source]

Bases: ValueError

Raised when the exception is caused by wrong selection range(s).

tabulous.post_init module

class tabulous.post_init.CellNamespaceMock(name: str = '')[source]

Bases: tabulous.post_init._Updatable

A mock for the cell_namespace attribute of a table viewer instance.

class tabulous.post_init.CommandPaletteMock(name: str = '')[source]

Bases: tabulous.post_init._Registerable

register(command: Callable[[TableViewerBase], Any], title: str, desc: str | None, key: str | None)[source]
register(command: Literal[None], title: str, desc: str | None, key: str | None)
class tabulous.post_init.ConsoleMock(name: str = '')[source]

Bases: tabulous.post_init._Updatable

A mock for the console attribute of a table viewer instance.

class tabulous.post_init.ContextRegisterable(name: str = '')[source]

Bases: tabulous.post_init._Registerable, Generic[tabulous.post_init._T]

A mock for the register method.

register(loc: str, func: Literal[None] = None) Callable[[Callable[[tabulous.post_init._T, Any], None]], Callable[[tabulous.post_init._T, Any], None]][source]
register(loc: str, func: Callable[[tabulous.post_init._T, Any], None]) Callable[[tabulous.post_init._T, Any], None]
class tabulous.post_init.Initializer[source]

Bases: object

join(other: tabulous.post_init.Initializer)[source]

Join initializers together.

class tabulous.post_init.KeyMapMock(name: str = '')[source]

Bases: tabulous.post_init._Registerable

A mock for the keymap attribute of a table viewer instance.

register(key: str, func: Literal[None] = None) Callable[[Callable[[TableViewerBase, Any], None]], Callable[[TableViewerBase, Any], None]][source]
register(key: str, func: Callable[[TableViewerBase, Any], None]) Callable[[TableViewerBase, Any], None]
class tabulous.post_init.TableInitializer[source]

Bases: tabulous.post_init.Initializer

cell: ContextRegisterable[TableBase]

A mock for the register method.

columns: ContextRegisterable[TableBase]

A mock for the register method.

index: ContextRegisterable[TableBase]

A mock for the register method.

initialize_table(table: TableBase)[source]
keymap: ContextRegisterable[TableBase]

A mock for the keymap attribute of a table viewer instance.

class tabulous.post_init.ViewerInitializer[source]

Bases: tabulous.post_init.Initializer

cell_namespace: CellNamespaceMock[TableViewerBase]

A mock for the cell_namespace attribute of a table viewer instance.

command_palette: CommandPaletteMock[TableViewerBase]
console: ConsoleMock[TableViewerBase]

A mock for the console attribute of a table viewer instance.

initialize_viewer(viewer: TableViewerBase)[source]
keymap: ContextRegisterable[TableViewerBase]

A mock for the keymap attribute of a table viewer instance.

tables: ContextRegisterable[TableViewerBase]

A mock for the register method.

tabulous.post_init.get_initializers() tuple[tabulous.post_init.ViewerInitializer, tabulous.post_init.TableInitializer][source]

Get viewer and table initializers.

tabulous.threading module

tabulous.threading.thread_worker(function: Callable[[_P], Generator[tabulous.threading._Y, tabulous.threading._S, tabulous.threading._R]], *, desc: str | None = 'None', total: int = '0') Callable[[_P], superqt.utils._qthreading.GeneratorWorker[tabulous.threading._Y, tabulous.threading._S, tabulous.threading._R]][source]
tabulous.threading.thread_worker(function: Callable[[_P], tabulous.threading._R], *, desc: str | None = 'None', total: int = '0') Callable[[_P], superqt.utils._qthreading.FunctionWorker[tabulous.threading._R]]
tabulous.threading.thread_worker(function: None = None, *, desc: str | None = 'None', total: int = '0') Callable[[Callable[[_P], tabulous.threading._R]], Callable[[_P], Union[superqt.utils._qthreading.FunctionWorker[tabulous.threading._R], superqt.utils._qthreading.GeneratorWorker[Any, Any, tabulous.threading._R]]]]

Convert the returned value of a function into a worker.

>>> from tabulous.threading import thread_worker
>>> @thread_worker
>>> def func():
...     time.sleep(1)
Parameters
  • function (callable) – Function to be called in another thread.

  • desc (str, optional) – Label that will shown beside the progress indicator. The function name will be used if not provided.

  • total (int, default is 0) – Total number of steps for the progress indicator.

tabulous.types module

class tabulous.types.HeaderInfo(index: int, value: Any, old_value: Any)[source]

Bases: NamedTuple

A named tuple for header update.

Value takes (index, value, old_value) where

indexint

Index where item edited.

valueAny

New value of the item.

old_valueAny

Old value of the item.

index: int

Alias for field number 0

old_value: Any

Alias for field number 2

value: Any

Alias for field number 1

class tabulous.types.ItemInfo(row: int | slice, column: int | slice, value: Any, old_value: Any)[source]

Bases: NamedTuple

A named tuple for item update.

Value takes (row, column, value, old_value) where

rowint or slice

Row index or slice where item edited.

columnint or slice

Column index or slice where item edited.

valueAny

New value of the item.

old_valueAny

Old value of the item.

If a row or column is deleted, the value is set to DELETED. If a row or column is inserted, the old_value is set to INSERTED.

DELETED = DELETED
INSERTED = INSERTED
property col: int | slice

Alias of column.

column: int | slice

Alias for field number 1

old_value: Any

Alias for field number 3

row: int | slice

Alias for field number 0

value: Any

Alias for field number 2

class tabulous.types.TableInfo(*args, **kwargs)[source]

Bases: object

A generic type to describe a DataFrame and its column names.

TableInfo["x", "y"] is equivalent to tuple[pd.DataFrame, str, str] with additional information for magicgui construction.

Module contents

class tabulous.MagicTableViewer(*, tab_position: tabulous.types.TabPosition | str = TabPosition.top, name: str = '', label: str = None, tooltip: str | None = None, visible: bool | None = None, enabled: bool = True, show: bool = False)[source]

Bases: magicgui.widgets.bases._widget.Widget, tabulous.widgets._mainwindow.TableViewerWidget

A magicgui widget of table viewer.

This class is a subclass of magicgui.widget.Widget so that it can be used in a compatible way with magicgui and napari.

Parameters

tab_position (TabPosition or str) – Type of list-like widget to use.

property native

Return native backend widget.

Note this is the widget that contains the layout, and not any parent widgets of this (e.g. a parent widget that is used to enable scroll bars)

class tabulous.TableViewer(*, tab_position: tabulous.types.TabPosition | str = TabPosition.top, show: bool = True)[source]

Bases: tabulous.widgets._mainwindow.TableViewerBase

The main table viewer widget.

add_dock_widget(widget: Widget | QWidget, *, name: str = '', area: str = 'right', allowed_areas: list[str] | None = None)[source]

Add a Qt or magic widget as a dock widget of the table viewer.

Parameters
  • widget (magicgui.widgets.Widget or QWidget) – Widget to add to the table viewer.

  • name (str, optional) – Name of the widget.

  • area (str, default is "right") – The initial area of the dock widget.

  • allowed_areas (list of str, optional) – The allowed areas of the dock widget.

property config: mappingproxy

Return the config info.

events: TableViewerSignal
remove_dock_widget(name_or_widget: str | Widget | QWidget)[source]

Remove dock widget from the table viewer.

reset_choices(*_)[source]

Reset all the magicgui combo boxes.

class tabulous.TableViewerWidget(*, tab_position: tabulous.types.TabPosition | str = TabPosition.top, show: bool = True)[source]

Bases: tabulous.widgets._mainwindow.TableViewerBase

The non-main table viewer widget.

add_widget(widget: Widget | QWidget, *, name: str = '')[source]

Add a widget to the viewer as a child floating widget.

events: TableViewerSignal
tabulous.current_viewer() TableViewerBase[source]

Get the current table viewer widget.

tabulous.open_sample(sample_name: str, plugin_name: str = 'seaborn') TableViewerBase[source]

Open a sample data.

tabulous.read_csv(path: str | Path, *args, **kwargs) TableViewerBase[source]

Read CSV file and add it to the current viewer.

tabulous.read_excel(path: str | Path, *args, **kwargs) TableViewerBase[source]

Read Excel file and add all the sheets to the current viewer.

tabulous.view_spreadsheet(data, *, name: str | None = None, editable: bool = True, copy: bool = True) TableViewerBase[source]

View a table as a spreadsheet in the current viewer.

tabulous.view_table(data, *, name: str | None = None, editable: bool = False, copy: bool = True) TableViewerBase[source]

View a table in the current viewer.