From: Jaggo <jag...@ya...> - 2007-03-23 14:15:48
|
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. 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. |
From: Jussi S. <jus...@pp...> - 2007-03-23 17:35:59
|
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 > Pyt...@li... > https://lists.sourceforge.net/lists/listinfo/pythoncard-users > -- Jussi Salmela http://personal.inet.fi/cool/operator/ |
From: Jaggo <jag...@ya...> - 2007-03-24 16:41:20
|
God bless yew, this precisely what I needed. [well duh, the dir(self.components.list1) simply did not occur to me.] Jussi Salmela <jus...@pp...> 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 > Pyt...@li... > 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. |
From: Kevin A. <al...@se...> - 2007-03-26 15:46:40
|
On Mar 23, 2007, at 7:15 AM, Jaggo wrote: > 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. > > Thank you for your responce, > Omer T. > All the component source files are in the PythonCard/components directory, so you could look at list.py in the case of the 'list' component. In addition, if you run your application with the shell, either via the -s or -d command-line option, you can inspect your components for attributes simply by using command completion in the shell. In your case, at the prompt you could type... >>> self.components.list1. and when you type the period (dot) you will see a list of attributes and methods. What you probably want is 'selection' and possibly 'stringSelection'. You can also look at all of the PythonCard samples and tools to see how things are done. In general, you will see a lot of methods that are in mixedCase style that are aliases for CamelCase wxPython methods (e.g. delete() is the same as Delete()), and for the most common get/set type of methods PythonCard provides an attribute like 'selection' that does the work of two methods such as GetSelection and SetSelection. Finally, in the PythonCard/samples/widgets/widgets.py sample there is a menu option under the File menu called 'Create Component Docs...' that will allow you to create a directory of HTML files with some simplistic documentation of your currently installed components. ka |