wxPython 2.8 transition, python alike properties

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:

1. SetStatusText("welcome") to StatusText = "welcome" No errors, but won't show the message inside StatusBar?

2. Is there property for wx.SystemSettings.GetFont(wx.SYS_SYSTEM_FONT)?

3. Is there property for SetSizerAndFit(sizer) and SetSizer(sizer)?

4. wx.Button's SetToolTipString("ToolTip") to ToolTipString = "ToolTip" No errors, but won't show the tooltip for this button?

5. Is there property for wx.Buttons' SetDefault()?

6. Is there property for wx.TextCtrl's SetFocus()?

7. Is there property for wx.SpinCtrl's SetRange(1,1000)?

8. Is there property for wx.ListCtrl's + mixins:
  SetImageList(self.imagelist, wx.IMAGE_LIST_SMALL);
  SetColumnWidth(0, 150);
  SetStringItem(index, 1, item);
  SetItemData(index, idx);
  SetItemState(index, wx.LIST_STATE_SELECTED, wx.LIST_STATE_SELECTED);
  GetItemData(self.currentItem);

Thanks for help!

···

--
Basil Shubin
Freelance Software Developer
http://bashu.wordpress.com

(rest removed)

Wow Basil - sounds like your brief exposure to Dabo spoiled you! All
those things have been part of Dabo for years. Glad to see wxPython
improving, though.

···

On 1/10/07, Basil Shubin <bashu@yandex.ru> wrote:

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:

1. SetStatusText("welcome") to StatusText = "welcome" No errors, but
won't show the message inside StatusBar?

2. Is there property for

3. Is there property for

4. wx.Button's SetToolTipString("ToolTip") to ToolTipString = "ToolTip"
No errors, but won't show the tooltip for this button?

5. Is there property for

--

# p.d.

Peter Decker wrote:

···

On 1/10/07, Basil Shubin <bashu@yandex.ru> wrote:

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:

1. SetStatusText("welcome") to StatusText = "welcome" No errors, but
won't show the message inside StatusBar?

2. Is there property for

3. Is there property for

4. wx.Button's SetToolTipString("ToolTip") to ToolTipString = "ToolTip"
No errors, but won't show the tooltip for this button?

5. Is there property for

(rest removed)

Wow Basil - sounds like your brief exposure to Dabo spoiled you! All
those things have been part of Dabo for years. Glad to see wxPython
improving, though.

Yeh, Dabo is the hot thing! But for current project, it's not acceptable. But for all database-orientated GUI apps - it's the number one choice! :slight_smile:

Alas, but my question still unanswered :frowning:

--
Basil Shubin
Freelance Software Developer
http://bashu.wordpress.com

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 NameBright - Coming Soon

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Robin Dunn 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 NameBright - Coming Soon

Thank you for explanations and link!

···

--
Basil Shubin
Freelance Software Developer
http://bashu.wordpress.com

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@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 NameBright - Coming Soon

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

Ofcourse I meant exception :wink: access violations are only happening in
my Delphi environment I am confined to during working hours :wink:

- Jorgen

···

On 1/11/07, Jorgen Bodde <jorgen.maillist@gmail.com> wrote:

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@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 NameBright - Coming Soon
>
> --
> Robin Dunn
> Software Craftsman
> http://wxPython.org Java give you jitters? Relax with wxPython!
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
> For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org
>

Jorgen Bodde wrote:

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.

I think that the __slots__ feature will let us do something like this, however if I understand them correctly they only apply to the class with the __slots__ and so if you derive a new class it will still let you assign arbitrary attributes, or something like that. (Please correct me if I'm wrong.) If anybody has suggestions for making this work, and also for automatically building the __slots__ list let me know.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!