Enaml notification operator does not listen to create events

23 views
Skip to first unread message

Brad Buran

unread,
Jul 9, 2021, 1:45:35 PM7/9/21
to Enaml
I've managed to boil down the problem to the simplest possible code:

from atom.api import Atom, Typed
from enaml.core.api import Declarative, d_
from enaml.widgets.api import MainWindow

class Bar(Atom):
    pass

class Foo(Declarative):
    x = d_(Typed(Bar))

enamldef Main(MainWindow):
    Foo:
        initialized ::
            self.x = Bar()

        x ::
            # This never gets triggered!
            print('First foo changed')

    Foo:
        initialized ::
            self.x
            self.x = Bar()

        x ::
            # This gets triggered!
            print('Second foo changed')

The key difference between appears to be that the first generates only one event (create) whereas the second generates a create followed by an update event. I'd like the :: operator to respond to both create and update notifications. Is there any simple approach to solving this problem?

Chris Colbert

unread,
Jul 9, 2021, 1:48:24 PM7/9/21
to Brad Buran, Enaml
The notification operator ignores ‘create’ events by design. It specifically only responds to changes in the value, which would be an ‘update’ event.

--
You received this message because you are subscribed to the Google Groups "Enaml" group.
To unsubscribe from this group and stop receiving emails from it, send an email to enaml+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/enaml/a0e6017f-42a7-4c1d-bc78-da8d49c87616n%40googlegroups.com.

Brad Buran

unread,
Jul 9, 2021, 1:53:10 PM7/9/21
to Enaml
Thank you. I had a suspicion this was the case. I will see if I can find a different approach to the problem.
Reply all
Reply to author
Forward
0 new messages