Re: [PyQt] help with dip and PyQt4 widgets

2011-07-11 Thread Lic . José M . Rodriguez Bacallao
I think that's the way to go, I didn't think that solution. I like it.
Thanks very much.

On Mon, Jul 11, 2011 at 12:08 PM, Phil Thompson
 wrote:
> On Fri, 8 Jul 2011 09:49:30 -0400, Lic. José M. Rodriguez Bacallao
>  wrote:
>> hi folks, I am creating a composite widget with PyQt4 and Dip, the
>> problem I have is that when I use dip properties for setting PyQt4
>> properties in the constructor I am getting an error saying that the
>> underlying C++ object has been delete, I think this is due to the way
>> dip works because it call properties methods before the actual Qt4
>> widget as been created when I pass an initial value in the
>> constructor. When I construct the object with properties initial
>> values and the use the properties accesors to set the value, this
>> doens't happen. So, my question is, which is the right way to
>> construct a custom composite widget with dip?
>>
>> # dip imports
>> from dip.model import Model, Instance, Str
>>
>> # PyQt4 imports
>> from PyQt4 import QtCore, QtGui
>>
>> class Indicator(QtGui.QToolButton, Model):
>>
>>     # the indicator identifier, it must be unique for all indicators
>>     id = Str()
>>
>>     # the indicator text, this text will be shown
>>     # beside the icon if one is defined
>>     text = Str()
>>
>>     # the indicator tooltip
>>     tooltip = Str()
>>
>>     # the indicator icon
>>     icon = Instance(QtGui.QIcon)
>>
>>     @id.getter
>>     def id(self):
>>         print 'getting value'
>>         return self.objectName()
>>
>>     @id.setter
>>     def id(self, id):
>>         print 'setting value'
>>         self.setObjectName(id)
>>
>>     @text.getter
>>     def text(self):
>>         return self.text()
>>
>>     @text.setter
>>     def text(self, text):
>>         self.setText(text)
>>
>>     @tooltip.getter
>>     def tooltip(self):
>>         return self.toolTip()
>>
>>     @tooltip.setter
>>     def tooltip(self, tooltip):
>>         self.setToolTip(tooltip)
>>
>>     @icon.getter
>>     def icon(self):
>>         return self.icon()
>>
>>     @icon.setter
>>     def icon(self, icon):
>>         self.icon = icon
>>
>>     def perform(self):
>>         raise NotImplementedError
>>
>> if __name__ == '__main__':
>>     app = QtGui.QApplication([])
>>
>>     i = Indicator(text='xxx')
>>     i.show()
>>
>>     app.exec_()
>
> Your interpretation of the problem is correct - attributes are initialised
> (via setters if they have them) before __init__ is called.
>
> I'm not sure what you are trying to achieve. If you simply want to add
> behaviour to a QToolButton then I'd just sub-class it as normal. If you
> want to add properties then use pyqtProperty().
>
> If you want to create a new Indicator type then I would define an
> IIndicator interface and implement an adapter from QToolButton to
> IIndicator. The interface and the adapter together would be pretty much
> what you have above. If your code sticks to the IIndicator API then it will
> work with any widget for which a suitable adapter exists.
>
> Phil
>



-- 
Lic. José M. Rodriguez Bacallao
Centro de Biofisica Medica
-
Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo mismo.

Recuerda: El arca de Noe fue construida por aficionados, el titanic
por profesionales
-
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] help with dip and PyQt4 widgets

2011-07-11 Thread Phil Thompson
On Fri, 8 Jul 2011 09:49:30 -0400, Lic. José M. Rodriguez Bacallao
 wrote:
