Show More
@@ -40,50 +40,37 b' except Exception,e:' | |||||
40 | raise "Error importing IPython (%s)" % str(e) |
|
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 | class WxNonBlockingIPShell(NonBlockingIPShell): |
|
45 | class WxNonBlockingIPShell(NonBlockingIPShell): | |
46 | ''' |
|
46 | ''' | |
47 | An NonBlockingIPShell Thread that is WX dependent. |
|
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 | argv=[],user_ns={},user_global_ns=None, |
|
50 | argv=[],user_ns={},user_global_ns=None, | |
52 | cin=None, cout=None, cerr=None, |
|
51 | cin=None, cout=None, cerr=None, | |
53 | ask_exit_handler=None): |
|
52 | ask_exit_handler=None): | |
54 |
|
53 | |||
55 | #user_ns['addGUIShortcut'] = self.addGUIShortcut |
|
|||
56 | NonBlockingIPShell.__init__(self,argv,user_ns,user_global_ns, |
|
54 | NonBlockingIPShell.__init__(self,argv,user_ns,user_global_ns, | |
57 | cin, cout, cerr, |
|
55 | cin, cout, cerr, | |
58 | ask_exit_handler) |
|
56 | ask_exit_handler) | |
59 |
|
57 | |||
60 | # This creates a new Event class and a EVT binder function |
|
58 | self.parent = parent | |
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) |
|
|||
70 |
|
59 | |||
71 | self.wx_instance = wx_instance |
|
60 | self.ask_exit_callback = ask_exit_handler | |
72 | self._IP.ask_exit = self._askExit |
|
61 | self._IP.ask_exit = self._askExit | |
73 |
|
62 | |||
|
63 | ||||
74 | def addGUIShortcut(self,text,func): |
|
64 | def addGUIShortcut(self,text,func): | |
75 | evt = self.IPythonAddButtonEvent( |
|
65 | wx.CallAfter(self.parent.add_button_handler, | |
76 | button_info={ 'text':text, |
|
66 | button_info={ 'text':text, | |
77 |
'func':self. |
|
67 | 'func':self.parent.doExecuteLine(func)}) | |
78 | wx.PostEvent(self.wx_instance, evt) |
|
|||
79 |
|
68 | |||
80 | def _askExit(self): |
|
69 | def _askExit(self): | |
81 | evt = self.IPythonAskExitEvent() |
|
70 | wx.CallAfter(self.ask_exit_callback, ()) | |
82 | wx.PostEvent(self.wx_instance, evt) |
|
|||
83 |
|
71 | |||
84 | def _afterExecute(self): |
|
72 | def _afterExecute(self): | |
85 | evt = self.IPythonExecuteDoneEvent() |
|
73 | wx.CallAfter(self.parent.evtStateExecuteDone, ()) | |
86 | wx.PostEvent(self.wx_instance, evt) |
|
|||
87 |
|
74 | |||
88 |
|
75 | |||
89 | class WxConsoleView(stc.StyledTextCtrl): |
|
76 | class WxConsoleView(stc.StyledTextCtrl): |
General Comments 0
You need to be logged in to leave comments.
Login now