zasim.gui.elementary - Tools for manipulating Elementary Step Functions

Inheritance diagram of zasim.gui.elementary

This module offers GUI tools for manipulating table-like step functions of “elementary” cellular automatons.

Ideas for further utilities:

  • Display conflicting rules for horizontal or vertical symmetry, rotational symmetry, ...

  • An editing mode, that handles simple binary logic, like:

    c == 1 then result = 1
    c == 0 then result = 0
    l == 0 and r == 1 then result = 0
  • A graphical editing mode that allows adding “pattern matching” for rules with “dontcare fields” or something of that sort.

  • A graphical editing mode with zooming UI.

  • ...

zasim.gui.elementary.GAP = <object object at 0x460da20>

The value passed to create_subwidget when a position is not held by a field.

zasim.gui.elementary.CELL_COL = {0: PySide.QtGui.QColor.fromRgbF(0.000000, 0.000000, 0.000000, 1.000000), 1: PySide.QtGui.QColor.fromRgbF(1.000000, 1.000000, 1.000000, 1.000000), 2: PySide.QtGui.QColor.fromRgbF(1.000000, 0.000000, 0.000000, 1.000000), 3: PySide.QtGui.QColor.fromRgbF(0.000000, 0.000000, 1.000000, 1.000000), 4: PySide.QtGui.QColor.fromRgbF(0.000000, 1.000000, 0.000000, 1.000000), 5: PySide.QtGui.QColor.fromRgbF(1.000000, 1.000000, 0.000000, 1.000000), 6: PySide.QtGui.QColor.fromRgbF(0.000000, 1.000000, 1.000000, 1.000000), 7: PySide.QtGui.QColor.fromRgbF(1.000000, 0.000000, 1.000000, 1.000000), <object object at 0x460da20>: PySide.QtGui.QColor.fromRgbF(0.501961, 0.501961, 0.501961, 1.000000)}

What colors to use for what field values.

class zasim.gui.elementary.CellDisplayWidget(value, position=None, size=16, palette=None, **kwargs)[source]

Bases: PySide.QtGui.QLabel

A little Widget that displays a cell in a neighbourhood.

Create the DisplayWidget.

Parameters:
  • value – The cell value to show.
  • position – Alternatively, the position of the cell in the result list, to be used for communication to the outside.
  • size – The size of the cell, used for both width and height.
  • palette – The palette of colors to use.
staticMetaObject = <PySide.QtCore.QMetaObject object at 0x55b4c20>
class zasim.gui.elementary.EditableCellDisplayWidget(value, position, base=2, size=16, palette=None, **kwargs)[source]

Bases: PySide.QtGui.QPushButton

A clickable and keyboard-operatable display widget for cells.

Create the editable display widget.

Parameters:
  • value – The start value.
  • position – The position in the result list, used in the value_changed signal.
  • base – The numerical base for values.
  • size – The size for the display, used for both width and height.
  • palette – The palette of qcolors to use.
value_changed = <PySide.QtCore.Signal object at 0x43ea570>

This signal will be emitted when the user changed the value of the cell. It will emit the position and the new value.

set_value(value, emit=False)[source]
paintEvent(event)[source]

Redraw the button, add a rectangle inside the button if it has the focus.

set_position(position)[source]
staticMetaObject = <PySide.QtCore.QMetaObject object at 0x5181c68>
class zasim.gui.elementary.BaseNeighbourhoodDisplay(neighbourhood, values=None, base=2, palette=None, **kwargs)[source]

Bases: PySide.QtGui.QWidget

The BaseNeighbourhoodDisplay offers a skeleton for different ways of displaying neighbourhoods.

Subclass this and implement create_subwidget, which will be fed an offset and the corresponding entry from the values dictionary, or GAP if there is no spot in the neighbourhood at that position, and will then be put into a QGridLayout.

This class itself displays colored blocks in the shape of the neighbourhood.

determine_size()[source]

Determine how many fields to allocate in the grid. Subclass this, if you want more gaps around the edges.

Return a tuple of width, height and a tuple of x-offset and y-offset.

create_subwidget(offset, value)[source]

Create a widget for a cell in the neighbourhood.

Parameters:
  • offset – A tuple of (x, y) for the position of the cell
  • value – The value of the cell, as per the values dictionary, or if the widget is to be created for an empty space, GAP.
Returns:

a QWidget initialised for the cell. Alternatively, None.

update_value(widget, offset, new_value)[source]

Manipulate the given widget for the new value.

Returns:None, if the widget was manipulated, alternatively a new QWidget to take its place.
staticMetaObject = <PySide.QtCore.QMetaObject object at 0x51813f8>
class zasim.gui.elementary.NextToResult(neighbourhood_widget, result_widget, direction='l', **kwargs)[source]

Bases: PySide.QtGui.QWidget

A simple utility class to display a neighbourhood widget and a result widget next to each other in different relations.

Create the widget.

Parameters:
  • neighbourhood_widget – The neighbourhood widget to put in.
  • result_widget – The result widget to put in.
  • direction – The direction the neighbourhood widget to put at. Valid directions are l, u, d and r for left, up, down and right respectively.
staticMetaObject = <PySide.QtCore.QMetaObject object at 0x51819e0>
class zasim.gui.elementary.ElementaryRuleWindow(neighbourhood, rule=None, base=2, palette_info=None, **kwargs)[source]

Bases: PySide.QtGui.QWidget

A window usable to modify the table of an elementary step function.

Parameters:
  • neighbourhood – The Neighbourhood instance to get the data from.
  • rule – The rule to set at the beginning.
  • base – The numerical base for the cells.
  • palette – The palette_info for the simulator.
staticMetaObject = <PySide.QtCore.QMetaObject object at 0x5181320>
recalculate_rule_number()[source]

Recalculate what number corresponds to the result values saved in digits_and_values. :returns: the new rule number.

minimize_rule_number()[source]
do_neighbourhood_action(action)[source]
resizeEvent(event)[source]

React to a size change of the widget.

zasim.gui.elementary.main()[source]

Previous topic

zasim.gui.stepfunc - Compose stepfuncs with a GUI

Next topic

zasim.gui.animation - Animation to show during long-running tasks

This Page