> hi folks, I am creating a composite widget with PyQt4 and Dip, the
> problem I have is that when I use dip properties for setting PyQt4
> properties in the constructor I am getting an error saying that the
> underlying C++ object has been delete, I think this is due to the way
> dip works because it call properties methods before the actual Qt4
> widget as been created when I pass an initial value in the
> constructor. When I construct the object with properties initial
> values and the use the properties accesors to set the value, this
> doens't happen. So, my question is, which is the right way to
> construct a custom composite widget with dip?
> 
> # dip imports
> from dip.model import Model, Instance, Str
> 
> # PyQt4 imports
> from PyQt4 import QtCore, QtGui
> 
> class Indicator(QtGui.QToolButton, Model):
> 
> # the indicator identifier, it must be unique for all indicators
> id = Str()
> 
> # the indicator text, this text will be shown
> # beside the icon if one is defined
> text = Str()
> 
> # the indicator tooltip
> tooltip = Str()
> 
> # the indicator icon
> icon = Instance(QtGui.QIcon)
> 
> @id.getter
> def id(self):
> print 'getting value'
> return self.objectName()
> 
> @id.setter
> def id(self, id):
> print 'setting value'
> self.setObjectName(id)
> 
> @text.getter
> def text(self):
> return self.text()
> 
> @text.setter
> def text(self, text):
> self.setText(text)
> 
> @tooltip.getter
> def tooltip(self):
> return self.toolTip()
> 
> @tooltip.setter
> def tooltip(self, tooltip):
> self.setToolTip(tooltip)
> 
> @icon.getter
> def icon(self):
> return self.icon()
> 
> @icon.setter
> def icon(self, icon):
> self.icon = icon
> 
> def perform(self):
> raise NotImplementedError
> 
> if __name__ == '__main__':
> app = QtGui.QApplication([])
> 
> i = Indicator(text='xxx')
> i.show()
> 
> app.exec_()

Your interpretation of the problem is correct - attributes are initialised
(via setters if they have them) before __init__ is called.

I'm not sure what you are trying to achieve. If you simply want to add
behaviour to a QToolButton then I'd just sub-class it as normal. If you
want to add properties then use pyqtProperty().

If you want to create a new Indicator type then I would define an
IIndicator interface and implement an adapter from QToolButton to
IIndicator. The interface and the adapter together would be pretty much
what you have above. If your code sticks to the IIndicator API then it will
work with any widget for which a suitable adapter exists.

Phil
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] help with dip and PyQt4 widgets

2011-07-08 Thread Darren Dale
Have you seen the discussion at
http://www.riverbankcomputing.co.uk/static/Docs/dip/ui_tutorial.html#creating-views-programmatically
, or 
http://www.riverbankcomputing.co.uk/static/Docs/dip/ui_tutorial.html#creating-views-with-qt-designer
?

On Fri, Jul 8, 2011 at 1:19 PM, Lic. José M. Rodriguez Bacallao
 wrote:
> but the view will need to be pure pyqt, not dip?
>
> On Fri, Jul 8, 2011 at 1:13 PM, Darren Dale  wrote:
>> Have you considered trying to decouple your model and view, as
>> described throughout the documentation?
>>
>> On Fri, Jul 8, 2011 at 1:04 PM, Lic. José M. Rodriguez Bacallao
>>  wrote:
>>> yes, I know, I read that in the docs, but, how to do something similar
>>> to what I want to achieve?
>>>
>>> On Fri, Jul 8, 2011 at 12:20 PM, Lic. José M. Rodriguez Bacallao
>>>  wrote:
 I tried that before and still getting the same error. I thinks is
 something like the C++ part of the widget is not created at the time
 when the properties methods are called to set my initial values as
 this  happen before __init__ is called.

 On Fri, Jul 8, 2011 at 12:05 PM, Demetrius Cassidy  
 wrote:
