Show More
@@ -40,50 +40,37 b' except Exception,e:' | |||
|
40 | 40 | raise "Error importing IPython (%s)" % str(e) |
|
41 | 41 | |
|
42 | 42 | |
|
43 |
from non_blocking_ip_shell import |
|
|
43 | from non_blocking_ip_shell import NonBlockingIPShell | |
|
44 | 44 | |
|
45 | 45 | class WxNonBlockingIPShell(NonBlockingIPShell): |
|
46 | 46 | ''' |
|
47 | 47 | An NonBlockingIPShell Thread that is WX dependent. |
|
48 | Thus it permits direct interaction with a WX GUI without OnIdle event state machine trick... | |
|
49 | 48 | ''' |
|
50 |
def __init__(self, |
|
|
49 | def __init__(self, parent, | |
|
51 | 50 | argv=[],user_ns={},user_global_ns=None, |
|
52 | 51 | cin=None, cout=None, cerr=None, |
|
53 | 52 | ask_exit_handler=None): |
|
54 | 53 | |
|
55 | #user_ns['addGUIShortcut'] = self.addGUIShortcut | |
|
56 | 54 | NonBlockingIPShell.__init__(self,argv,user_ns,user_global_ns, |
|
57 | 55 | cin, cout, cerr, |
|
58 | 56 | ask_exit_handler) |
|
59 | 57 | |
|
60 | # This creates a new Event class and a EVT binder function | |
|
61 | (self.IPythonAskExitEvent, EVT_IP_ASK_EXIT) = wx.lib.newevent.NewEvent() | |
|
62 | (self.IPythonAddButtonEvent, EVT_IP_ADD_BUTTON_EXIT) = \ | |
|
63 | wx.lib.newevent.NewEvent() | |
|
64 | (self.IPythonExecuteDoneEvent, EVT_IP_EXECUTE_DONE) = \ | |
|
65 | wx.lib.newevent.NewEvent() | |
|
66 | ||
|
67 | wx_instance.Bind(EVT_IP_ASK_EXIT, wx_instance.ask_exit_handler) | |
|
68 | wx_instance.Bind(EVT_IP_ADD_BUTTON_EXIT, wx_instance.add_button_handler) | |
|
69 | wx_instance.Bind(EVT_IP_EXECUTE_DONE, wx_instance.evtStateExecuteDone) | |
|
58 | self.parent = parent | |
|
70 | 59 | |
|
71 | self.wx_instance = wx_instance | |
|
60 | self.ask_exit_callback = ask_exit_handler | |
|
72 | 61 | self._IP.ask_exit = self._askExit |
|
73 | 62 | |
|
63 | ||
|
74 | 64 | def addGUIShortcut(self,text,func): |
|
75 | evt = self.IPythonAddButtonEvent( | |
|
65 | wx.CallAfter(self.parent.add_button_handler, | |
|
76 | 66 | button_info={ 'text':text, |
|
77 |
'func':self. |
|
|
78 | wx.PostEvent(self.wx_instance, evt) | |
|
67 | 'func':self.parent.doExecuteLine(func)}) | |
|
79 | 68 | |
|
80 | 69 | def _askExit(self): |
|
81 | evt = self.IPythonAskExitEvent() | |
|
82 | wx.PostEvent(self.wx_instance, evt) | |
|
70 | wx.CallAfter(self.ask_exit_callback, ()) | |
|
83 | 71 | |
|
84 | 72 | def _afterExecute(self): |
|
85 | evt = self.IPythonExecuteDoneEvent() | |
|
86 | wx.PostEvent(self.wx_instance, evt) | |
|
73 | wx.CallAfter(self.parent.evtStateExecuteDone, ()) | |
|
87 | 74 | |
|
88 | 75 | |
|
89 | 76 | class WxConsoleView(stc.StyledTextCtrl): |
General Comments 0
You need to be logged in to leave comments.
Login now