[wxPython-users] wxPython 2.8 transition, python alike properties

Jorgen Bodde jorgen.maillist at gmail.com
Thu Jan 11 00:11:11 PST 2007


Robin,

Just out of curiousity.. when I read this it seemed very nice to have
getters and setter, however the distinction between methods with a Get
and Set prefix and the ones only having a Get prefix is not intuitive,
and if I would be programming, I would stick to the traditional
methods because of Python's way of accepting any property even when it
does not exist.

What about creating a setter or getter that returns an access
violation ? If for example;

mywindow.Default = true

and I would use:

if mywindow.Default:
  ...

an access violation would occur because there is no GetDefault
binding. This way the python-like properties are much more valuable. I
am not sure how simple this is to implement, but only implementing
properties that can only be read/writable sounds confusing.

Regards,
- Jorgen

On 1/10/07, Robin Dunn <robin at alldunn.com> wrote:
> Basil Shubin wrote:
> > Hello friends!
> >
> > I have make transition from 2.6 to 2.8. One of the innovation of new
> > wxPython is python alike properties! But for some case I don't realise
> > how to use them, or exactly how to transite to them from 2.6 branch.
> > Here a task list:
>
> The general rule is that there are properties in a class for any
> non-static method that has a GetFoo name that takes no parameters.  If
> there is also a matching SetFoo that takes only one parameter then it
> will be set as the setter for that property.
>
> >
> > 1. SetStatusText("welcome") to StatusText = "welcome" No errors, but
> > won't show the message inside StatusBar?
>
> I assume you are talking about wx.Frame here.  There is no GetStatusText
> so there is no property, so you are just assigning to a normal attribute
> named StatusText.
>
> >
> > 2. Is there property for wx.SystemSettings.GetFont(wx.SYS_SYSTEM_FONT)?
>
> No, it is a staticmethod.
>
> >
> > 3. Is there property for SetSizerAndFit(sizer) and SetSizer(sizer)?
>
>
> No getter for the first.  There is a property for 'Sizer' though.
>
> >
> > 4. wx.Button's SetToolTipString("ToolTip") to ToolTipString = "ToolTip"
> > No errors, but won't show the tooltip for this button?
>
> No matching getters.
>
> >
> > 5. Is there property for wx.Buttons' SetDefault()?
>
> No getter
>
> >
> > 6. Is there property for wx.TextCtrl's SetFocus()?
>
> No getter
>
>
> >
> > 7. Is there property for wx.SpinCtrl's SetRange(1,1000)?
>
> No, but there are properties for 'Min' and 'Max'
>
> >
> > 8. Is there property for wx.ListCtrl's + mixins:
> >     SetImageList(self.imagelist, wx.IMAGE_LIST_SMALL);
>
> Yes, but there shouldn't be because the getter takes a parameter, and
> the setter takes more than one.  It's a bug that there is one there
> currently.
>
> >     SetColumnWidth(0, 150);
> >     SetStringItem(index, 1, item);
> >     SetItemData(index, idx);
> >     SetItemState(index, wx.LIST_STATE_SELECTED, wx.LIST_STATE_SELECTED);
> >     GetItemData(self.currentItem);
>
> Each of these has too many parameters.
>
> BTW, the properties are all listed in the class docs in the
> Python-specific docs at http://wxpython.wxcommunity.com/docs/api/
>
> --
> Robin Dunn
> Software Craftsman
> http://wxPython.org  Java give you jitters?  Relax with wxPython!
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wxPython-users-unsubscribe at lists.wxwidgets.org
> For additional commands, e-mail: wxPython-users-help at lists.wxwidgets.org
>
>




More information about the wxpython-users mailing list