> You need to call QToolButton's __init__() method.
>
> class Indicator(QtGui.QToolButton, Model):
>     def __init__(self)
>        super(Indicator, self).__init__()
> On Fri, Jul 8, 2011 at 1:49 PM, Lic. José M. Rodriguez Bacallao
>  wrote:
>>
>> hi folks, I am creating a composite widget with PyQt4 and Dip, the
>> problem I have is that when I use dip properties for setting PyQt4
>> properties in the constructor I am getting an error saying that the
>> underlying C++ object has been delete, I think this is due to the way
>> dip works because it call properties methods before the actual Qt4
>> widget as been created when I pass an initial value in the
>> constructor. When I construct the object with properties initial
>> values and the use the properties accesors to set the value, this
>> doens't happen. So, my question is, which is the right way to
>> construct a custom composite widget with dip?
>>
>> # dip imports
>> from dip.model import Model, Instance, Str
>>
>> # PyQt4 imports
>> from PyQt4 import QtCore, QtGui
>>
>> class Indicator(QtGui.QToolButton, Model):
>>
>>    # the indicator identifier, it must be unique for all indicators
>>    id = Str()
>>
>>    # the indicator text, this text will be shown
>>    # beside the icon if one is defined
>>    text = Str()
>>
>>    # the indicator tooltip
>>    tooltip = Str()
>>
>>    # the indicator icon
>>    icon = Instance(QtGui.QIcon)
>>
>>    @id.getter
>>    def id(self):
>>        print 'getting value'
>>        return self.objectName()
>>
>>    @id.setter
>>    def id(self, id):
>>        print 'setting value'
>>        self.setObjectName(id)
>>
>>    @text.getter
>>    def text(self):
>>        return self.text()
>>
>>    @text.setter
>>    def text(self, text):
>>        self.setText(text)
>>
>>    @tooltip.getter
>>    def tooltip(self):
>>        return self.toolTip()
>>
>>    @tooltip.setter
>>    def tooltip(self, tooltip):
>>        self.setToolTip(tooltip)
>>
>>    @icon.getter
>>    def icon(self):
>>        return self.icon()
>>
>>    @icon.setter
>>    def icon(self, icon):
>>        self.icon = icon
>>
>>    def perform(self):
>>        raise NotImplementedError
>>
>> if __name__ == '__main__':
>>    app = QtGui.QApplication([])
>>
>>    i = Indicator(text='xxx')
>>    i.show()
>>
>>    app.exec_()
>>
>> --
>> Lic. José M. Rodriguez Bacallao
>> Centro de Biofisica Medica
>> -
>> Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo
>> mismo.
>>
>> Recuerda: El arca de Noe fue construida por aficionados, el titanic
>> por profesionales
>> -
>> ___
>> PyQt mailing list    PyQt@riverbankcomputing.com
>> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>



 --
 Lic. José M. Rodriguez Bacallao
 Centro de Biofisica Medica
 -
 Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo 
 mismo.

 Recuerda: El arca de Noe fue construida por aficionados, el titanic
 por profesionales
 -

>>>
>>>
>>>
>>> --
>>> Lic. José M. Rodriguez Bacallao
>>> Centro de Biofisica Medica
>>> -
>>> Todos somo

Re: [PyQt] help with dip and PyQt4 widgets

2011-07-08 Thread Lic . José M . Rodriguez Bacallao
but the view will need to be pure pyqt, not dip?

On Fri, Jul 8, 2011 at 1:13 PM, Darren Dale  wrote:
> Have you considered trying to decouple your model and view, as
> described throughout the documentation?
>
> On Fri, Jul 8, 2011 at 1:04 PM, Lic. José M. Rodriguez Bacallao
>  wrote:
>> yes, I know, I read that in the docs, but, how to do something similar
>> to what I want to achieve?
>>
>> On Fri, Jul 8, 2011 at 12:20 PM, Lic. José M. Rodriguez Bacallao
>>  wrote:
>>> I tried that before and still getting the same error. I thinks is
>>> something like the C++ part of the widget is not created at the time
>>> when the properties methods are called to set my initial values as
>>> this  happen before __init__ is called.
>>>
>>> On Fri, Jul 8, 2011 at 12:05 PM, Demetrius Cassidy  
>>> wrote:
 You need to call QToolButton's __init__() method.

 class Indicator(QtGui.QToolButton, Model):
     def __init__(self)
        super(Indicator, self).__init__()
 On Fri, Jul 8, 2011 at 1:49 PM, Lic. José M. Rodriguez Bacallao
  wrote:
