##// END OF EJS Templates
code cleanup: IPShellQt and IPShellQt4
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 2755 2007-09-09 20:10:30Z darren.dale $"""
7 $Id: Shell.py 2756 2007-09-10 18:25:30Z darren.dale $"""
8 8
9 9 #*****************************************************************************
10 10 # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu>
@@ -885,25 +885,37 b' class IPShellQt(IPThread):'
885 885
886 886 import qt
887 887
888 class newQApplication:
888 self.qApp = qt.qApp
889
890 class DummyQApp:
891 def __init__(self, *args):
892 self.qApp = qt.qApp
893
894 def exec_loop(*args, **kwargs):
895 pass
896
897 def __getattr__(self, name):
898 return getattr(self.qApp, name)
899
900 class DummyQApplication:
889 901 def __init__( self ):
890 902 self.QApplication = qt.QApplication
891 903
892 904 def __call__( *args, **kwargs ):
905 # mask until module NoneType errors can be fixed
906 # return DummyQApp()
893 907 return qt.qApp
894 908
895 def exec_loop( *args, **kwargs ):
896 pass
897
898 909 def __getattr__( self, name ):
899 910 return getattr( self.QApplication, name )
900 911
901 qt.QApplication = newQApplication()
912 qt.QApplication = DummyQApplication()
902 913
903 914 # Allows us to use both Tk and QT.
904 915 self.tk = get_tk()
905 916
906 self.IP = make_IPython(argv,user_ns=user_ns,
917 self.IP = make_IPython(argv,
918 user_ns=user_ns,
907 919 user_global_ns=user_global_ns,
908 920 debug=debug,
909 921 shell_class=shell_class,
@@ -923,15 +935,20 b' class IPShellQt(IPThread):'
923 935 self._banner = banner
924 936
925 937 if qt.QApplication.startingUp():
926 a = qt.QApplication.QApplication(sys.argv)
938 self.qApp = qt.QApplication.QApplication(sys.argv)
939 # mask until module NoneType errors can be fixed
940 # qt.qApp = qt.QApplication()
941
927 942 self.timer = qt.QTimer()
928 qt.QObject.connect( self.timer, qt.SIGNAL( 'timeout()' ), self.on_timer )
943 qt.QObject.connect(self.timer,
944 qt.SIGNAL( 'timeout()' ),
945 self.on_timer)
929 946
930 947 self.start()
931 948 self.timer.start( self.TIMEOUT, True )
932 949 while True:
933 950 if self.IP._kill: break
934 qt.qApp.exec_loop()
951 self.qApp.exec_loop()
935 952 self.join()
936 953
937 954 def on_timer(self):
@@ -955,25 +972,37 b' class IPShellQt4(IPThread):'
955 972
956 973 from PyQt4 import QtCore, QtGui
957 974
958 class newQApplication:
959 def __init__( self ):
975 self.qApp = QtGui.qApp
976
977 class DummyQApp:
978 def __init__(self, *args):
979 self.qApp = QtGui.qApp
980
981 def exec_(*args, **kwargs):
982 pass
983
984 def __getattr__(self, name):
985 return getattr(self.qApp, name)
986
987 class DummyQApplication:
988 def __init__(self, *args):
960 989 self.QApplication = QtGui.QApplication
961 990
962 991 def __call__( *args, **kwargs ):
992 # mask until module NoneType errors can be fixed
993 # return DummyQApp()
963 994 return QtGui.qApp
964 995
965 def exec_loop( *args, **kwargs ):
966 pass
967
968 996 def __getattr__( self, name ):
969 997 return getattr( self.QApplication, name )
970 998
971 QtGui.QApplication = newQApplication()
999 QtGui.QApplication = DummyQApplication()
972 1000
973 1001 # Allows us to use both Tk and QT.
974 1002 self.tk = get_tk()
975 1003
976 self.IP = make_IPython(argv,user_ns=user_ns,
1004 self.IP = make_IPython(argv,
1005 user_ns=user_ns,
977 1006 user_global_ns=user_global_ns,
978 1007 debug=debug,
979 1008 shell_class=shell_class,
@@ -993,15 +1022,20 b' class IPShellQt4(IPThread):'
993 1022 self._banner = banner
994 1023
995 1024 if QtGui.QApplication.startingUp():
996 a = QtGui.QApplication.QApplication(sys.argv)
1025 self.qApp = QtGui.QApplication.QApplication(sys.argv)
1026 # mask until module NoneType errors can be fixed
1027 # QtGui.qApp = QtGui.QApplication()
1028
997 1029 self.timer = QtCore.QTimer()
998 QtCore.QObject.connect( self.timer, QtCore.SIGNAL( 'timeout()' ), self.on_timer )
1030 QtCore.QObject.connect(self.timer,
1031 QtCore.SIGNAL('timeout()'),
1032 self.on_timer)
999 1033
1000 1034 self.start()
1001 1035 self.timer.start( self.TIMEOUT )
1002 1036 while True:
1037 self.qApp.exec_()
1003 1038 if self.IP._kill: break
1004 QtGui.qApp.exec_()
1005 1039 self.join()
1006 1040
1007 1041 def on_timer(self):
@@ -1,3 +1,7 b''
1 2007-09-10 Darren Dale <dd55@cornell.edu>
2
3 * Cleanup of IPShellQt and IPShellQt4
4
1 5 2007-09-09 Fernando Perez <Fernando.Perez@colorado.edu>
2 6
3 7 * IPython/FakeModule.py (FakeModule.__init__): further fixes for
General Comments 0
You need to be logged in to leave comments. Login now