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 276 |
|
|
7 | $Id: Shell.py 2761 2007-09-11 17:40:42Z darren.dale $""" | |
|
8 | 8 | |
|
9 | 9 | #***************************************************************************** |
|
10 | 10 | # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu> |
@@ -684,6 +684,33 b' def hijack_gtk():' | |||
|
684 | 684 | gtk.main = dummy_mainloop |
|
685 | 685 | return orig_mainloop |
|
686 | 686 | |
|
687 | def hijack_qt(): | |
|
688 | """Modifies PyQt's mainloop with a dummy so user code does not | |
|
689 | block IPython. This function returns the original | |
|
690 | `qt.qApp.exec_loop` function that has been hijacked. | |
|
691 | """ | |
|
692 | def dummy_mainloop(*args, **kw): | |
|
693 | pass | |
|
694 | import qt | |
|
695 | orig_mainloop = qt.qApp.exec_loop | |
|
696 | qt.qApp.exec_loop = dummy_mainloop | |
|
697 | qt.QApplication.exec_loop = dummy_mainloop | |
|
698 | return orig_mainloop | |
|
699 | ||
|
700 | def hijack_qt4(): | |
|
701 | """Modifies PyQt4's mainloop with a dummy so user code does not | |
|
702 | block IPython. This function returns the original | |
|
703 | `QtGui.qApp.exec_` function that has been hijacked. | |
|
704 | """ | |
|
705 | def dummy_mainloop(*args, **kw): | |
|
706 | pass | |
|
707 | from PyQt4 import QtGui, QtCore | |
|
708 | orig_mainloop = QtGui.qApp.exec_ | |
|
709 | QtGui.qApp.exec_ = dummy_mainloop | |
|
710 | QtGui.QApplication.exec_ = dummy_mainloop | |
|
711 | QtCore.QCoreApplication.exec_ = dummy_mainloop | |
|
712 | return orig_mainloop | |
|
713 | ||
|
687 | 714 | #----------------------------------------------------------------------------- |
|
688 | 715 | # The IPShell* classes below are the ones meant to be run by external code as |
|
689 | 716 | # IPython instances. Note that unless a specific threading strategy is |
@@ -884,13 +911,7 b' class IPShellQt(IPThread):' | |||
|
884 | 911 | |
|
885 | 912 | import qt |
|
886 | 913 | |
|
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 | |
|
914 | self.exec_loop = hijack_qt() | |
|
894 | 915 | |
|
895 | 916 | # Allows us to use both Tk and QT. |
|
896 | 917 | self.tk = get_tk() |
@@ -950,15 +971,8 b' class IPShellQt4(IPThread):' | |||
|
950 | 971 | debug=0, shell_class=MTInteractiveShell): |
|
951 | 972 | |
|
952 | 973 | from PyQt4 import QtCore, QtGui |
|
953 | ||
|
954 | def dummy_mainloop(*args, **kwargs): | |
|
955 | pass | |
|
956 | 974 | |
|
957 |
self.exec_ = |
|
|
958 | ||
|
959 | QtGui.qApp.exec_ = dummy_mainloop | |
|
960 | QtGui.QApplication.exec_ = dummy_mainloop | |
|
961 | QtCore.QCoreApplication.exec_ = dummy_mainloop | |
|
975 | self.exec_ = hijack_qt4() | |
|
962 | 976 | |
|
963 | 977 | # Allows us to use both Tk and QT. |
|
964 | 978 | self.tk = get_tk() |
General Comments 0
You need to be logged in to leave comments.
Login now