>
> hi folks, I am creating a composite widget with PyQt4 and Dip, the
> problem I have is that when I use dip properties for setting PyQt4
> properties in the constructor I am getting an error saying that the
> underlying C++ object has been delete, I think this is due to the way
> dip works because it call properties methods before the actual Qt4
> widget as been created when I pass an initial value in the
> constructor. When I construct the object with properties initial
> values and the use the properties accesors to set the value, this
> doens't happen. So, my question is, which is the right way to
> construct a custom composite widget with dip?
>
> # dip imports
> from dip.model import Model, Instance, Str
>
> # PyQt4 imports
> from PyQt4 import QtCore, QtGui
>
> class Indicator(QtGui.QToolButton, Model):
>
>    # the indicator identifier, it must be unique for all indicators
>    id = Str()
>
>    # the indicator text, this text will be shown
>    # beside the icon if one is defined
>    text = Str()
>
>    # the indicator tooltip
>    tooltip = Str()
>
>    # the indicator icon
>    icon = Instance(QtGui.QIcon)
>
>    @id.getter
>    def id(self):
>        print 'getting value'
>        return self.objectName()
>
>    @id.setter
>    def id(self, id):
>        print 'setting value'
>        self.setObjectName(id)
>
>    @text.getter
>    def text(self):
>        return self.text()
>
>    @text.setter
>    def text(self, text):
>        self.setText(text)
>
>    @tooltip.getter
>    def tooltip(self):
>        return self.toolTip()
>
>    @tooltip.setter
>    def tooltip(self, tooltip):
>        self.setToolTip(tooltip)
>
>    @icon.getter
>    def icon(self):
>        return self.icon()
>
>    @icon.setter
>    def icon(self, icon):
>        self.icon = icon
>
>    def perform(self):
>        raise NotImplementedError
>
> if __name__ == '__main__':
>    app = QtGui.QApplication([])
>
>    i = Indicator(text='xxx')
>    i.show()
>
>    app.exec_()
>
> --
> Lic. José M. Rodriguez Bacallao
> Centro de Biofisica Medica
> -
> Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo
> mismo.
>
> Recuerda: El arca de Noe fue construida por aficionados, el titanic
> por profesionales
> -
> ___
> PyQt mailing list    PyQt@riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt

>>>
>>>
>>>
>>> --
>>> Lic. José M. Rodriguez Bacallao
>>> Centro de Biofisica Medica
>>> -
>>> Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo 
>>> mismo.
>>>
>>> Recuerda: El arca de Noe fue construida por aficionados, el titanic
>>> por profesionales
>>> -
>>>
>>
>>
>>
>> --
>> Lic. José M. Rodriguez Bacallao
>> Centro de Biofisica Medica
>> -
>> Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo mismo.
>>
>> Recuerda: El arca de Noe fue construida por aficionados, el titanic
>> por profesionales
>> -
>> ___
>> PyQt mailing list    PyQt@riverbankcomputing.com
>> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>



-- 
Lic. José M. Rodriguez Bacallao
Centro de Biofisica Med

Re: [PyQt] help with dip and PyQt4 widgets

2011-07-08 Thread Darren Dale
Have you considered trying to decouple your model and view, as
described throughout the documentation?

On Fri, Jul 8, 2011 at 1:04 PM, Lic. José M. Rodriguez Bacallao
 wrote:
> yes, I know, I read that in the docs, but, how to do something similar
> to what I want to achieve?
>
> On Fri, Jul 8, 2011 at 12:20 PM, Lic. José M. Rodriguez Bacallao
>  wrote:
>> I tried that before and still getting the same error. I thinks is
>> something like the C++ part of the widget is not created at the time
>> when the properties methods are called to set my initial values as
>> this  happen before __init__ is called.
>>
>> On Fri, Jul 8, 2011 at 12:05 PM, Demetrius Cassidy  
>> wrote:
>>> You need to call QToolButton's __init__() method.
>>>
>>> class Indicator(QtGui.QToolButton, Model):
>>>     def __init__(self)
>>>        super(Indicator, self).__init__()
>>> On Fri, Jul 8, 2011 at 1:49 PM, Lic. José M. Rodriguez Bacallao
>>>  wrote:

 hi folks, I am creating a composite widget with PyQt4 and Dip, the
 problem I have is that when I use dip properties for setting PyQt4
 properties in the constructor I am getting an error saying that the
 underlying C++ object has been delete, I think this is due to the way
 dip works because it call properties methods before the actual Qt4
 widget as been created when I pass an initial value in the
 constructor. When I construct the object with properties initial
 values and the use the properties accesors to set the value, this
 doens't happen. So, my question is, which is the right way to
 construct a custom composite widget with dip?

 # dip imports
 from dip.model import Model, Instance, Str

 # PyQt4 imports
 from PyQt4 import QtCore, QtGui

 class Indicator(QtGui.QToolButton, Model):

    # the indicator identifier, it must be unique for all indicators
    id = Str()

    # the indicator text, this text will be shown
    # beside the icon if one is defined
    text = Str()

    # the indicator tooltip
    tooltip = Str()

    # the indicator icon
    icon = Instance(QtGui.QIcon)

    @id.getter
    def id(self):
        print 'getting value'
        return self.objectName()

    @id.setter
    def id(self, id):
        print 'setting value'
        self.setObjectName(id)

    @text.getter
    def text(self):
        return self.text()

    @text.setter
    def text(self, text):
        self.setText(text)

    @tooltip.getter
    def tooltip(self):
        return self.toolTip()

    @tooltip.setter
    def tooltip(self, tooltip):
        self.setToolTip(tooltip)

    @icon.getter
    def icon(self):
        return self.icon()

    @icon.setter
    def icon(self, icon):
        self.icon = icon

    def perform(self):
        raise NotImplementedError

 if __name__ == '__main__':
    app = QtGui.QApplication([])

    i = Indicator(text='xxx')
    i.show()

    app.exec_()

 --
 Lic. José M. Rodriguez Bacallao
 Centro de Biofisica Medica
 -
 Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo
 mismo.

 Recuerda: El arca de Noe fue construida por aficionados, el titanic
 por profesionales
 -
 ___
 PyQt mailing list    PyQt@riverbankcomputing.com
 http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>>>
