Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

larch_gui now correcly responding with wx updates from larch requests…

…, as with plot update_line
  • Loading branch information...
commit 18b39d2eefa7d0343824ddef32274883f801e7dc 1 parent 91488aa
@newville newville authored
Showing with 26 additions and 4 deletions.
  1. +25 −4 lib/wx/larchframe.py
  2. +1 −0  plugins/wx/gui_utils.py
View
29 lib/wx/larchframe.py
@@ -45,12 +45,23 @@ def __init__(self, wxparent=None, writer=None,
self.prompt = prompt
self.output = output
self.larch.writer = self
- self.larch.add_plugin('wx', wxparent=wxparent)
+ self.larch.add_plugin('wx', wxparent=wxparent, inputhandler=self.onUpdate)
+ self.symtable.set_symbol('_builtin.force_wxupdate', False)
self.SetPrompt()
for fname in larch.site_config.init_files:
self.execute("run('%s')" % fname)
+ def onUpdate(self, event=None):
+ symtable = self.symtable
+ if symtable.get_symbol('_builtin.force_wxupdate', create=True):
+ app = wx.GetApp()
+ evtloop = wx.EventLoop()
+ while evtloop.Pending():
+ evtloop.Dispatch()
+ app.ProcessIdle()
+ symtable.set_symbol('_builtin.force_wxupdate', False)
+
def SetPrompt(self, partial=False):
if self.prompt is not None:
if partial:
@@ -125,9 +136,8 @@ def __init__(self, parent=None, **kwds):
self.larchshell = LarchWxShell(wxparent=self,
prompt = self.prompt,
output = self.output)
-
self.datapanel.SetRootObject(self.larchshell.symtable)
-
+ #self.timer.Start(200)
def InputPanel(self, parent):
panel = wx.Panel(parent, -1)
@@ -191,14 +201,25 @@ def BuildFrame(self, parent=None, **kwds):
opts = dict(flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.EXPAND,
border=2)
+ #ID_TIMER = wx.NewId()
+ #wx.EVT_TIMER(self, ID_TIMER, self.onTimer)
+ #self.timer = wx.Timer(self, ID_TIMER)
+
sizer.Add(nbook, 1, **opts)
sizer.Add(self.InputPanel(self), 0, **opts)
self.SetSizer(sizer)
self.Refresh()
-
self.SetStatusText("Ready", 0)
+ def onTimer(self, event=None):
+ symtable = self.larchshell.symtable
+ # print 'On Timer ', symtable, symtable.get_symbol('_builtin.force_wxupdate')
+ #if symtable.get_symbol('_builtin.force_wxupdate', create=True):
+ # print 'Update from Timer!!'
+ # app = wx.GetApp()
+ # app.ProcessIdle()
+
def BuildMenus(self):
ID_ABOUT = wx.NewId()
ID_CLOSE = wx.NewId()
View
1  plugins/wx/gui_utils.py
@@ -44,6 +44,7 @@ def _gcd(wxparent=None, _larch=None, **kws):
# @SafeWxCall
def _wxupdate(wxparent=None, _larch=None, inputhandler=None, **kws):
"""force an update of wxPython windows"""
+ # print 'wxupdate!! ', _larch, inputhandler
if _larch is not None and inputhandler is not None:
symtable = _larch.symtable
symtable.set_symbol("%s.force_wxupdate" % MODNAME, True)
Please sign in to comment.
Something went wrong with that request. Please try again.