hey guys, 

I want to clarify what PSEP102 really means when it says to replace Qt getters 
and setters to Python properties.  I think that it means replacing syntax like 

'''excerpt counterlabel.py

A PyQt custom widget example for Qt Designer.

Copyright (C) 2006 David Boddie <[email protected]>
Copyright (C) 2005-2006 Trolltech ASA. All rights reserved.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
'''

class CounterLabel(QtGui.QWidget)
    def __init__(self, parent = None):

        QtGui.QWidget.__init__(self, parent)
        self.setAutoFillBackground(False)

        self._font = QtGui.QFont()

    def getFont(self):
        return self._font

    def setFont(self, font):
        self._font = font

    font = QtCore.Property("QFont", getFont, setFont)


with something like:

class CounterLabel(QtGui.QWidget)
    def __init__(self, parent = None):

        QtGui.QWidget.__init__(self, parent)
        self.setAutoFillBackground(False)

        self.font = QtGui.QFont()

if there are some custom functions needed for the property, it would still be:
class CounterLabel(QtGui.QWidget)

    def __init__(self, parent = None):

        QtGui.QWidget.__init__(self, parent)
        self.setAutoFillBackground(False)

        self._font = QtGui.QFont()

    def getFont(self):
        return self._font

    def setFont(self, font):
        self._font = font
        self.rescale()
        self.reposition()

    font = QtCore.Property("QFont", getFont, setFont)

unless we don't need the type, in which case we would use the regular python 
property syntax to get the last line to be:
    font = property(getFont,setFont)


maybe the original author could verify/correct?

-d


      
_______________________________________________
PySide mailing list
[email protected]
http://lists.openbossa.org/listinfo/pyside

Reply via email to