>>
>>
>>
>> --
>> Lic. José M. Rodriguez Bacallao
>> Centro de Biofisica Medica
>> -
>> Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo mismo.
>>
>> Recuerda: El arca de Noe fue construida por aficionados, el titanic
>> por profesionales
>> -
>>
>
>
>
> --
> Lic. José M. Rodriguez Bacallao
> Centro de Biofisica Medica
> -
> Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo mismo.
>
> Recuerda: El arca de Noe fue construida por aficionados, el titanic
> por profesionales
> -
> ___
> PyQt mailing list    PyQt@riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] help with dip and PyQt4 widgets

2011-07-08 Thread Lic . José M . Rodriguez Bacallao
yes, I know, I read that in the docs, but, how to do something similar
to what I want to achieve?

On Fri, Jul 8, 2011 at 12:20 PM, Lic. José M. Rodriguez Bacallao
 wrote:
> I tried that before and still getting the same error. I thinks is
> something like the C++ part of the widget is not created at the time
> when the properties methods are called to set my initial values as
> this  happen before __init__ is called.
>
> On Fri, Jul 8, 2011 at 12:05 PM, Demetrius Cassidy  
> wrote:
>> You need to call QToolButton's __init__() method.
>>
>> class Indicator(QtGui.QToolButton, Model):
>>     def __init__(self)
>>        super(Indicator, self).__init__()
>> On Fri, Jul 8, 2011 at 1:49 PM, Lic. José M. Rodriguez Bacallao
>>  wrote:
>>>
>>> hi folks, I am creating a composite widget with PyQt4 and Dip, the
>>> problem I have is that when I use dip properties for setting PyQt4
>>> properties in the constructor I am getting an error saying that the
>>> underlying C++ object has been delete, I think this is due to the way
>>> dip works because it call properties methods before the actual Qt4
>>> widget as been created when I pass an initial value in the
>>> constructor. When I construct the object with properties initial
>>> values and the use the properties accesors to set the value, this
>>> doens't happen. So, my question is, which is the right way to
>>> construct a custom composite widget with dip?
>>>
>>> # dip imports
>>> from dip.model import Model, Instance, Str
>>>
>>> # PyQt4 imports
>>> from PyQt4 import QtCore, QtGui
>>>
>>> class Indicator(QtGui.QToolButton, Model):
>>>
>>>    # the indicator identifier, it must be unique for all indicators
>>>    id = Str()
>>>
>>>    # the indicator text, this text will be shown
>>>    # beside the icon if one is defined
>>>    text = Str()
>>>
>>>    # the indicator tooltip
>>>    tooltip = Str()
>>>
>>>    # the indicator icon
>>>    icon = Instance(QtGui.QIcon)
>>>
>>>    @id.getter
>>>    def id(self):
>>>        print 'getting value'
>>>        return self.objectName()
>>>
>>>    @id.setter
>>>    def id(self, id):
>>>        print 'setting value'
>>>        self.setObjectName(id)
>>>
>>>    @text.getter
>>>    def text(self):
>>>        return self.text()
>>>
>>>    @text.setter
>>>    def text(self, text):
>>>        self.setText(text)
>>>
>>>    @tooltip.getter
>>>    def tooltip(self):
>>>        return self.toolTip()
>>>
>>>    @tooltip.setter
>>>    def tooltip(self, tooltip):
>>>        self.setToolTip(tooltip)
>>>
>>>    @icon.getter
>>>    def icon(self):
>>>        return self.icon()
>>>
>>>    @icon.setter
>>>    def icon(self, icon):
>>>        self.icon = icon
>>>
>>>    def perform(self):
>>>        raise NotImplementedError
>>>
>>> if __name__ == '__main__':
>>>    app = QtGui.QApplication([])
>>>
>>>    i = Indicator(text='xxx')
>>>    i.show()
>>>
>>>    app.exec_()
>>>
>>> --
>>> Lic. José M. Rodriguez Bacallao
>>> Centro de Biofisica Medica
>>> -
>>> Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo
>>> mismo.
>>>
>>> Recuerda: El arca de Noe fue construida por aficionados, el titanic
>>> por profesionales
>>> -
>>> ___
>>> PyQt mailing list    PyQt@riverbankcomputing.com
>>> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>>
>
>
>
> --
> Lic. José M. Rodriguez Bacallao
> Centro de Biofisica Medica
> -
> Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo mismo.
>
> Recuerda: El arca de Noe fue construida por aficionados, el titanic
> por profesionales
> -
>



