[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] Shortening multiple widget initializations to one line
From:       Shriramana Sharma <samjnaa () gmail ! com>
Date:       2012-12-10 16:59:16
Message-ID: CAH-HCWXppQgfQkYNNCyvsAUZ8svJeKdZ8E+Omuus2nWDMndD0g () mail ! gmail ! com
[Download RAW message or body]

Hello -- thanks all for your kind replies. The ideas for multiple
creation are all useful. One more point below:

On Mon, Dec 10, 2012 at 9:49 PM, Matt Newell <newellm@blur.com> wrote:
>>               self . p1xSpin, self . p1ySpin, self . c1xSpin, self . c1ySpin,
>>               self . c2xSpin, self . c2ySpin, self . p2xSpin, self . p2ySpin,
>>               self . pHxSpin, self . pHySpin = ( QSpinBox () for i in range ( 10 )
> )
>> but I got the error:
>>
>> Traceback (most recent call last):
>> AttributeError: 'MainWindow' object has no attribute 'p1xSpin'
>
> Probably some simple error here causing the line to try to get the attribute
> instead of set it.

Adding parantheses around the list corrected it. I forgot that only
when there is an enclosing parantheses or bracket (or with explicit \
like in C) will multi-line commands be recognized.

-- 
Shriramana Sharma
_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic