qt_binder.widgets

Value-added wrappers for Qt widgets.


class qt_binder.widgets.TextField(*args, **traits)[source]

Bases: qt_binder.raw_widgets.LineEdit

Simple customization of a LineEdit.

The widget can be configured to update the model on every text change or only when Enter is pressed (or focus leaves). This emulates Traits UI’s TextEditor auto_set and enter_set configurations.

If a validator is set, invalid text will cause the background to be red.

value = Unicode(comparison_mode=NO_COMPARE)

The value to sync with the model.

mode = Enum('auto', 'enter')

Whether the value updates on every keypress, or when Enter is pressed (or focusOut).

valid = QtDynamicProperty(True)

Whether or not the current value is valid, for the stylesheet.

configure()[source]

class qt_binder.widgets.EditableComboBox(*args, **traits)[source]

Bases: qt_binder.raw_widgets.ComboBox

ComboBox with an editable text field.

We do not do bidirectional synchronization of the value with the model since that is typically not required for these use cases.

lineEdit_class

alias of TextField

value = Any(Undefined, comparison_mode=NO_COMPARE)

The selected value.

values = List(Tuple(Any, Unicode))

(object, label) pairs.

same_as = Callable(operator.eq)

Function that is used to compare two objects in the values list for equality. Defaults to normal Python equality.

configure()[source]

class qt_binder.widgets.EnumDropDown(*args, **traits)[source]

Bases: qt_binder.raw_widgets.ComboBox

Select from a set of preloaded choices.

value = Any(Undefined, comparison_mode=NO_COMPARE)

The selected value.

values = List(Tuple(Any, Unicode))

(object, label) pairs.

same_as = Callable(operator.eq)

Function that is used to compare two objects in the values list for equality. Defaults to normal Python equality.


class qt_binder.widgets.UIFile(filename, **traits)[source]

Bases: qt_binder.binder.Composite

Load a layout from a Qt Designer .ui file.

Widgets and layouts with names that do not start with underscores will be added as traits to this Binder. The binder_registry will be consulted to find the raw Binder to use for each widget. This can be overridden for any named widget using the overrides trait.

qclass
filename = Str()

The .ui file with the layout.

overrides = Dict(Str, Instance(Binder))

Override binders for named widgets.

construct(*args, **kwds)[source]

class qt_binder.widgets.BaseSlider(*args, **traits)[source]

Bases: qt_binder.raw_widgets.Slider

Base class for the other sliders.

Mostly for interface-checking and common defaults.

value = Any(0)

The value to synch with the model.

range = Tuple(Any(0), Any(99))

The inclusive range.

qt_value = Rename('value')

The underlying Qt value.

orientation = Default(<DocMock.Unknown>)

class qt_binder.widgets.IntSlider(*args, **traits)[source]

Bases: qt_binder.widgets.BaseSlider

value = Int(0)

The value to synch with the model.

range = Tuple(Int(0), Int(99))

The inclusive range.

configure()

class qt_binder.widgets.FloatSlider(*args, **traits)[source]

Bases: qt_binder.widgets.BaseSlider

value = Float(0.0)

The value to synch with the model.

range = Tuple(Float(0.0), Float(1.0))

The inclusive range.

precision = Int(1000)

The number of steps in the range.

configure()

class qt_binder.widgets.LogSlider(*args, **traits)[source]

Bases: qt_binder.widgets.FloatSlider

range = Tuple(Float(0.01), Float(100.0))

The inclusive range.


class qt_binder.widgets.RangeSlider(*args, **traits)[source]

Bases: qt_binder.binder.Composite

A slider with labels and a text entry field.

The root widget is a QWidget with a new property binder_class=RangeSlider. Stylesheets can reference it using the selector:

*[binder_class="RangeSlider"] {...}

This can be useful for styling the child QLabels and QLineEdit, for example to make a series of RangeSliders align.

qclass
value = Any(0)

The value to synch with the model.

range = Tuple(Any(0), Any(99))

The inclusive range.

label_format_func = Callable(six.text_type)

The formatting function for the labels.

field_format_func = Callable(six.text_type)

The formatting function for the text field. This is used only when the slider is setting the value.

field = Instance(TextField, args=())

The field widget.

slider = Instance(BaseSlider, factory=IntSlider, args=())

The slider widget.

construct()[source]
configure()[source]

Previous topic

qt_binder.type_registry

This Page