From: Aaron S. <az...@bu...> - 2007-11-06 13:46:14
|
Hi, Whilst reviewing the documentation here: http://pythoncard.sourceforge.net/framework/components/RadioGroup.html http://pythoncard.sourceforge.net/framework/components/ComboBox.html In both cases the documentation states that there is an attribute called "selected". In fact, there is not! The only way that I can see to access the selection is using the list and the item index into the list. # this call fails -- no attribute 'selected' # print self.components.radFavoriteDrink.selected # item # this works, using list and index items = self.components.radFavoriteDrink.items # list selection = self.components.radFavoriteDrink.selection # index print "Favorite drink is", items[selection] The same thing is true with the ComboBox. Am I mistaken, or is the documentation wrong? I've also found that this approach seems to be more reliable than the documentation: for component in self.components.iterkeys(): print component, "->",type(self.components[component]) print "\t",dir(type(self.components[component])) Any thoughts? Best, Aaron |
From: Kevin A. <al...@se...> - 2007-11-10 05:33:51
|
On Nov 6, 2007, at 5:42 AM, Aaron Stevens wrote: > Hi, > > Whilst reviewing the documentation here: > http://pythoncard.sourceforge.net/framework/components/RadioGroup.html > http://pythoncard.sourceforge.net/framework/components/ComboBox.html > > In both cases the documentation states that there is an attribute > called > "selected". > In fact, there is not! The only way that I can see to access the > selection is using the list and the item index into the list. > # this call fails -- no attribute 'selected' > # print self.components.radFavoriteDrink.selected # item > > > # this works, using list and index > items = self.components.radFavoriteDrink.items # list > selection = self.components.radFavoriteDrink.selection # index > print "Favorite drink is", items[selection] > > The same thing is true with the ComboBox. Am I mistaken, or is the > documentation wrong? > > I've also found that this approach seems to be more reliable than the > documentation: > > for component in self.components.iterkeys(): > print component, "->",type(self.components[component]) > print "\t",dir(type(self.components[component])) > > Any thoughts? > > Best, > Aaron Sorry about the confusion. Those doc pages were built from an earlier version and never updated. The tool that created them is built into the widgets sample under the File menu. The menu item Create Component Docs... brings up a directory selection dialog and then creates a component directory of HTML with one HTML page per component in the widgets sample. That way you can create your own docs dynamically. However, it doesn't currently deal with properties that aren't used in the resource file, but are available. For example, if you look at the RadioGroup component in PythonCard/ components/radiogroup.py you'll see that it inherits from the list.ContainerMixin class. So, in PythonCard/components/list.py you'll see the attribute is defined... selection = property(_getSelection, _setSelection) This should probably be part of the attribute spec as well, but since it isn't, the documentation tool code won't pick it up correctly. Without looking at the source files, probably the quickest way to see all the attributes is to just use dir() as you surmised. The wxPython attributes are CamelCase style and the PythonCard ones are lowercase, so a code snippet similar to the one below would dump all the attributes and methods specific to PythonCard. for n in dir(self.components.yourComponentName): if n[0][0] in 'abcdefghijklmnopqrstuvwxyz': print n ka |
From: Aaron S. <az...@bu...> - 2007-11-12 12:17:58
|
Kevin, Thanks for this information, and it certainly explains what I've seen. I have a work-around for myself (using some run-time introspection), but how do we go about getting the doc webpages updated? Who owns/maintains these webpages? Best, Aaron -----Original Message----- From: Kevin Altis [mailto:al...@se...] Sent: Saturday, November 10, 2007 12:34 AM To: Aaron Stevens Cc: pyt...@li... Subject: Re: [Pythoncard-users] RadioGroup/ComboBox -- documentation error? On Nov 6, 2007, at 5:42 AM, Aaron Stevens wrote: > Hi, > > Whilst reviewing the documentation here: > http://pythoncard.sourceforge.net/framework/components/RadioGroup.html > http://pythoncard.sourceforge.net/framework/components/ComboBox.html > > In both cases the documentation states that there is an attribute > called > "selected". > In fact, there is not! The only way that I can see to access the > selection is using the list and the item index into the list. > # this call fails -- no attribute 'selected' > # print self.components.radFavoriteDrink.selected # item > > > # this works, using list and index > items = self.components.radFavoriteDrink.items # list > selection = self.components.radFavoriteDrink.selection # index > print "Favorite drink is", items[selection] > > The same thing is true with the ComboBox. Am I mistaken, or is the > documentation wrong? > > I've also found that this approach seems to be more reliable than the > documentation: > > for component in self.components.iterkeys(): > print component, "->",type(self.components[component]) > print "\t",dir(type(self.components[component])) > > Any thoughts? > > Best, > Aaron Sorry about the confusion. Those doc pages were built from an earlier version and never updated. The tool that created them is built into the widgets sample under the File menu. The menu item Create Component Docs... brings up a directory selection dialog and then creates a component directory of HTML with one HTML page per component in the widgets sample. That way you can create your own docs dynamically. However, it doesn't currently deal with properties that aren't used in the resource file, but are available. For example, if you look at the RadioGroup component in PythonCard/ components/radiogroup.py you'll see that it inherits from the list.ContainerMixin class. So, in PythonCard/components/list.py you'll see the attribute is defined... selection = property(_getSelection, _setSelection) This should probably be part of the attribute spec as well, but since it isn't, the documentation tool code won't pick it up correctly. Without looking at the source files, probably the quickest way to see all the attributes is to just use dir() as you surmised. The wxPython attributes are CamelCase style and the PythonCard ones are lowercase, so a code snippet similar to the one below would dump all the attributes and methods specific to PythonCard. for n in dir(self.components.yourComponentName): if n[0][0] in 'abcdefghijklmnopqrstuvwxyz': print n ka |