##// END OF EJS Templates
Some cosmetic changes.
Gael Varoquaux -
Show More
@@ -1,7 +1,7 b''
1 1 #!/usr/bin/python
2 2 # -*- coding: iso-8859-15 -*-
3 3 '''
4 Provides IPython WX console widget.
4 Provides IPython WX console widgets.
5 5
6 6 @author: Laurent Dufrechou
7 7 laurent.dufrechou _at_ gmail.com
@@ -33,7 +33,6 b' import sys'
33 33 import os
34 34 import locale
35 35 import time
36 #from ThreadEx import Thread
37 36 from StringIO import StringIO
38 37 try:
39 38 import IPython
@@ -41,11 +40,11 b' except Exception,e:'
41 40 raise "Error importing IPython (%s)" % str(e)
42 41
43 42
44 from ipython_interactive_shell import *
43 from non_blocking_ip_shell import *
45 44
46 class WxIterableIPShell(IterableIPShell):
45 class WxNonBlockingIPShell(NonBlockingIPShell):
47 46 '''
48 An IterableIPShell Thread that is WX dependent.
47 An NonBlockingIPShell Thread that is WX dependent.
49 48 Thus it permits direct interaction with a WX GUI without OnIdle event state machine trick...
50 49 '''
51 50 def __init__(self,wx_instance,
@@ -54,7 +53,7 b' class WxIterableIPShell(IterableIPShell):'
54 53 exit_handler=None,time_loop = 0.1):
55 54
56 55 user_ns['addGUIShortcut'] = self.addGUIShortcut
57 IterableIPShell.__init__(self,argv,user_ns,user_global_ns,
56 NonBlockingIPShell.__init__(self,argv,user_ns,user_global_ns,
58 57 cin, cout, cerr,
59 58 exit_handler,time_loop)
60 59
@@ -465,7 +464,9 b' class WxIPythonViewPanel(wx.Panel):'
465 464 Any idea to make it more 'genric' welcomed.
466 465 '''
467 466 def __init__(self,parent,exit_handler=None,intro=None,
468 background_color="BLACK",add_button_handler=None):
467 background_color="BLACK", add_button_handler=None,
468 wx_ip_shell=None,
469 ):
469 470 '''
470 471 Initialize.
471 472 Instanciate an IPython thread.
@@ -480,7 +481,10 b' class WxIPythonViewPanel(wx.Panel):'
480 481 self.add_button_handler = add_button_handler
481 482 self.exit_handler = exit_handler
482 483
483 self.IP = WxIterableIPShell(self,
484 if wx_ip_shell is not None:
485 self.IP = wx_ip_shell
486 else:
487 self.IP = WxNonBlockingIPShell(self,
484 488 cout=self.cout,cerr=self.cout,
485 489 exit_handler = exit_handler,
486 490 time_loop = 0.1)
@@ -23,7 +23,7 b' import os'
23 23 import locale
24 24 import time
25 25 import pydoc,__builtin__,site
26 from ThreadEx import Thread
26 from thread_ex import ThreadEx
27 27 from StringIO import StringIO
28 28
29 29 try:
@@ -57,13 +57,13 b' class _Helper(object):'
57 57 return pydoc.help(*args, **kwds)
58 58
59 59
60 class IterableIPShell(Thread):
60 class NonBlockingIPShell(ThreadEx):
61 61 '''
62 62 Create an IPython instance inside a dedicated thread.
63 63 Does not start a blocking event loop, instead allow single iterations.
64 64 This allows embedding in any GUI without blockage.
65 65 The thread is a slave one, in that it doesn't interact directly with the GUI.
66 Note Thread class comes from ThreadEx that supports asynchroneous function call
66 Note ThreadEx class supports asynchroneous function call
67 67 via raise_exc()
68 68 '''
69 69
@@ -89,7 +89,7 b' class IterableIPShell(Thread):'
89 89 @param time_loop: Define the sleep time between two thread's loop
90 90 @type int
91 91 '''
92 Thread.__init__(self)
92 ThreadEx.__init__(self)
93 93
94 94 #first we redefine in/out/error functions of IPython
95 95 if cin:
@@ -1,3 +1,8 b''
1 """
2 Thread subclass that can deal with asynchronously function calls via
3 raise_exc.
4 """
5
1 6 import threading
2 7 import inspect
3 8 import ctypes
@@ -17,7 +22,7 b' def _async_raise(tid, exctype):'
17 22 raise SystemError("PyThreadState_SetAsyncExc failed")
18 23
19 24
20 class Thread(threading.Thread):
25 class ThreadEx(threading.Thread):
21 26 def _get_my_tid(self):
22 27 """determines this (self's) thread id"""
23 28 if not self.isAlive():
General Comments 0
You need to be logged in to leave comments. Login now