QNodeEditor.widgets.value_box.ValueBox#

class QNodeEditor.widgets.value_box.ValueBox(name: str = '', value_type: int = 0, parent: ~PyQt5.QtWidgets.QWidget = None, theme: ~typing.Type[~QNodeEditor.themes.theme.Theme] = <class 'QNodeEditor.themes.dark.DarkTheme'>)#

Bases: QWidget

Widget with a numerical value that allows dragging or line edit updating.

The value box by default is divided into three sections. The middle section shows the name and value of the box, the outer sections are increment/decrement buttons.

If the user clicks and drags from the center section, the value will increase/decrease if the user moves the mouse to the right/left respectively. Holding Shift will change the value in smaller steps, while holding Ctrl results in larger steps.

If the user clicks on the value box, a line edit is shown for entering a custom value with the keyboard. The line edit closes when it loses focus or Enter/Return is pressed.

The value box can have a minimum and/or maximum value. If both are set, the increment/decrement buttons are hidden and the value box acts as a progress bar, showing at what percentage of the range between minimum and maximum the current value is.

Properties

TYPE_FLOAT

Attribute indicating this value box holds a float

TYPE_INT

Attribute indicating this value box holds an integer

editing(bool)

Signal that emits when the user starts/stops editing the line edit

maximum

Get or set the maximum value of the box.

minimum

Get or set the minimum value of the box.

name

Get or set the value box name.

step

Get or set the value step size

theme

Get or set the value box theme.

value

Get or set the current value.

value_changed(int)

Signal that emits the box value if it changed

value_type

Get or set the type of value in the box (int or float)

Methods

__init__

Create a new value box.

decrement

Decrement the value by one step (modified by Shift/Ctrl)

enterEvent

Change the box style when the mouse hovers over it.

eventFilter

Handle mouse button presses and movements.

increment

Increment the value by one step (modified by Shift/Ctrl)

leaveEvent

Change the box style when the mouse stops hovering over it.

set_height

Set the fixed height of the value box.

set_label_only

Hide/show the value box and hide/show only the name label instead.

set_range

Set the minimum and maximum value of the value box.

__init__(name: str = '', value_type: int = 0, parent: ~PyQt5.QtWidgets.QWidget = None, theme: ~typing.Type[~QNodeEditor.themes.theme.Theme] = <class 'QNodeEditor.themes.dark.DarkTheme'>)#

Create a new value box.

Parameters:
  • name (str, optional) – Name of the value box

  • value_type (int, optional) – Type of value (TYPE_INT or TYPE_FLOAT)

  • parent (QWidget, optional) – Parent widget (if any)

  • theme (Type[Theme], optional) – Theme for the value box (default: DarkTheme)

decrement() None#

Decrement the value by one step (modified by Shift/Ctrl)

Return type:

None

increment() None#

Increment the value by one step (modified by Shift/Ctrl)

Return type:

None

set_height(height: int) None#

Set the fixed height of the value box.

Parameters:

height (int) – Fixed height for the value box

Return type:

None

set_label_only(label_only: bool) None#

Hide/show the value box and hide/show only the name label instead.

Parameters:

label_only (bool) – Whether to only show the name label

Return type:

None

set_range(minimum: int, maximum: int) None#

Set the minimum and maximum value of the value box.

Parameters:
  • minimum (int or float) – New minimum value

  • maximum (int or float) – New maximum value

Return type:

None

TYPE_FLOAT: int = 1#

Attribute indicating this value box holds a float

Type:

int

TYPE_INT: int = 0#

Attribute indicating this value box holds an integer

Type:

int

editing(bool): Signal#

Signal that emits when the user starts/stops editing the line edit

Type:

Signal

property maximum: int#

Get or set the maximum value of the box.

If the current value is lower than the new maximum, the value will be set to the new maximum.

property minimum: int#

Get or set the minimum value of the box.

If the current value is lower than the new minimum, the value will be set to the new minimum.

property name: str#

Get or set the value box name.

property step: int#

Get or set the value step size

property theme: Type[Theme]#

Get or set the value box theme.

property value: int#

Get or set the current value.

Provided values will be forced within minimum-maximum range.

value_changed(int): Signal#

Signal that emits the box value if it changed

Type:

Signal or float

property value_type: int#

Get or set the type of value in the box (int or float)