Re: Beginner Help

Jaggo <[email protected]>
Newsgroups gmane.comp.python.pythoncard
Message-ID <[email protected]>
God bless yew, this precisely what I needed.

[well duh, the dir(self.components.list1) simply did not occur to me.]

Jussi Salmela <[email protected]> wrote: Jaggo kirjoitti:
> Hello !
>
> I'm trying to implement a GUI to a Python application I'm writing 
> using Python Card.
>
> [If anyone is interested, the application:
> http://www.sourceforge.net/Gutenberg2pod/
> ]
>
> I've ran across a number of issues I failed to answer myself, the 
> biggest of which was:
>
> Regarding the component "list", I failed in attempting to create a 
> button which removed items from a list. I simply couldn't "guess" the 
> function which returned the index of items selected in a list. Had 
> this been Py-win I would have simply ran dir() on it, except that I 
> figure out what exactly was I dir-ing.
>
With a button having a command doItMan, the confusion can be removed 
like this:

def on_doItMan_command(self, event):
        lst = self.components.List1
        # First execution:
        print dir(lst)
        # My-my, what a load of interesting method names!
        # Second execution after finding a couple of
        # promising names:
        print dir(lst.GetSelection)
        print lst.GetSelection.__doc__
        print dir(lst.Delete)
        print lst.Delete.__doc__
        # Sure enough, these are what we need. Let's play a
        # little i.e. click the button without selecting anything
        # in the list:
        x = lst.GetSelection()
        print x, type(x)
        # Aha! The __doc__ is in error: it claims that when
        # no item is selected wx.NOT_FOUND is returned but
        # insted it returns -1. No big deal though!
        # Let's try the operation we are after:
        x = lst.GetSelection()
        if x != -1:
            lst.Delete(x)
        # IT WORKS!!!


HTH,
Jussi
> Thank you for your responce,
> Omer T.
>
> ------------------------------------------------------------------------
> Be a PS3 game guru.
> Get your game face on with the latest PS3 news and previews at Yahoo! 
> Games. 
> ------------------------------------------------------------------------
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys-and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> ------------------------------------------------------------------------
>
> _______________________________________________
> Pythoncard-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/pythoncard-users
>   


-- 
Jussi Salmela
http://personal.inet.fi/cool/operator/



 
---------------------------------
8:00? 8:25? 8:40?  Find a flick in no time
 with theYahoo! Search movie showtime shortcut.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

_______________________________________________
Pythoncard-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pythoncard-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.