...
Sure. Just as I said above, you need to ensure that SetSelection is
called *after* the default processing has happened, so in your example
just add this to your __init__
wxCallAfter(self.tc.SetSelection, 0, 0)
Nice. This is working. I find this not obvious. I will study the case more.
...
Sure. Just as I said above, you need to ensure that SetSelection is called *after* the default processing has happened, so in your example just add this to your __init__
wxCallAfter(self.tc.SetSelection, 0, 0)
Nice. This is working. I find this not obvious. I will study the case more.
It just schedules self.tc.SetSelection(0,0) to be called just before the next IDLE events are sent. So since the default behavior of selecting all of the text also happens sometime after the current scope, you are causing the SetSelection to be called after that undoing hte default behavior.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
Although this works fine most of the time, I am running into a problem
whose symptoms are:
Traceback (most recent call last):
File "E:\software\python\lib\site-packages\wxPython\wx.py",
line 1712, in <lambda>
lambda event: event.callable(*event.args, **event.kw) )
File "E:\software\python\lib\site-packages\wxPython\controls.py",
line 753, in SetSelection
val = controlsc.wxTextCtrl_SetSelection(self, *_args, **_kwargs)
TypeError: Type error in argument 1 of wxTextCtrl_SetSelection.
Expected _wxTextCtrl_p.
This is when my application closes and destroys the window, and I think
it may get focus as part of the closing process. I think my handler then
registers a the call on SetSelection which then later is invoked on a
"non-existent" window.
Ideas?
In article <3FAAF905.2090302@alldunn.com>, Robin Dunn
<robin@alldunn.com> writes
···
Jean-Michel Fauth wrote:
Hi.
Robin Dunn wrote:
...
Sure. Just as I said above, you need to ensure that SetSelection is
called *after* the default processing has happened, so in your example
just add this to your __init__
wxCallAfter(self.tc.SetSelection, 0, 0)
Nice. This is working. I find this not obvious. I will study the case more.
It just schedules self.tc.SetSelection(0,0) to be called just before the
next IDLE events are sent. So since the default behavior of selecting
all of the text also happens sometime after the current scope, you are
causing the SetSelection to be called after that undoing hte default
behavior.
Although this works fine most of the time, I am running into a problem
whose symptoms are:
Traceback (most recent call last):
File "E:\software\python\lib\site-packages\wxPython\wx.py",
line 1712, in <lambda>
lambda event: event.callable(*event.args, **event.kw) )
File "E:\software\python\lib\site-packages\wxPython\controls.py",
line 753, in SetSelection
val = controlsc.wxTextCtrl_SetSelection(self, *_args, **_kwargs)
TypeError: Type error in argument 1 of wxTextCtrl_SetSelection.
Expected _wxTextCtrl_p.
This is when my application closes and destroys the window, and I think
it may get focus as part of the closing process. I think my handler then
registers a the call on SetSelection which then later is invoked on a
"non-existent" window.
Yep, that is probably the case. You can usually prevent this by checking if the parent window is being destroyed before doing anything in your focus handlers.
if self.IsBeingDeleted():
return
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!