gui

main

class axopy.gui.main.Container[source]

Graphics container for tasks.

set_layout(layout)[source]

Set the layout of the container.

Parameters:

layout (QLayout) – Any QLayout is OK to add.

set_widget(widget)[source]

Set the widget containing all graphical elements.

Parameters:

widget (QWidget) – Any QWidget is OK to add.

See also

axopy.gui.canvas

Canvas widget and canvas items that can be added to the container.

axopy.gui.graph

Plotting widgets that can be added to the container.

show()[source]

Show the container in the active application.

This is not normally needed, unless you’re testing out a GUI and using gui_check().

axopy.gui.main.get_qtapp()[source]

Get a QApplication instance running.

Returns the current QApplication instance if it exists and creates it otherwise.

Examples

This function is primarily for internal usage, but it is exposed to make it convenient to test graphical code without all of the experiment/task machinery.

from axopy.gui.main import get_qtapp, Container

# get the application instance first, before creating widgets etc.
app = get_qtapp()

con = Container()

# call show() to show the widget, then run the application
con.show()
app.exec_()
axopy.gui.main.gui_check()[source]

Check graphical interface code interactively.

This function makes it convenient to test graphical code without all of the experiment/task machinery. You can create a Container, add things to the container, and then call this function with the container to run the GUI and try it out.

Note

Be sure to call Container.show() at the end to display the container.

Examples

Minimal example

from axopy.gui.main import Container, gui_check

with gui_check():
    con = Container()
    con.show()

canvas

2D canvas style graphics functionality backed by Qt’s QGraphicsView.

class axopy.gui.canvas.Canvas(draw_border=True, bg_color=None, border_color=None, parent=None, invert_x=False, invert_y=False)[source]

A 2D canvas interface implemented using a QGraphicsView.

This view essentially just holds a QGraphicsScene that grows to fit the size of the view, keeping the aspect ratio square. The scene is displayed with a gray (by default) border.

See Qt’s documentation for more information about working with QGraphicsView (https://doc.qt.io/Qt-5/qgraphicsview.html).

add_item(item)[source]

Add an item to the canvas.

Parameters:

item (Item or QGraphicsItem) – The item to add to the canvas. This can be either one of AxoPy’s built-in items (Circle, Text, etc.) or any QGraphicsItem.

resizeEvent(self, event: QResizeEvent)[source]
class axopy.gui.canvas.Circle(diameter, color='#333333')[source]

Circular item.

The coordinates of this item correspond to the center of the circle.

Parameters:
  • dia (float) – Diameter of the circle with respect to the scene coordinate system.

  • color (str) – Hex string to set the color of the circle. You can use the underlying qitem attribute to get the underlying QGraphicsEllipseItem to set stroke color vs. fill color, etc. if needed.

class axopy.gui.canvas.Cross(size=0.05, linewidth=0.01, color='#333333')[source]

Collection of two lines oriented as a “plus sign”.

The coordinates of this item correspond to the center of the cross. This item’s qitem attribute is a QGraphicsItemGroup (a group of two lines).

Parameters:
  • size (float) – The size is the length of each line making up the cross.

  • linewidth (float) – Thickness of each line making up the cross.

  • color (str) – Color of the lines making up the cross.

property color

Color of the lines in the cross.

class axopy.gui.canvas.Item(qitem)[source]

Canvas item base class.

This is simply a wrapper around any kind of QGraphicsItem, adding the ability to set some properties of the underlying item with a more Pythonic API. You can always access the QGraphicsItem with the qitem attribute. Once you know what kind of QGraphicsItem is being wrapped, you can use the corresponding Qt documentation to make use of more complete functionality.

qitem

The QGraphicsItem being wrapped. You can use this attribute to access methods and properties of the item not exposed by the wrapper class. If you find yourself routinely using a method of the QGraphicsItem, consider recommending it for addition to AxoPy.

Type:

QGraphicsItem

collides_with(item)[source]

Determine if the item intersects with another item.

property color

Color of the item.

get(prop, *args, **kwargs)[source]

Get any property of the underlying QGraphicsItem.

hide()[source]

Set the item to invisible.

property opacity

Opacity of the item (between 0 and 1).

property pos

Both X and Y coordinates of the item in the canvas.

set(**kwargs)[source]

Set any properties of the underlying QGraphicsItem.

show()[source]

Set the item to visible.

property visible

Visibility of the item.

property x

X coordinate of the item in the canvas.

property y

Y coordinate of the item in the canvas.

class axopy.gui.canvas.Line(x1, y1, x2, y2, width=0.01, color='#333333')[source]

Line item.

property color

Color of the item.

class axopy.gui.canvas.Rectangle(width, height, x=0, y=0, color='#333333', penwidth=0.01)[source]

Rectangular item.

This is a filled retangle that allows you to set the size, color, position, etc. By default, the item’s position is its center.

property color

Color of the rectangle.

class axopy.gui.canvas.Text(text, color='#333333')[source]

Text item.

graph

Widgets for plotting multi-channel signals.

class axopy.gui.graph.SignalWidget[source]

Scrolling oscilloscope-like widget for displaying real-time signals.

Intended for multi-channel viewing, each channel gets its own row in the widget, and all channels share y-axis zoom.

plot(data)[source]

Adds a window of data to the widget.

Previous windows are scrolled to the left, and the new data is added to the end.

Parameters:

data (ndarray, shape = (n_channels, n_samples)) – Window of data to add to the end of the currently-shown data.