-- 
Lic. José M. Rodriguez Bacallao
Centro de Biofisica Medica
-
Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo mismo.

Recuerda: El arca de Noe fue construida por aficionados, el titanic
por profesionales
-
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] help with dip and PyQt4 widgets

2011-07-08 Thread Darren Dale
http://www.riverbankcomputing.co.uk/static/Docs/dip/model_tutorial.html#models-and-init
:

The handling of the initial values of attributes is performed by the
meta-class of the Model class. This is done before the model’s
__init__() method (if there is one) is called.


On Fri, Jul 8, 2011 at 12:20 PM, Lic. José M. Rodriguez Bacallao
 wrote:
> I tried that before and still getting the same error. I thinks is
> something like the C++ part of the widget is not created at the time
> when the properties methods are called to set my initial values as
> this  happen before __init__ is called.
>
> On Fri, Jul 8, 2011 at 12:05 PM, Demetrius Cassidy  
> wrote:
>> You need to call QToolButton's __init__() method.
>>
>> class Indicator(QtGui.QToolButton, Model):
>>     def __init__(self)
>>        super(Indicator, self).__init__()
>> On Fri, Jul 8, 2011 at 1:49 PM, Lic. José M. Rodriguez Bacallao
>>  wrote:
>>>
>>> hi folks, I am creating a composite widget with PyQt4 and Dip, the
>>> problem I have is that when I use dip properties for setting PyQt4
>>> properties in the constructor I am getting an error saying that the
>>> underlying C++ object has been delete, I think this is due to the way
>>> dip works because it call properties methods before the actual Qt4
>>> widget as been created when I pass an initial value in the
>>> constructor. When I construct the object with properties initial
>>> values and the use the properties accesors to set the value, this
>>> doens't happen. So, my question is, which is the right way to
>>> construct a custom composite widget with dip?
>>>
>>> # dip imports
>>> from dip.model import Model, Instance, Str
>>>
>>> # PyQt4 imports
>>> from PyQt4 import QtCore, QtGui
>>>
>>> class Indicator(QtGui.QToolButton, Model):
>>>
>>>    # the indicator identifier, it must be unique for all indicators
>>>    id = Str()
>>>
>>>    # the indicator text, this text will be shown
>>>    # beside the icon if one is defined
>>>    text = Str()
>>>
>>>    # the indicator tooltip
>>>    tooltip = Str()
>>>
>>>    # the indicator icon
>>>    icon = Instance(QtGui.QIcon)
>>>
>>>    @id.getter
>>>    def id(self):
>>>        print 'getting value'
>>>        return self.objectName()
>>>
>>>    @id.setter
>>>    def id(self, id):
>>>        print 'setting value'
>>>        self.setObjectName(id)
>>>
>>>    @text.getter
>>>    def text(self):
>>>        return self.text()
>>>
>>>    @text.setter
>>>    def text(self, text):
>>>        self.setText(text)
>>>
>>>    @tooltip.getter
>>>    def tooltip(self):
>>>        return self.toolTip()
>>>
>>>    @tooltip.setter
>>>    def tooltip(self, tooltip):
>>>        self.setToolTip(tooltip)
>>>
>>>    @icon.getter
>>>    def icon(self):
>>>        return self.icon()
>>>
>>>    @icon.setter
>>>    def icon(self, icon):
>>>        self.icon = icon
>>>
>>>    def perform(self):
>>>        raise NotImplementedError
>>>
>>> if __name__ == '__main__':
>>>    app = QtGui.QApplication([])
>>>
>>>    i = Indicator(text='xxx')
>>>    i.show()
>>>
>>>    app.exec_()
>>>
>>> --
>>> Lic. José M. Rodriguez Bacallao
>>> Centro de Biofisica Medica
>>> -
>>> Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo
>>> mismo.
>>>
>>> Recuerda: El arca de Noe fue construida por aficionados, el titanic
>>> por profesionales
>>> -
>>> ___
>>> PyQt mailing list    PyQt@riverbankcomputing.com
>>> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>>
>
>
>
> --
> Lic. José M. Rodriguez Bacallao
> Centro de Biofisica Medica
> -
> Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo mismo.
>
> Recuerda: El arca de Noe fue construida por aficionados, el titanic
> por profesionales
> -
> ___
> PyQt mailing list    PyQt@riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] help with dip and PyQt4 widgets

