On Wed, 13 Jul 2011 11:32:11 -0400, Lic. José M. Rodriguez Bacallao <jmr...@gmail.com> wrote: > why this doesn't work? > > --------- i_widget.py --------- > > # dip imports > from dip.model import Str, Instance > > # PyQt4 imports > from PyQt4 import QtGui > > # imagis imports > from i_action_container import IActionContainer > > class IWidget(IActionContainer): > > # the identifier of the widget > id = Str() > > # the name of the widget > name = Str() > > # The PyQt4.QtGui.QWidget instance that implements the widget. > widget = Instance(QtGui.QWidget) > > # The parent of the internal widget. > parent = Instance(QtGui.QWidget) > > ----- widget.py -------- > > # dip imports > from dip.model import Model, implements, observe > > # imagis imports > from i_widget import IWidget > import PyQt4 > > @implements(IWidget) > class Widget(Model): > """ Base class for all ui widgets that can manage an internal > PyQt4.QtCore.QWidget. > """ > > @observe('IWidget.name') > def name(self, c): > print 'changing: ', c.new > > > @IWidget.widget.default > def widget(self): > return QtGui.QWidget() > > if __name__ == '__main__': > from dip.model import Instance, Str > from PyQt4 import QtGui > > class W(Widget): > > id = 'example.id' > name = Str('text') > > app = QtGui.QApplication([]) > w = W() > w.name = 'xxx' > w.widget.show() > app.exec_() > > the observer is never called
Either use... @observe('IWidget.name') def some_other_name(self, c): ...or (my preference)... @IWidget.name.observer def name(self, c): Phil _______________________________________________ PyQt mailing list PyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt