A small proposed change to wx.StaticText

Is there any chance we could get something in the Python or C++ sources to make SetValue an alias for SetLabel on wxStaticText? It makes it messy to do a bunch of programmatic changes to a long list of controls because wxStaticText has to be treated "special" with its egregious SetLabel method.

I'd like to keep from having silliness like this in my code:

class StaticText(wx.StaticText):
     """A dumbheaded subclass so we can give wx.StaticText a SetValue method
     like it should have had all along. Just use this class in place of
     wx.StaticText, otherwise exactly the same.
     """
     def SetValue(self, *args, **kwargs):
         self.SetLabel(*args, **kwargs)

Such a change would be harmless. And us optimistic folks might even dare to hope that SetLabel would eventually become deprecated :slight_smile:

Any hope?

Thanks,
Michael

This inconsistency is all throughout wxPython: SetLabel, SetValue,
SetText, SetTitle, etc. That's why I constantly had to have the docs
open when I was coding: it was nearly impossible to remember which one
to use with which control.

That's a big reason I switched to Dabo: it wraps the wx controls and
gives them consistent naming. Want to set the text on a button? Or
maybe a checkbox? How about some static text? Or a menu item? In Dabo,
it's simple: obj.Caption = "Something". Anything that has a label,
some piece of displayed text, has a Caption property. The setter of
the Caption property handles the various inconsistencies for you, so
that you only have to remember one thing to get your task done.

···

On Mon, Aug 9, 2010 at 10:11 AM, Michael Hipp <Michael@hipp.com> wrote:

Is there any chance we could get something in the Python or C++ sources to
make SetValue an alias for SetLabel on wxStaticText? It makes it messy to do
a bunch of programmatic changes to a long list of controls because
wxStaticText has to be treated "special" with its egregious SetLabel method.

--

# p.d.

Is there any chance we could get something in the Python or C++ sources
to make SetValue an alias for SetLabel on wxStaticText? It makes it
messy to do a bunch of programmatic changes to a long list of controls
because wxStaticText has to be treated "special" with its egregious
SetLabel method.

They are two different things. A value is something that can be changed by the user while a label is something that can only be seen and is not editable. This way a widget is allowed to have both a label and a value, or just one, or neither.

I'd like to keep from having silliness like this in my code:

class StaticText(wx.StaticText):
"""A dumbheaded subclass so we can give wx.StaticText a SetValue method
like it should have had all along. Just use this class in place of
wx.StaticText, otherwise exactly the same.
"""
def SetValue(self, *args, **kwargs):
self.SetLabel(*args, **kwargs)

This is even simpler:

import wx
wx.StaticText.SetValue = wx.StaticText.SetLabel

Such a change would be harmless. And us optimistic folks might even dare
to hope that SetLabel would eventually become deprecated :slight_smile:

Any hope?

Probably not.

···

On 8/9/10 7:11 AM, Michael Hipp wrote:

--
Robin Dunn
Software Craftsman