Grid tablebase load inside a delayedresult

I'm doing some unusual test to see if I can load a tablebase inside a delayedresult worker function, it's useful for me as I can then show a progress dialog while loading data, something like the following where "base" is a custom class that acts as a container for a wx.grid.PyGridTableBase.
Now while it seems to work, should I use it? is it safe to send events to a wx.grid.Grid from a delayedResult worker function?

class Base(object):

     def __init__(self):
  self.tablebase = wx.grid.PyGridTableBase(....)

     def load(filters):

  #here I load data from the db and then I do a
  #refresh of the wx.grid.Grid associated

class Test:

     def __init__(self, view):
  self.base = Base()
  self.view = view

     def testDelayed(self, parent):

  delayedresult.startWorker(self._EndLoad, self._doDelayedLoad,
           wargs=(self.base, filters))
  
  self._progress_dlg = MyProgressDialog(self.view)
         self._progress_dlg.Show()
         self._progress_dlg.MakeModal(True)

     def _doDelayedLoad(self, base, filters):

         base.load(filters)

         return True

     def _EndLoad(self, delayedResult):

         try :
             result = delayedResult.get()
         except Exception, e:
             print "_EndLoad:" , e

         self._progress_dlg.MakeModal(False)
         self._progress_dlg.Destroy()

         wx.Yield()

         self.Layout()

As long as it is only events or wx.CallAfter calls then it should be fine. Don't call any other wx methods that update the GUI directly from the thread.

···

On 9/21/09 7:54 AM, Marco De Felice wrote:

I'm doing some unusual test to see if I can load a tablebase inside a
delayedresult worker function, it's useful for me as I can then show a
progress dialog while loading data, something like the following where
"base" is a custom class that acts as a container for a
wx.grid.PyGridTableBase.
Now while it seems to work, should I use it? is it safe to send events
to a wx.grid.Grid from a delayedResult worker function?

--
Robin Dunn
Software Craftsman