Re: List components

"Azam, Naweed" <[email protected]> Thu, 19 Sep 2013 00:30:20 +0000
Newsgroups gmane.comp.python.pythoncard
Message-ID <[email protected]>
Thank you Steven - that worked perfectly!  That was exactly the solution for my problem.

Thanks also for the explanation of why I was seeing that behavior.

Regards,
Naweed.


-----Original Message-----
From: Steven D'Aprano [mailto:[email protected]] 
Sent: Wednesday, September 18, 2013 12:33 AM
To: [email protected]
Subject: Re: [Pythoncard-users] List components

On Wed, Sep 18, 2013 at 03:42:46AM +0000, Azam, Naweed wrote:
> Hello,
> 
> I have a question about list components.  When I try to specify text 
> to appear in a List box, each character appears on a line alone and 
> nothing shows up in the stringSelection drop down box.


I'm not an expert on Pythoncard, but given the description of the error, I would try passing the list of movie titles directly rather than a single string. E.g. instead of:

# clips is a list of movie titles
self.components.List1.items = str(clips)  

I would use this:

self.components.List1.items = clips  


This assumes that each movie title is a string.

Calling str() on a list of strings gives you a single string:

py> clips = ['Warm Bodies', 'Gone With The Wind', 'Alien']
py> str(clips)
"['Warm Bodies', 'Gone With The Wind', 'Alien']"


and then iterating over that string gives you individual characters, including those from the list itself:

py> for element in str(clips):
...     print element
... 
[
'
W
a
r
m
[... snip long output ...]


Does this help?



--
Steven

------------------------------------------------------------------------------
LIMITED TIME SALE - Full Year of Microsoft Training For Just $49.99!
1,500+ hours of tutorials including VisualStudio 2012, Windows 8, SharePoint 2013, SQL 2012, MVC 4, more. BEST VALUE: New Multi-Library Power Pack includes Mobile, Cloud, Java, and UX Design. Lowest price ever! Ends 9/20/13. 
http://pubads.g.doubleclick.net/gampad/clk?id=58041151&iu=/4140/ostg.clktrk
_______________________________________________
Pythoncard-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pythoncard-users

------------------------------------------------------------------------------
LIMITED TIME SALE - Full Year of Microsoft Training For Just $49.99!
1,500+ hours of tutorials including VisualStudio 2012, Windows 8, SharePoint
2013, SQL 2012, MVC 4, more. BEST VALUE: New Multi-Library Power Pack includes
Mobile, Cloud, Java, and UX Design. Lowest price ever! Ends 9/20/13. 
http://pubads.g.doubleclick.net/gampad/clk?id=58041151&iu=/4140/ostg.clktrk