Kirix Support Forums

Calling Update inside a Timer event crashes my application.

Please post all general questions, comments, bug reports, and any other wxAUI feedback here.

Calling Update inside a Timer event crashes my application.

Postby Diego on Thu Feb 15, 2007 6:09 pm

Hi, I found a sort of "conflict problem" between timer events and AuiManager's panes when the mouse pointer is on the close button inside one of its panels.
Here is a small wxpython application to show my problem (I'm using the python language):

import wx
from wx import aui

class Frame(wx.Frame):

def __init__(self, *a, **k):
wx.Frame.__init__(self, *a, **k)

self.txt = wx.TextCtrl(self, -1, style=wx.TE_MULTILINE)
self.button = wx.Button(self, -1, "Start timer")
self.test = wx.TextCtrl(self, -1, style=wx.TE_MULTILINE)

self.manager = aui.AuiManager(self)
self.manager.AddPane(self.button, aui.AuiPaneInfo().Left())
self.manager.AddPane(self.txt, aui.AuiPaneInfo().Name("txt").Center())
self.manager.AddPane(self.test, aui.AuiPaneInfo().Right())
self.manager.Update()

self.timer = wx.Timer(self)

self.Bind(wx.EVT_TIMER, self.onTimer, self.timer)
self.Bind(wx.EVT_BUTTON, self.onButton, self.button)

self.count = 0


def onTimer(self, evt):
txt = "onTimer (%s)" % self.count
self.txt.AppendText(txt + "\n")

self.manager.GetPane("txt").Caption(txt)
self.manager.Update()

self.count += 1

def onButton(self, evt):
self.timer.Start(40)


app = wx.PySimpleApp()
frame = Frame(None)
frame.Show()
app.MainLoop()

In the "onTimer" handler, I update the manager. But, if in that moment the cursor is on the close button in one of the manager panes, my application crashes.

Is there a solution ? I looked at the code for "pyaui", a aui python translation by Andrea Gavana, and I found a comment warning about calling "update" from inside a motion event... but I can't get longer. Also, using "pyaui" instead of wx.aui, this problem is not present.

Thank you for the help!

Diego.
Diego
Registered User
 
Posts: 5
Joined: Sun Jan 07, 2007 8:31 pm

Postby Infinity77 on Tue Feb 27, 2007 6:58 am

Hi Diego,

it looks like wxAUI doesn't want you to call Update() when you are hovering over a close button. I have no idea of the reason: I also tried using wx.CallAfter in the timer event, but nothing changed. Maybe Ben can help you here, but I am curious about the fact that the same issue does not appear with PyAUI.

Andrea.
"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.virgilio.it/infinity77
Infinity77
Registered User
 
Posts: 12
Joined: Thu Jan 05, 2006 12:57 am
Location: Milan, Italy

Postby Diego on Tue Feb 27, 2007 10:54 am

Hi Andrea! I think there's an issue related to AUI's using the IDLE event to accomplish some updates to its GUI, but I can't know much more.
I guess You are Andrea Gavana... Your widgets are very useful for wxpython users (like me), and I hope you'll release an updated version of pyaui, including AuiNotebook that I find very useful (that way pythonists could esasily customize some aspects of the wondweful AUI toolkit).
Thank You from Italy :-)

Diego.
Diego
Registered User
 
Posts: 5
Joined: Sun Jan 07, 2007 8:31 pm

Postby Infinity77 on Tue Feb 27, 2007 11:22 am

Hi Diego,

you guessed correct, I am Andrea Gavana :-D . As for PyAUI, I almost abandoned it once Robin decided to wrap the C++ version directly in wxPython. It's been a while since I haven't kept wxAUI and PyAUI synchronized, and I believe it would require a big work to restore the parity between the two implementations. The upside of the C++ version is that it's faster and well developed, having Ben and friends as creators, maintainers and a wxWidgets official support. The downside for us, Python users, is that every bug fix/feature request/customization can not be simply tweaked in the source code (as we usually do with Python), unless you wish to modify the C++ source code, recompile wxWidgets *and* wxPython. No way for me :-D
You may have noticed that I also am from Italy :-D

Andrea.
Infinity77
Registered User
 
Posts: 12
Joined: Thu Jan 05, 2006 12:57 am
Location: Milan, Italy

Return to wxAUI Questions, Thoughts & Feedback