matrix_viewer package

Module contents

Top-level package for Matrix Viewer.

class matrix_viewer.Viewer(title='Matrix Viewer')[source]

Bases: object

Class representing a matrix viewer window.

register(tab, top_frame, tab_title)[source]

This method should only be used by tabs. It adds the tab to the window.

unregister(tab)[source]

This method should only be used by tabs.

view(object, tab_title=None, font_size=None, formatter=None)[source]

Adds a new tab that visualizes the specified object.

Parameters
  • tab_title – The string show in the tab header.

  • font_size – The font size used in the cells and the row / column headings.

  • formatter – A function which converts the cells to string. Currently only used for Matrix / Vector viewer.

class matrix_viewer.ViewerTab[source]

Bases: object

Base class for viewer tabs.

You must also call viewer.register in the __init__ function.

You must declare on_destroy(self): This method is called by Viewer when the tab is closed by the user. It is not called if the whole window is closed. It must call viewer.unregister(self).

class matrix_viewer.ViewerTabNumpy(viewer, matrix, matrix_title=None, font_size=None, cell_formatter=None)[source]

Bases: matrix_viewer._tab_table.ViewerTabTable

A viewer tab that can be used to visualize numpy.ndarray matrices and vectors.

get_focused_cell()[source]

Get the currently focused cell. This is the most recent cell that the user clicked on. If an area was selected that it drawn in blue, the focus cell is the cell with a white background inside the blue rectangle.

Returns

[index0, index1] so that matrix[index0, index1] represents the focused cell.

get_selection()[source]

Get the current selected matrix area.

Returns

[start0, end0, start1, end1] so that matrix[start0:end0, start1:end1] represents the selected part. If nothing was selected, returns None. If no area was explicitly selected, this is an 1x1 area representing the focused cell.

class matrix_viewer.ViewerTabStruct(viewer, object, title=None, font_size=None)[source]

Bases: matrix_viewer._tab_table.ViewerTabTable

A viewer tab that can be used to visualize a class, list, dict and some other container types.

class matrix_viewer.ViewerTabText(viewer, object, title=None, font_size=None)[source]

Bases: matrix_viewer._tab.ViewerTab

Viewer tab that displays the str(.) representation of an object.

on_destroy()[source]

Internal method called by the viewer.

matrix_viewer.pause(timeout)[source]

Runs the event loop for the specified time interval.

Parameters

timeout – Time interval in seconds. If 0, it will exit immediately after processing all pending GUI events.

matrix_viewer.show(block=True)[source]

Runs the event loop until all windows are closed.

Parameters

block – To keep API similarity to pyplot - if False, this will do nothing; if True, this function will block until all windows are closed.

matrix_viewer.show_with_pyplot()[source]

This function should be used instead of show when you are also using matplotlib.pyplot. It concurrently runs the event loop for pyplot and matrix_viewer. It will run until all numpy and matrix_viewer windows were closed by the user.

Note that unfortunately, pyplot and matrix_viewer appear to be slightly laggy if you are using a different pyplot backend than tkinter.

matrix_viewer.view(object, tab_title=None, font_size=None, formatter=None)[source]

Creates a new tab in the current window, which shows the object. Creates a new window if there are no opened windows.

Parameters
  • object – the object that is to be visualized.

  • tab_title – The string show in the tab header.

  • font_size – The font size used in the cells and the row / column headings.

  • formatter – A function which converts the cells to string. Currently only used for Matrix / Vector viewer.

Returns

The newly created viewer tab.

matrix_viewer.viewer(title='Matrix Viewer')[source]

Creates a new viewer window.

Parameters

title – The string shown in the window header.

Returns

The newly created viewer window.