From 5245480e028528ee6e73204b43353430158c4553 Mon Sep 17 00:00:00 2001 From: Matthew Newville Date: Fri, 8 Nov 2024 20:11:26 -0600 Subject: [PATCH] only set shell wx if LarchWxApp is imported, for whatever reaseon --- larch/shell.py | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/larch/shell.py b/larch/shell.py index 559ba4d00..48d3f7a6c 100644 --- a/larch/shell.py +++ b/larch/shell.py @@ -27,6 +27,8 @@ except ImportError: wx = None +SHOW_LIBS = ['numpy', 'scipy', 'matplotlib', 'h5py', + 'lmfit', 'xraydb', 'wx','wxmplot'] class Shell(cmd.Cmd): """command shell for Larch""" @@ -57,24 +59,21 @@ def __init__(self, completekey='tab', debug=False, quiet=False, if with_wx and HAS_WXPYTHON: symtable = self.larch.symtable try: - from .wxlib import LarchWxApp + from .wxlib import LarchWxApp, inputhook app = LarchWxApp(redirect=False, clearSigInt=False) - except SystemExit: - with_wx = False - - symtable.set_symbol('_sys.wx.wxapp', app) - symtable.set_symbol('_sys.wx.force_wxupdate', False) - symtable.set_symbol('_sys.wx.parent', None) - - from .wxlib import inputhook - symtable.set_symbol('_sys.wx.inputhook', inputhook) - if uname == 'darwin': - symtable.set_symbol('_sys.wx.ping', inputhook.ping_darwin) - else: - symtable.set_symbol('_sys.wx.ping', inputhook.ping) - - inputhook.ON_INTERRUPT = self.onCtrlC - inputhook.WXLARCH_SYM = symtable + symtable.set_symbol('_sys.wx.wxapp', app) + symtable.set_symbol('_sys.wx.force_wxupdate', False) + symtable.set_symbol('_sys.wx.parent', None) + symtable.set_symbol('_sys.wx.inputhook', inputhook) + if uname == 'darwin': + symtable.set_symbol('_sys.wx.ping', inputhook.ping_darwin) + else: + symtable.set_symbol('_sys.wx.ping', inputhook.ping) + + inputhook.ON_INTERRUPT = self.onCtrlC + inputhook.WXLARCH_SYM = symtable + except: + pass signal.signal(signal.SIGINT, self.onCtrlC) self.prompt = self.larch.input.prompt @@ -82,8 +81,7 @@ def __init__(self, completekey='tab', debug=False, quiet=False, self.color_writer = (uname != 'win' and hasattr(writer, 'set_textstyle')) if not quiet: if banner_msg is None: - banner_msg = make_banner(show_libraries=['numpy', 'scipy', 'matplotlib', 'h5py', - 'lmfit', 'xraydb', 'wx','wxmplot']) + banner_msg = make_banner(show_libraries=SHOW_LIBS) if self.color_writer: writer.set_textstyle('error') writer.write(banner_msg)