2011-07-08 Thread Lic . José M . Rodriguez Bacallao
I tried that before and still getting the same error. I thinks is
something like the C++ part of the widget is not created at the time
when the properties methods are called to set my initial values as
this  happen before __init__ is called.

On Fri, Jul 8, 2011 at 12:05 PM, Demetrius Cassidy  wrote:
> You need to call QToolButton's __init__() method.
>
> class Indicator(QtGui.QToolButton, Model):
>     def __init__(self)
>        super(Indicator, self).__init__()
> On Fri, Jul 8, 2011 at 1:49 PM, Lic. José M. Rodriguez Bacallao
>  wrote:
>>
>> hi folks, I am creating a composite widget with PyQt4 and Dip, the
>> problem I have is that when I use dip properties for setting PyQt4
>> properties in the constructor I am getting an error saying that the
>> underlying C++ object has been delete, I think this is due to the way
>> dip works because it call properties methods before the actual Qt4
>> widget as been created when I pass an initial value in the
>> constructor. When I construct the object with properties initial
>> values and the use the properties accesors to set the value, this
>> doens't happen. So, my question is, which is the right way to
>> construct a custom composite widget with dip?
>>
>> # dip imports
>> from dip.model import Model, Instance, Str
>>
>> # PyQt4 imports
>> from PyQt4 import QtCore, QtGui
>>
>> class Indicator(QtGui.QToolButton, Model):
>>
>>    # the indicator identifier, it must be unique for all indicators
>>    id = Str()
>>
>>    # the indicator text, this text will be shown
>>    # beside the icon if one is defined
>>    text = Str()
>>
>>    # the indicator tooltip
>>    tooltip = Str()
>>
>>    # the indicator icon
>>    icon = Instance(QtGui.QIcon)
>>
>>    @id.getter
>>    def id(self):
>>        print 'getting value'
>>        return self.objectName()
>>
>>    @id.setter
>>    def id(self, id):
>>        print 'setting value'
>>        self.setObjectName(id)
>>
>>    @text.getter
>>    def text(self):
>>        return self.text()
>>
>>    @text.setter
>>    def text(self, text):
>>        self.setText(text)
>>
>>    @tooltip.getter
>>    def tooltip(self):
>>        return self.toolTip()
>>
>>    @tooltip.setter
>>    def tooltip(self, tooltip):
>>        self.setToolTip(tooltip)
>>
>>    @icon.getter
>>    def icon(self):
>>        return self.icon()
>>
>>    @icon.setter
>>    def icon(self, icon):
>>        self.icon = icon
>>
>>    def perform(self):
>>        raise NotImplementedError
>>
>> if __name__ == '__main__':
>>    app = QtGui.QApplication([])
>>
>>    i = Indicator(text='xxx')
>>    i.show()
>>
>>    app.exec_()
>>
>> --
>> Lic. José M. Rodriguez Bacallao
>> Centro de Biofisica Medica
>> -
>> Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo
>> mismo.
>>
>> Recuerda: El arca de Noe fue construida por aficionados, el titanic
>> por profesionales
>> -
>> ___
>> PyQt mailing list    PyQt@riverbankcomputing.com
>> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>



-- 
Lic. José M. Rodriguez Bacallao
Centro de Biofisica Medica
-
Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo mismo.

Recuerda: El arca de Noe fue construida por aficionados, el titanic
por profesionales
-
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] help with dip and PyQt4 widgets

2011-07-08 Thread Demetrius Cassidy
You need to call QToolButton's __init__() method.

