qt_binder.binder
¶
-
class
qt_binder.binder.
Binder
(*args, **traits)[source]¶ Bases:
traits.has_traits.HasStrictTraits
Traited proxy for a
QObject
class.The default proxy traits will be automatically assigned by inspecting the Qt class specified in the
qclass
class attribute. Since this inspection process can be time consuming, compared to normal class construction, this will only be done the first time theBinder
class 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
qobj
can only be assigned once in theBinder's
lifetime.-
qclass
¶ The
QObject
class 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.Binder
Base class for Binders that hold other Binders as children.
Their
QObjects
may or may not have a similar parent-child relationship. TheComposite
is responsible for constructing its children, configuring them, and disposing of them.-
child_binders
= Property(List(Instance(Binder)))¶ The child
Binder
instances. This will typically be a Property returning a list ofBinders
that are attributes.
-
-
class
qt_binder.binder.
NChildren
(*args, **traits)[source]¶ Bases:
qt_binder.binder.Composite
Base 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.TraitType
Base class for Qt proxy traits on
Binder
classes.Each subclass should override
get()
andset()
. AllQtTrait
subclasses are property-like traits.If there is a Qt
Signal
that should be connected to to propagate notifications, assign it to thesignal
attribute. The QtSignal
will 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.QtTrait
Proxy trait for a Qt static property.
Pass in a
QMetaProperty
from theQMetaObject
.
-
class
qt_binder.binder.
QtDynamicProperty
(default_value=None, **metadata)[source]¶ Bases:
qt_binder.binder.QtTrait
A Qt dynamic property added to the
QObject
.The dynamic property will be created on the
QObject
when 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
QObject
associated 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=False
to the constructor.
-
class
qt_binder.binder.
QtGetterSetter
(getter_name, setter_name=None, **metadata)[source]¶ Bases:
qt_binder.binder.QtTrait
Proxy 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.QtTrait
Proxy 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
QMetaMethod
for this slot.
-
class
qt_binder.binder.
QtSignal
(meta_method, **metadata)[source]¶ Bases:
qt_binder.binder.QtSlot
Proxy 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
QMetaMethod
for this signal.
-
class
qt_binder.binder.
Default
(value)[source]¶ Bases:
object
Specify a default value for an automatic QtTrait.
-
class
qt_binder.binder.
Rename
(qt_name, default=<undefined>)[source]¶ Bases:
object
Specify that an automatic QtTrait be renamed.
Use at the class level of a
Binder
to rename the trait to something else.For
QtSlot
traits 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
Default
andRename
at the same time, one can also specify the default value here.