Re: Beginner Help
Jussi Salmela <[email protected]>
| Newsgroups | gmane.comp.python.pythoncard |
|---|---|
| Message-ID | <[email protected]> |
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. <http://us.rd.yahoo.com/evt=49936/*http://videogames.yahoo.com>
> ------------------------------------------------------------------------
>
> -------------------------------------------------------------------------
> 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/
-------------------------------------------------------------------------
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