QJoystick#
- class QInstrument.widgets.QJoystick.QJoystick(*args, fullscale=None, **kwargs)[source]#
Bases:
QWidgetMouse-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].xis positive to the right;yis 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.
- 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:
- 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 withqproperty-padColor: #rrggbb;.- Parameters:
color (QtGui.QColor) – Base color for the pad.
- Return type:
- 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 withqproperty-knobColor: #rrggbb;.- Parameters:
color (QtGui.QColor) – Base color for the knob.
- Return type:
- 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 emitpositionChanged.- Parameters:
fx (float) – Horizontal fraction in
[-1, 1]. Positive is right.fy (float) – Vertical fraction in
[-1, 1]. Positive is upward.
- Return type:
- mousePressEvent(event)[source]#
Activate dragging when the press lands inside the knob.
- Return type: