Dear Robin,
This is the workaround i was already trying to use. The main problem is that
the behavior when the callback is retriggered by a SetValue depends on the
number of characters in the text control. I cannot reset the flag when the
callback isn't called twice (in the case the number of characters is less
than 1024). The best thing would be to get an event with any call to
SetValue as this is what the reference permits!
If we knew where this 1024-behavior originates (i.e. Python or C++
framework?) it would be a great step for the solution.
Best regards
Oliver
···
-----Ursprüngliche Nachricht-----
Von: Robin Dunn [mailto:robin@alldunn.com]
Gesendet: Mittwoch, 7. Januar 2004 19:43
An: wxPython-users@lists.wxwindows.org
Betreff: Re: [wxPython-users] Strange bug in wxTextCtrl.SetValue
Oliver Walczak wrote:
Dear list,
For security purposes i need to check the data that i put into the text
controls of my dialog. Therefore i use handlers like EVT_TEXT(self,
ID_MY_TEXT_CTRL, self.OnChangeText) in my class that is derived from
wxFrame. OnChangeText looks similary to this:def OnChangeText(self, event):
ctrl = self.FindWindowById(ID_MY_TEXT_CTRL)
myString = event.GetString()
<do something with myString>
ctrl.SetValue(myString)This call shows different behaviors on different machines: if myString
takes
more than 1024 characters the program hangs up with a stack overflow. I
noticed that with more than 1024 characters in the string SetValue() seems
to call the callback consistently. I tested on two machines, both
identically installed with WindowsXP, Python 2.2.3, wxPython 2.4.2.4 and
win32all 1.6.2. On the first PC it worked regardless of the string's
length.
The callback gets called about 6 or 7 times but then it calms again. On
the
second one it crashes badly (i.e. if you don't feed a print statement or
something like that to OnChangeText you will not even get a traceback!)
after a series of calls.
One possibility could be that the SetValue is causing another recursive
EVT_TEXT on the one machine (or perhaps some other difference such as
different order of the events.) This can be caused by different
versions of the native controls as MS is sometimes highly inconsistent
at the low level things. The best thing to do would be to set a flag
before the SetValue and then check it at the begining of OnChangeText
and do nothing if it is set.
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org