class Indicator(QtGui.QToolButton, Model):
def __init__(self)
   super(Indicator, self).__init__()

On Fri, Jul 8, 2011 at 1:49 PM, Lic. José M. Rodriguez Bacallao <
jmr...@gmail.com> wrote:

> hi folks, I am creating a composite widget with PyQt4 and Dip, the
> problem I have is that when I use dip properties for setting PyQt4
> properties in the constructor I am getting an error saying that the
> underlying C++ object has been delete, I think this is due to the way
> dip works because it call properties methods before the actual Qt4
> widget as been created when I pass an initial value in the
> constructor. When I construct the object with properties initial
> values and the use the properties accesors to set the value, this
> doens't happen. So, my question is, which is the right way to
> construct a custom composite widget with dip?
>
> # dip imports
> from dip.model import Model, Instance, Str
>
> # PyQt4 imports
> from PyQt4 import QtCore, QtGui
>
> class Indicator(QtGui.QToolButton, Model):
>
># the indicator identifier, it must be unique for all indicators
>id = Str()
>
># the indicator text, this text will be shown
># beside the icon if one is defined
>text = Str()
>
># the indicator tooltip
>tooltip = Str()
>
># the indicator icon
>icon = Instance(QtGui.QIcon)
>
>@id.getter
>def id(self):
>print 'getting value'
>return self.objectName()
>
>@id.setter
>def id(self, id):
>print 'setting value'
>self.setObjectName(id)
>
>@text.getter
>def text(self):
>return self.text()
>
>@text.setter
>def text(self, text):
>self.setText(text)
>
>@tooltip.getter
>def tooltip(self):
>return self.toolTip()
>
>@tooltip.setter
>def tooltip(self, tooltip):
>self.setToolTip(tooltip)
>
>@icon.getter
>def icon(self):
>return self.icon()
>
>@icon.setter
>def icon(self, icon):
>self.icon = icon
>
>def perform(self):
>raise NotImplementedError
>
> if __name__ == '__main__':
>app = QtGui.QApplication([])
>
>i = Indicator(text='xxx')
>i.show()
>
>app.exec_()
>
> --
> Lic. José M. Rodriguez Bacallao
> Centro de Biofisica Medica
> -
> Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo
> mismo.
>
> Recuerda: El arca de Noe fue construida por aficionados, el titanic
> por profesionales
> -
> ___
> PyQt mailing listPyQt@riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[PyQt] help with dip and PyQt4 widgets

2011-07-08 Thread Lic . José M . Rodriguez Bacallao
hi folks, I am creating a composite widget with PyQt4 and Dip, the
problem I have is that when I use dip properties for setting PyQt4
properties in the constructor I am getting an error saying that the
underlying C++ object has been delete, I think this is due to the way
dip works because it call properties methods before the actual Qt4
widget as been created when I pass an initial value in the
constructor. When I construct the object with properties initial
values and the use the properties accesors to set the value, this
doens't happen. So, my question is, which is the right way to
construct a custom composite widget with dip?

# dip imports
from dip.model import Model, Instance, Str

# PyQt4 imports
from PyQt4 import QtCore, QtGui

class Indicator(QtGui.QToolButton, Model):

# the indicator identifier, it must be unique for all indicators
id = Str()

# the indicator text, this text will be shown
# beside the icon if one is defined
text = Str()

# the indicator tooltip
tooltip = Str()

# the indicator icon
icon = Instance(QtGui.QIcon)

@id.getter
def id(self):
print 'getting value'
return self.objectName()

@id.setter
def id(self, id):
print 'setting value'
self.setObjectName(id)

@text.getter
def text(self):
return self.text()

@text.setter
def text(self, text):
self.setText(text)

@tooltip.getter
def tooltip(self):
return self.toolTip()

@tooltip.setter
def tooltip(self, tooltip):
self.setToolTip(tooltip)

@icon.getter
def icon(self):
return self.icon()

@icon.setter
def icon(self, icon):
self.icon = icon

def perform(self):
raise NotImplementedError

if __name__ == '__main__':
app = QtGui.QApplication([])

i = Indicator(text='xxx')
i.show()

app.exec_()

-- 
Lic. José M. Rodriguez Bacallao
Centro de Biofisica Medica
-
Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo mismo.

Recuerda: El arca de Noe fue construida por aficionados, el titanic
por profesionales
-
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt