QJoystick#

class QInstrument.widgets.QJoystick.QJoystick(*args, fullscale=None, **kwargs)[source]#

Bases: QWidget

Mouse-controlled joystick widget.

Renders a circular pad with a draggable knob. Press and drag the knob to set a position; release to return it to center.

Signals#

positionChanged(numpy.ndarray)

Emitted when the knob moves beyond the dead-band. Carries a two-element array [x, y] mapped linearly from the knob fraction [-1, 1] to [minimum, maximum]. x is positive to the right; y is positive upward.

Properties#

fullscalefloat

Symmetric output limit: equivalent to setRange(-v, v). Default: 1.0.

padColorQtGui.QColor

Base color of the pad. Gradient stops and border are derived from it via lighter() / darker(). Default: QColor('#a888c8') (medium lavender). Settable via stylesheet: qproperty-padColor: #rrggbb;

knobColorQtGui.QColor

Base color of the knob. Gradient stops are derived from it. Default: QColor('#3848b8') (medium blue). Settable via stylesheet: qproperty-knobColor: #rrggbb;

tolerancefloat

Fractional dead-band; position changes smaller than this fraction of the full pad radius are suppressed. Default: 0.05.

positionChanged#

alias of object

setRange(minimum, maximum)[source]#

Set the output range for both axes.

The knob fraction [-1, 1] maps linearly to [minimum, maximum], so the center position emits (minimum + maximum) / 2.

Parameters:
  • minimum (float) – Output value at full negative deflection.

  • maximum (float) – Output value at full positive deflection.

Return type:

None

minimum()[source]#

Return the output value at full negative deflection.

Return type:

float

maximum()[source]#

Return the output value at full positive deflection.

Return type:

float

property fullscale: float#

Symmetric output limit; equivalent to setRange(-v, v).

padColor = 'QColor'#
setPadColor(color)[source]#

Set the base pad color and repaint.

Gradient stops and border are derived automatically via lighter() / darker(). May also be set via stylesheet with qproperty-padColor: #rrggbb;.

Parameters:

color (QtGui.QColor) – Base color for the pad.

Return type:

None

knobColor = 'QColor'#
setKnobColor(color)[source]#

Set the base knob color and repaint.

Gradient stops are derived automatically via lighter() / darker(). May also be set via stylesheet with qproperty-knobColor: #rrggbb;.

Parameters:

color (QtGui.QColor) – Base color for the knob.

Return type:

None

sizeHint()[source]#

Return the preferred widget size.

Return type:

QSize

resizeEvent(event)[source]#

Recompute the pad radius and knob travel limit on resize.

Return type:

None

setKnobFraction(fx, fy)[source]#

Position the knob at a given fraction of the travel range.

Intended for external control (e.g. step buttons on a QJoystickPad). Does not emit positionChanged.

Parameters:
  • fx (float) – Horizontal fraction in [-1, 1]. Positive is right.

  • fy (float) – Vertical fraction in [-1, 1]. Positive is upward.

Return type:

None

paintEvent(event)[source]#
Return type:

None

mousePressEvent(event)[source]#

Activate dragging when the press lands inside the knob.

Return type:

None

mouseReleaseEvent(event)[source]#

Deactivate dragging and return the knob to center.

Return type:

None

mouseMoveEvent(event)[source]#

Update knob position while dragging.

Return type:

None