##// END OF EJS Templates
finish IPShellQt[4] improvements, hijacking mainloop ...
darren.dale -
Show More
@@ -4,7 +4,7 b''
4 4 All the matplotlib support code was co-developed with John Hunter,
5 5 matplotlib's author.
6 6
7 $Id: Shell.py 2758 2007-09-10 20:56:27Z darren.dale $"""
7 $Id: Shell.py 2760 2007-09-11 17:30:32Z darren.dale $"""
8 8
9 9 #*****************************************************************************
10 10 # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu>
@@ -46,7 +46,6 b' from IPython.ipmaker import make_IPython'
46 46 from IPython.Magic import Magic
47 47 from IPython.ipstruct import Struct
48 48
49
50 49 # Globals
51 50 # global flag to pass around information about Ctrl-C without exceptions
52 51 KBINT = False
@@ -877,7 +876,7 b' class IPShellQt(IPThread):'
877 876 Python commands can be passed to the thread where they will be executed.
878 877 This is implemented by periodically checking for passed code using a
879 878 Qt timer / slot."""
880
879
881 880 TIMEOUT = 100 # Millisecond interval between timeouts.
882 881
883 882 def __init__(self, argv=None, user_ns=None, user_global_ns=None,
@@ -885,6 +884,14 b' class IPShellQt(IPThread):'
885 884
886 885 import qt
887 886
887 def dummy_mainloop(*args, **kwargs):
888 pass
889
890 self.exec_loop = qt.qApp.exec_loop
891
892 qt.qApp.exec_loop = dummy_mainloop
893 qt.QApplication.exec_loop = dummy_mainloop
894
888 895 # Allows us to use both Tk and QT.
889 896 self.tk = get_tk()
890 897
@@ -902,25 +909,25 b' class IPShellQt(IPThread):'
902 909
903 910 threading.Thread.__init__(self)
904 911
905 def mainloop(self,sys_exit=0,banner=None):
912 def mainloop(self, sys_exit=0, banner=None):
906 913
907 914 import qt
908 915
909 916 self._banner = banner
910 917
911 918 if qt.QApplication.startingUp():
912 self.qApp = qt.QApplication(sys.argv)
919 a = qt.QApplication(sys.argv)
913 920
914 921 self.timer = qt.QTimer()
915 922 qt.QObject.connect(self.timer,
916 qt.SIGNAL( 'timeout()' ),
923 qt.SIGNAL('timeout()'),
917 924 self.on_timer)
918 925
919 926 self.start()
920 927 self.timer.start(self.TIMEOUT, True)
921 928 while True:
922 929 if self.IP._kill: break
923 qt.qApp.exec_loop()
930 self.exec_loop()
924 931 self.join()
925 932
926 933 def on_timer(self):
@@ -929,6 +936,7 b' class IPShellQt(IPThread):'
929 936 self.timer.start(self.TIMEOUT, True)
930 937 return result
931 938
939
932 940 class IPShellQt4(IPThread):
933 941 """Run a Qt event loop in a separate thread.
934 942
@@ -942,6 +950,15 b' class IPShellQt4(IPThread):'
942 950 debug=0, shell_class=MTInteractiveShell):
943 951
944 952 from PyQt4 import QtCore, QtGui
953
954 def dummy_mainloop(*args, **kwargs):
955 pass
956
957 self.exec_ = QtGui.qApp.exec_
958
959 QtGui.qApp.exec_ = dummy_mainloop
960 QtGui.QApplication.exec_ = dummy_mainloop
961 QtCore.QCoreApplication.exec_ = dummy_mainloop
945 962
946 963 # Allows us to use both Tk and QT.
947 964 self.tk = get_tk()
@@ -967,7 +984,7 b' class IPShellQt4(IPThread):'
967 984 self._banner = banner
968 985
969 986 if QtGui.QApplication.startingUp():
970 self.qApp = QtGui.QApplication(sys.argv)
987 a = QtGui.QApplication(sys.argv)
971 988
972 989 self.timer = QtCore.QTimer()
973 990 QtCore.QObject.connect(self.timer,
@@ -978,7 +995,7 b' class IPShellQt4(IPThread):'
978 995 self.timer.start(self.TIMEOUT)
979 996 while True:
980 997 if self.IP._kill: break
981 QtGui.qApp.exec_()
998 self.exec_()
982 999 self.join()
983 1000
984 1001 def on_timer(self):
General Comments 0
You need to be logged in to leave comments. Login now