43 |
43 |
44 class ShellWindow(E5MainWindow): |
44 class ShellWindow(E5MainWindow): |
45 """ |
45 """ |
46 Class implementing a stand alone shell window. |
46 Class implementing a stand alone shell window. |
47 """ |
47 """ |
48 def __init__(self, parent=None, name=None): |
48 def __init__(self, originalPathString, parent=None, name=None): |
49 """ |
49 """ |
50 Constructor |
50 Constructor |
51 |
51 |
|
52 @param originalPathString original PATH environment variable |
|
53 @type str |
52 @param parent reference to the parent widget |
54 @param parent reference to the parent widget |
53 @type QWidget |
55 @type QWidget |
54 @param name object name of the window |
56 @param name object name of the window |
55 @type str |
57 @type str |
56 """ |
58 """ |
57 super(ShellWindow, self).__init__(parent) |
59 super(ShellWindow, self).__init__(parent) |
58 if name is not None: |
60 if name is not None: |
59 self.setObjectName(name) |
61 self.setObjectName(name) |
60 self.setWindowIcon(UI.PixmapCache.getIcon("shell.png")) |
62 self.setWindowIcon(UI.PixmapCache.getIcon("shell.png")) |
|
63 self.setWindowTitle(self.tr("eric6 Shell")) |
61 |
64 |
62 self.setStyle(Preferences.getUI("Style"), |
65 self.setStyle(Preferences.getUI("Style"), |
63 Preferences.getUI("StyleSheet")) |
66 Preferences.getUI("StyleSheet")) |
64 |
67 |
65 # initialize the APIs manager |
68 # initialize the APIs manager |
66 self.__apisManager = APIsManager(parent=self) |
69 self.__apisManager = APIsManager(parent=self) |
67 |
70 |
68 # initialize the debug server and shell widgets |
71 # initialize the debug server and shell widgets |
69 self.__debugServer = DebugServer(preventPassiveDebugging=True) |
72 self.__debugServer = DebugServer(originalPathString, |
|
73 preventPassiveDebugging=True) |
70 self.__shell = Shell(self.__debugServer, self, None, True, self) |
74 self.__shell = Shell(self.__debugServer, self, None, True, self) |
71 self.__searchWidget = SearchWidget(self.__shell, self, showLine=True) |
75 self.__searchWidget = SearchWidget(self.__shell, self, showLine=True) |
72 |
76 |
73 centralWidget = QWidget() |
77 centralWidget = QWidget() |
74 layout = QVBoxLayout() |
78 layout = QVBoxLayout() |
97 |
101 |
98 # Generate the virtual environment manager and register it |
102 # Generate the virtual environment manager and register it |
99 self.virtualenvManager = VirtualenvManager(self) |
103 self.virtualenvManager = VirtualenvManager(self) |
100 e5App().registerObject("VirtualEnvManager", self.virtualenvManager) |
104 e5App().registerObject("VirtualEnvManager", self.virtualenvManager) |
101 |
105 |
102 # now start the debug client |
106 self.__shell.virtualEnvironmentChanged.connect( |
103 self.__debugServer.startClient(False) |
107 self.__virtualEnvironmentChanged) |
|
108 |
|
109 # now start the debug client with the most recently used virtual |
|
110 # environment |
|
111 self.__debugServer.startClient( |
|
112 False, venvName=Preferences.getShell("LastVirtualEnvironment") |
|
113 ) |
104 |
114 |
105 # set the keyboard input interval |
115 # set the keyboard input interval |
106 interval = Preferences.getUI("KeyboardInputInterval") |
116 interval = Preferences.getUI("KeyboardInputInterval") |
107 if interval > 0: |
117 if interval > 0: |
108 QApplication.setKeyboardInputInterval(interval) |
118 QApplication.setKeyboardInputInterval(interval) |
231 'Restart the shell')) |
241 'Restart the shell')) |
232 self.restartAct.setWhatsThis(self.tr( |
242 self.restartAct.setWhatsThis(self.tr( |
233 """<b>Restart</b>""" |
243 """<b>Restart</b>""" |
234 """<p>Restart the shell for the currently selected language.</p>""" |
244 """<p>Restart the shell for the currently selected language.</p>""" |
235 )) |
245 )) |
236 self.restartAct.triggered.connect(self.__doRestart) |
246 self.restartAct.triggered.connect(self.__shell.doRestart) |
237 self.fileActions.append(self.restartAct) |
247 self.fileActions.append(self.restartAct) |
238 |
248 |
239 self.clearRestartAct = E5Action( |
249 self.clearRestartAct = E5Action( |
240 self.tr('Restart and Clear'), |
250 self.tr('Restart and Clear'), |
241 UI.PixmapCache.getIcon("restartDelete.png"), |
251 UI.PixmapCache.getIcon("restartDelete.png"), |
246 self.clearRestartAct.setWhatsThis(self.tr( |
256 self.clearRestartAct.setWhatsThis(self.tr( |
247 """<b>Restart and Clear</b>""" |
257 """<b>Restart and Clear</b>""" |
248 """<p>Clear the shell window and restart the shell for the""" |
258 """<p>Clear the shell window and restart the shell for the""" |
249 """ currently selected language.</p>""" |
259 """ currently selected language.</p>""" |
250 )) |
260 )) |
251 self.clearRestartAct.triggered.connect(self.__doClearRestart) |
261 self.clearRestartAct.triggered.connect(self.__shell.doClearRestart) |
252 self.fileActions.append(self.clearRestartAct) |
262 self.fileActions.append(self.clearRestartAct) |
253 |
263 |
254 def __createEditActions(self): |
264 def __createEditActions(self): |
255 """ |
265 """ |
256 Private method defining the user interface actions for the edit |
266 Private method defining the user interface actions for the edit |
1002 """ |
1012 """ |
1003 Public method to quit the application. |
1013 Public method to quit the application. |
1004 """ |
1014 """ |
1005 e5App().closeAllWindows() |
1015 e5App().closeAllWindows() |
1006 |
1016 |
1007 def __doRestart(self): |
|
1008 """ |
|
1009 Private slot to handle the 'restart' menu entry. |
|
1010 """ |
|
1011 self.__debugServer.startClient(False) |
|
1012 |
|
1013 def __doClearRestart(self): |
|
1014 """ |
|
1015 Private slot to handle the 'restart and clear' menu entry. |
|
1016 """ |
|
1017 self.__doRestart() |
|
1018 self.__shell.clear() |
|
1019 |
|
1020 def __newWindow(self): |
1017 def __newWindow(self): |
1021 """ |
1018 """ |
1022 Private slot to start a new instance of eric6. |
1019 Private slot to start a new instance of eric6. |
1023 """ |
1020 """ |
1024 program = sys.executable |
1021 program = sys.executable |
1025 eric6 = os.path.join(getConfig("ericDir"), "eric6_shell.py") |
1022 eric6 = os.path.join(getConfig("ericDir"), "eric6_shell.py") |
1026 args = [eric6] |
1023 args = [eric6] |
1027 QProcess.startDetached(program, args) |
1024 QProcess.startDetached(program, args) |
|
1025 |
|
1026 def __virtualEnvironmentChanged(self, venvName): |
|
1027 """ |
|
1028 Private slot handling a change of the shell's virtual environment. |
|
1029 |
|
1030 @param venvName name of the virtual environment of the shell |
|
1031 @type str |
|
1032 """ |
|
1033 if venvName: |
|
1034 self.setWindowTitle(self.tr("eric6 Shell [{0}]").format(venvName)) |
|
1035 else: |
|
1036 self.setWindowTitle(self.tr("eric6 Shell")) |
1028 |
1037 |
1029 ################################################################## |
1038 ################################################################## |
1030 ## Below are the action methods for the view menu |
1039 ## Below are the action methods for the view menu |
1031 ################################################################## |
1040 ################################################################## |
1032 |
1041 |