qt_binder.binder¶
-
class
qt_binder.binder.Binder(*args, **traits)[source]¶ Bases:
traits.has_traits.HasStrictTraitsTraited proxy for a
QObjectclass.The default proxy traits will be automatically assigned by inspecting the Qt class specified in the
qclassclass attribute. Since this inspection process can be time consuming, compared to normal class construction, this will only be done the first time theBinderclass is instantiated.For those traits that proxy a Qt
Signal(or property that has aSignal), the Qt signal connection will only be made once a Traits listener is attached to the proxy trait.The
qobjcan only be assigned once in theBinder'slifetime.-
qclass¶ The
QObjectclass that is going to be wrapped by this class.
-
loopback_guard= Instance(LoopbackGuard, args=())¶ The loopback guard.
-
id= Str()¶ An ID string, if any. It should be a valid Python identifier.
-
-
class
qt_binder.binder.Composite(*args, **traits)[source]¶ Bases:
qt_binder.binder.BinderBase class for Binders that hold other Binders as children.
Their
QObjectsmay or may not have a similar parent-child relationship. TheCompositeis responsible for constructing its children, configuring them, and disposing of them.-
child_binders= Property(List(Instance(Binder)))¶ The child
Binderinstances. This will typically be a Property returning a list ofBindersthat are attributes.
-
-
class
qt_binder.binder.NChildren(*args, **traits)[source]¶ Bases:
qt_binder.binder.CompositeBase class for Composite Binders that have arbitrary unnamed children.
-
child_binders= List(Instance(Binder))¶ Any children. It will be filtered for Binders.
-
-
class
qt_binder.binder.QtTrait(*args, **metadata)[source]¶ Bases:
traits.trait_handlers.TraitTypeBase class for Qt proxy traits on
Binderclasses.Each subclass should override
get()andset(). AllQtTraitsubclasses are property-like traits.If there is a Qt
Signalthat should be connected to to propagate notifications, assign it to thesignalattribute. The QtSignalwill only be connected to when a Traits listener is attached to this trait.
-
class
qt_binder.binder.QtProperty(meta_prop, **metadata)[source]¶ Bases:
qt_binder.binder.QtTraitProxy trait for a Qt static property.
Pass in a
QMetaPropertyfrom theQMetaObject.
-
class
qt_binder.binder.QtDynamicProperty(default_value=None, **metadata)[source]¶ Bases:
qt_binder.binder.QtTraitA Qt dynamic property added to the
QObject.The dynamic property will be created on the
QObjectwhen it is added to theBinder. The default value given to this trait will be the initial value. It should be an object that can be passed toQVariant.Because most dynamic properties will be added this way to support Qt stylesheets, by default when the property is assigned a new value, the
QObjectassociated with theBinder(which should be aQWidget) will be made to redraw itself in order to reevaluate the stylesheet rules with the new value. Turn this off by passingstyled=Falseto the constructor.
-
class
qt_binder.binder.QtGetterSetter(getter_name, setter_name=None, **metadata)[source]¶ Bases:
qt_binder.binder.QtTraitProxy for a getter/setter pair of methods.
This is used for
value()/setValue()pairs of methods that are frequently found in Qt, but which are not bona fide Qt properties.If the names follow this convention, you only need to pass the name of the getter method. Otherwise, pass both.
-
class
qt_binder.binder.QtSlot(meta_method, **metadata)[source]¶ Bases:
qt_binder.binder.QtTraitProxy for a Qt slot method.
In general use, this trait will only be assigned to. If the slot takes no arguments, the value assigned is ignored. If the slot takes one argument, the value assigned is passed to the slot. If the slot takes more than one argument, the value assigned should be a tuple of the right size.
As a convenience, getting the value of this trait will return the slot method object itself to allow you to connect to it using the normal Qt mechanism.
The constructor should be passed the
QMetaMethodfor this slot.
-
class
qt_binder.binder.QtSignal(meta_method, **metadata)[source]¶ Bases:
qt_binder.binder.QtSlotProxy for a Qt signal method.
In general use, this trait will only be listened to for events that are emitted internally from Qt. However, it can be assigned values, with the same argument semantics as
QtSlot. LikeQtSlot, getting the value of this trait will return the signal method object itself for you to connect to it using the normal Qt mechanism.The constructor should be passed the
QMetaMethodfor this signal.
-
class
qt_binder.binder.Default(value)[source]¶ Bases:
objectSpecify a default value for an automatic QtTrait.
-
class
qt_binder.binder.Rename(qt_name, default=<undefined>)[source]¶ Bases:
objectSpecify that an automatic QtTrait be renamed.
Use at the class level of a
Binderto rename the trait to something else.For
QtSlottraits with multiple signatures, only the primary part of the name (without the mangled type signature) needs to be given.Since one cannot use both a
DefaultandRenameat the same time, one can also specify the default value here.