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:
QWidgetWidget 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
Shiftwill change the value in smaller steps, while holdingCtrlresults 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/Returnis 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
Attribute indicating this value box holds a float
Attribute indicating this value box holds an integer
editing(bool)Signal that emits when the user starts/stops editing the line edit
Get or set the maximum value of the box.
Get or set the minimum value of the box.
Get or set the value box name.
Get or set the value step size
Get or set the value box theme.
Get or set the current value.
value_changed(int)Signal that emits the box value if it changed
Get or set the type of value in the box (
intorfloat)Methods
Create a new value box.
Decrement the value by one step (modified by
Shift/Ctrl)enterEventChange the box style when the mouse hovers over it.
eventFilterHandle mouse button presses and movements.
Increment the value by one step (modified by
Shift/Ctrl)leaveEventChange the box style when the mouse stops hovering over it.
Set the fixed height of the value box.
Hide/show the value box and hide/show only the name label instead.
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_INTorTYPE_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
- 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 value: int#
Get or set the current value.
Provided values will be forced within minimum-maximum range.
- property value_type: int#
Get or set the type of value in the box (
intorfloat)