I wonder if I am missing something already in wxPython. If not, consider
this a suggestion for future versions.
In Borland Delphi, the individual widgets (components) had a spare field
that could be used to store an integer for whatever purpose the
developer wanted. I would like to see something like this in wx. Here's
where I could use something like this. I designed a form with a series
of buttons. Several of the buttons could share the same event handler if
the event handler could figure out which button invoked it. I supposed
I could use reflection to figure out which button, but it would be nice
if the event handler could check this spare field in the button.
I'm using wxGlade for the design. The latest version allows you to
attach properties to the widgets which it implements by calling a SetXXX
method. To get this to work, I had to derive a button from wxButton that
had a SetXXX method.
In Borland Delphi, the individual widgets (components) had a spare field
that could be used to store an integer for whatever purpose the
developer wanted. I would like to see something like this in wx. Here’s
where I could use something like this. I designed a form with a series
of buttons. Several of the buttons could share the same event handler if
the event handler could figure out which button invoked it. I supposed
I could use reflection to figure out which button, but it would be nice
if the event handler could check this spare field in the button.
Since every button has it’s own ID, isn’t .GetID() enough to find which is which?
I’m using wxGlade for the design. The latest version allows you to
attach properties to the widgets which it implements by calling a SetXXX
method. To get this to work, I had to derive a button from wxButton that
had a SetXXX method.
As I find it more efficient to do all my GUI design by hand, I don’t know what wxGlade’s capabilities are. Does it let you enter arbitrary code? As all the wxPython objects are regular python objects, you can set any arbitrary attribute on them if you want. I personally find that “poor practice”, but that’s me.
You could do ‘button.whichButton = 5’ if you wanted. Even though ‘whichButton’ doesn’t exist before.
In Borland Delphi, the individual widgets (components) had a spare field
that could be used to store an integer for whatever purpose the
developer wanted. I would like to see something like this in wx. Here's
where I could use something like this. I designed a form with a series
of buttons. Several of the buttons could share the same event handler if
the event handler could figure out which button invoked it. I supposed
I could use reflection to figure out which button, but it would be nice
if the event handler could check this spare field in the button.
You could do something like this (using a number keypad, as an example):
Hi,
I'm using a wx.TextCtrl with a black background.
Let say my TextCtrl instance is 't'.
When I do t.Remove(t.GetLastPosition()-10, t.GetLastPosition())
The text is selected THEN it is deleted.
As the selection color is Blue it makes a graphical glitch.
Is there a way to set selection color to background color or perhaps another
way to avoid the glitch??
You could try to use something like:
yourTextCtrl.Freeze()
# your code to delete text and whatever you want here
On Mon, 2007-12-03 at 01:18 -0600, Zach Heilig wrote:
> In Borland Delphi, the individual widgets (components) had a spare field
> that could be used to store an integer for whatever purpose the
> developer wanted. I would like to see something like this in wx. Here's
> where I could use something like this. I designed a form with a series
> of buttons. Several of the buttons could share the same event handler if
> the event handler could figure out which button invoked it. I supposed
> I could use reflection to figure out which button, but it would be nice
> if the event handler could check this spare field in the button.
>
You could do something like this (using a number keypad, as an example):
Thanks for the example. I think it should work, but I was hoping to
avoid using the widget's label. It's possible that you might want to
change the label text (say for internationalization) without changing
the underlying code.
Thanks for the example. I think it should work, but I was hoping to
avoid using the widget's label. It's possible that you might want to
change the label text (say for internationalization) without changing
the underlying code.
right, the label isn't necessarily the best key. yous can use the Label, you can use the ID (which you can get by .getID(), after creating the object with the default).
Most importantly though -- this is Python! it's been said before in this thread, but it bears repeating: you can any attribute you want to any object, no problem at all. For instance, using the previous example, I might do:
Yes, I understand this and have used it. I still think it would be nice
if there were an 'official' data member that the user could use for
whatever was needed.
Actually, there is one in C++ but wxPython is already using it to store a pointer to the PyObject which is the Python proxy of the C++ object. This is what allows you to be able to assign arbitrary attributes to the original proxy instance and then later when something like event.GetEventObject() returns a proxy it is the same one that you assigned attributes to instead of a new instance that proxies the same C++ object.
···
On Mon, 2007-12-03 at 11:19 -0800, Christopher Barker wrote:
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!