A) this is a good question for the wxPython list -- probably not a Mcac issue

B) http://wiki.wxpython.org/MakingSampleApps

That being said:

self.run_button=wx.Button(self.panel,ID_RUN_BUTTON,label='Install')
self.Bind(wx.EVT_BUTTON, self.OnRun,id=ID_RUN_BUTTON)

I prefer this style:

self.run_button=wx.Button(self.panel, label='Install')
self.run_button.Bind(wx.EVT_BUTTON, self.OnRun)

explicit IDs are kind of ugly.

http://wiki.wxpython.org/wxPython%20Style%20Guide

def OnRun(self,evt):
    self.run_button.SetLabel('Installing..')
    #call a function that does the installation task
    installation_task()
    #After task completion, set the button label back to "Install"
    self.run_button.SetLabel('Install')

When I try doing this, it doesn't set the label to "Installing" while
the task is being performed. Any suggestions how do I achieve this?

wx blocks the event loop (and locks up the GUI) when handling an event, so you need to separate out the installation_task() function. This may work:

def OnRun(self,evt):
    self.run_button.SetLabel('Installing..')
    #call a function that does the installation task
    wx.CallAfter(installation_task())
    #After task completion, set the button label back to "Install"
    wx.CallAfter(self.run_button.SetLabel('Install'))


wx.CallAfter() puts an event on the event stack, then proceeds on, so the OnRun() function can finish, the GUI will update, then the events will be run.

Another option would be to post en event that's bound to the installation_task() function, and call that from OnRun, then have it post antoher even when it's done -- but that's really jsut a more complicated way to do the above.

Third option: try calling "self.run_button.Update()", after changing the button text.

-Chris








--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

chris.bar...@noaa.gov
_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG

Reply via email to