I need to change a listCtrl, I tried with listCtrl.destroy() to remove and create it again but it closes the app, I Attach a sample code, any suggestions?
On Nov 16, 11:05 pm, Jair Gaxiola <jyr.gaxi...@gmail.com> wrote:
Hola,
I need to change a listCtrl, I tried with listCtrl.destroy() to remove and
create it again but it closes the app, I Attach a sample code, any
suggestions?
What do you mean by "change" it? Are you wanting to refresh the rows
with new information? Change the number of columns? Or something else?
> Hola,
>
> I need to change a listCtrl, I tried with listCtrl.destroy() to remove
> and
> create it again but it closes the app, I Attach a sample code, any
> suggestions?
Your destroying the control while your inside an event handler that
you bound to it.
You could either
1) Just update the values in the control without destroying it.
Destroying and re-creating the control will likely lead to lots of
flickering and other display issues.
or
2) mark a flag and do the destroy/recreate it in OnIdle (highly
suggest #1 over this option)
Cody
···
On Nov 16, 11:05 pm, Jair Gaxiola <jyr.gaxi...@gmail.com> wrote:
You are destroying the list ctrl from within one of that list ctrl's event handlers. That's like saying, "I'm going to shoot myself in the head and after I'm finished I'll clean the gun and put it away in the gun safe." In other words, there is still some code that will be running that assumes that the list ctrl still exists and crashes when it tries to access it.
If you really need to destroy and recreate the list ctrl then what you could do instead is simply Hide() the old listctrl, create and populate the new one as you do now, and then call the Destroy method of the old one using wx.CallAfter so it will happen after all pending events have been processed.
···
On 11/16/09 9:05 PM, Jair Gaxiola wrote:
Hola,
I need to change a listCtrl, I tried with listCtrl.destroy() to remove
and create it again but it closes the app, I Attach a sample code, any
suggestions?
On Tue, Nov 17, 2009 at 11:15 AM, Cody Precord <codyprecord@gmail.com > <mailto:codyprecord@gmail.com>> wrote:
Hi,
>> On Nov 16, 11:05 pm, Jair Gaxiola <jyr.gaxi...@gmail.com > <mailto:jyr.gaxi…@gmail.com>> wrote:
>> > Hola,
>> >
>> > I need to change a listCtrl, I tried with listCtrl.destroy()
to remove
>> > and
>> > create it again but it closes the app, I Attach a sample
code, any
>> > suggestions?
Your destroying the control while your inside an event handler that
you bound to it.
But by destroyed the widget the app closes, please look the sample
code attaching.
You mean the application crashes? It seems fine here - you click the
first list item and it changes to the second one.
Windows XP SP3, python 2.6.4 wx 2.8.10.1
You may also just wish to use ClearAll() instead of destroy, then you
can just recreate the list's items, as opposed having to re-construct
the list widgets itself.
On Tue, Nov 17, 2009 at 11:19 AM, Robin Dunn <robin@alldunn.com > <mailto:robin@alldunn.com>> wrote:
You are destroying the list ctrl from within one of that list ctrl's
event handlers. That's like saying, "I'm going to shoot myself in the
head and after I'm finished I'll clean the gun and put it away in the
gun safe." In other words, there is still some code that will be
running that assumes that the list ctrl still exists and crashes when it
tries to access it.
If you really need to destroy and recreate the list ctrl then what you
could do instead is simply Hide() the old listctrl, create and populate
the new one as you do now, and then call the Destroy method of the old
one using wx.CallAfter so it will happen after all pending events have
been processed.
Already replacing the old listCtrl with new one, but only shows the new
listCtrl when I resize the window. I attach my sample code.