QJoystickPad#

class QInstrument.widgets.QJoystickPad.QJoystickPad(*args, fullscale=None, stepFraction=0.25, holdThreshold=300, **kwargs)[source]#

Bases: QWidget

QJoystick with four directional step buttons.

Arranges a QJoystick in the center of a 3×3 grid with a triangular step button on each side. The central joystick works normally. Each step button, when pressed, emits positionChanged once at stepFraction of the axis full-scale; releasing the button emits zero velocity.

Signals#

positionChanged(numpy.ndarray)

Forwarded from the embedded joystick, and also emitted by the step buttons. Carries a two-element [vx, vy] array in the same output range as the joystick.

Properties#

stepFractionfloat

Fraction of full-scale used by the step buttons. Range (0, 1], default 0.25. Settable via stylesheet: qproperty-stepFraction: 0.5;

padColorQtGui.QColor

Forwarded to the embedded joystick and the step buttons. Settable via stylesheet: qproperty-padColor: #rrggbb;

knobColorQtGui.QColor

Forwarded to the embedded joystick. Settable via stylesheet: qproperty-knobColor: #rrggbb;

positionChanged#

alias of object

stepped#

alias of str

hasHeightForWidth()[source]#

Report that this widget maintains a 1:1 aspect ratio.

Return type:

bool

heightForWidth(width)[source]#

Return width, enforcing a square allocation.

Return type:

int

resizeEvent(event)[source]#

Centre a square sub-region by adjusting layout margins.

When the allocated rectangle is not square — which can happen when hasHeightForWidth() is not propagated correctly through deeply nested layouts — this pads out the shorter axis so the inner grid always operates in a square region.

Return type:

None

sizeHint()[source]#

Return the preferred widget size with a 1:1 aspect ratio.

Return type:

QSize

minimumSizeHint()[source]#

Return the minimum functional size with a 1:1 aspect ratio.

Two button widths plus a minimum joystick diameter of 60 px.

Return type:

QSize

stepFraction#

alias of float

setStepFraction(value)[source]#

Set the step-button velocity fraction.

Parameters:

value (float) – Fraction of full-scale in the range (0, 1].

Return type:

None

holdThreshold#

alias of int

setHoldThreshold(value)[source]#

Set the press duration that distinguishes a click from a hold.

Parameters:

value (int) – Threshold in milliseconds. A press shorter than this emits stepped; a press longer than this starts continuous velocity motion via positionChanged.

Return type:

None

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

Set the pad and step-button color.

Parameters:

color (QtGui.QColor) – Base color forwarded to the joystick pad and all four step buttons.

Return type:

None

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

Set the joystick knob color.

Parameters:

color (QtGui.QColor) – Base color forwarded to the embedded joystick knob.

Return type:

None

setRange(minimum, maximum)[source]#

Set the joystick output range for both axes.

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

fullscale#

alias of float

QTriangleButton#

class QInstrument.widgets.QJoystickPad.QTriangleButton(direction, *args, **kwargs)[source]#

Bases: QAbstractButton

Push-button that paints a filled equilateral-ish triangle.

The triangle points in the given direction. Visual state (hover, pressed, disabled) is rendered automatically.

Parameters:

direction (str) – One of 'up', 'down', 'left', 'right'.

color = 'QColor'#
setColor(color)[source]#

Set the button fill color and repaint.

Parameters:

color (QtGui.QColor) – Base fill color; pressed and border shades are derived automatically.

Return type:

None

sizeHint()[source]#

Return the preferred button size.

Return type:

QSize

paintEvent(event)[source]#

Paint the triangle, reflecting enabled/hover/pressed state.

Return type:

None