Debugger/StartDialog.py

changeset 6352
4bdc6503df81
parent 6048
82ad8ec9548c
child 6645
ad476851d7e0
equal deleted inserted replaced
6351:27ce01e44a5f 6352:4bdc6503df81
10 from __future__ import unicode_literals 10 from __future__ import unicode_literals
11 11
12 from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QComboBox, QInputDialog 12 from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QComboBox, QInputDialog
13 13
14 from E5Gui.E5PathPicker import E5PathPickerModes 14 from E5Gui.E5PathPicker import E5PathPickerModes
15 from E5Gui.E5Application import e5App
15 16
16 import Preferences 17 import Preferences
17 18
18 19
19 class StartDialog(QDialog): 20 class StartDialog(QDialog):
23 It implements a dialog that is used to start an 24 It implements a dialog that is used to start an
24 application for debugging. It asks the user to enter 25 application for debugging. It asks the user to enter
25 the commandline parameters, the working directory and 26 the commandline parameters, the working directory and
26 whether exception reporting should be disabled. 27 whether exception reporting should be disabled.
27 """ 28 """
28 def __init__(self, caption, interpreterList, argvList, wdList, envList, 29 def __init__(self, caption, lastUsedVenvName, argvList, wdList, envList,
29 exceptions, 30 exceptions,
30 parent=None, dialogType=0, modfuncList=None, 31 parent=None, dialogType=0, modfuncList=None,
31 tracePython=False, autoClearShell=True, autoContinue=True, 32 tracePython=False, autoClearShell=True, autoContinue=True,
32 autoFork=False, forkChild=False): 33 autoFork=False, forkChild=False):
33 """ 34 """
34 Constructor 35 Constructor
35 36
36 @param caption the caption to be displayed (string) 37 @param caption the caption to be displayed
37 @param interpreterList list of interpreters (list of string) 38 @type str
38 @param argvList history list of commandline arguments (list of strings) 39 @param lastUsedVenvName name of the most recently used virtual
39 @param wdList history list of working directories (list of strings) 40 environment
40 @param envList history list of environment settings (list of strings) 41 @type str
41 @param exceptions exception reporting flag (boolean) 42 @param argvList history list of command line arguments
42 @param parent parent widget of this dialog (QWidget) 43 @type list of str
44 @param wdList history list of working directories
45 @type list of str
46 @param envList history list of environment parameter settings
47 @type list of str
48 @param exceptions exception reporting flag
49 @type bool
50 @param parent parent widget of this dialog
51 @type QWidget
43 @param dialogType type of the start dialog 52 @param dialogType type of the start dialog
44 <ul> 53 <ul>
45 <li>0 = start debug dialog</li> 54 <li>0 = start debug dialog</li>
46 <li>1 = start run dialog</li> 55 <li>1 = start run dialog</li>
47 <li>2 = start coverage dialog</li> 56 <li>2 = start coverage dialog</li>
48 <li>3 = start profile dialog</li> 57 <li>3 = start profile dialog</li>
49 </ul> 58 </ul>
59 @type int (0 to 3)
50 @keyparam modfuncList history list of module functions 60 @keyparam modfuncList history list of module functions
51 (list of strings) 61 @type list of str
52 @keyparam tracePython flag indicating if the Python library should 62 @keyparam tracePython flag indicating if the Python library should
53 be traced as well (boolean) 63 be traced as well
64 @type bool
54 @keyparam autoClearShell flag indicating, that the interpreter window 65 @keyparam autoClearShell flag indicating, that the interpreter window
55 should be cleared automatically (boolean) 66 should be cleared automatically
67 @type bool
56 @keyparam autoContinue flag indicating, that the debugger should not 68 @keyparam autoContinue flag indicating, that the debugger should not
57 stop at the first executable line (boolean) 69 stop at the first executable line
58 @keyparam autoFork flag indicating the automatic fork mode (boolean) 70 @type bool
71 @keyparam autoFork flag indicating the automatic fork mode
72 @type bool
59 @keyparam forkChild flag indicating to debug the child after forking 73 @keyparam forkChild flag indicating to debug the child after forking
60 (boolean) 74 @type bool
61 """ 75 """
62 super(StartDialog, self).__init__(parent) 76 super(StartDialog, self).__init__(parent)
63 self.setModal(True) 77 self.setModal(True)
64 78
65 self.dialogType = dialogType 79 self.dialogType = dialogType
75 elif dialogType == 3: 89 elif dialogType == 3:
76 from .Ui_StartProfileDialog import Ui_StartProfileDialog 90 from .Ui_StartProfileDialog import Ui_StartProfileDialog
77 self.ui = Ui_StartProfileDialog() 91 self.ui = Ui_StartProfileDialog()
78 self.ui.setupUi(self) 92 self.ui.setupUi(self)
79 93
80 self.ui.interpreterPicker.setMode(E5PathPickerModes.OpenFileMode) 94 self.ui.venvComboBox.addItem("")
81 self.ui.interpreterPicker.setInsertPolicy(QComboBox.InsertAtTop) 95 self.ui.venvComboBox.addItems(
82 self.ui.interpreterPicker.setSizeAdjustPolicy( 96 sorted(e5App().getObject("VirtualEnvManager")
83 QComboBox.AdjustToMinimumContentsLength) 97 .getVirtualenvNames()))
84 98
85 self.ui.workdirPicker.setMode(E5PathPickerModes.DirectoryMode) 99 self.ui.workdirPicker.setMode(E5PathPickerModes.DirectoryMode)
86 self.ui.workdirPicker.setDefaultDirectory( 100 self.ui.workdirPicker.setDefaultDirectory(
87 Preferences.getMultiProject("Workspace")) 101 Preferences.getMultiProject("Workspace"))
88 self.ui.workdirPicker.setInsertPolicy(QComboBox.InsertAtTop) 102 self.ui.workdirPicker.setInsertPolicy(QComboBox.InsertAtTop)
108 self.ui.exceptionCheckBox.setChecked(exceptions) 122 self.ui.exceptionCheckBox.setChecked(exceptions)
109 self.ui.clearShellCheckBox.setChecked(autoClearShell) 123 self.ui.clearShellCheckBox.setChecked(autoClearShell)
110 self.ui.consoleCheckBox.setEnabled( 124 self.ui.consoleCheckBox.setEnabled(
111 Preferences.getDebugger("ConsoleDbgCommand") != "") 125 Preferences.getDebugger("ConsoleDbgCommand") != "")
112 self.ui.consoleCheckBox.setChecked(False) 126 self.ui.consoleCheckBox.setChecked(False)
113 self.ui.interpreterPicker.clear() 127 venvIndex = max(0, self.ui.venvComboBox.findText(lastUsedVenvName))
114 self.ui.interpreterPicker.addItems(interpreterList) 128 self.ui.venvComboBox.setCurrentIndex(venvIndex)
115 if len(interpreterList) > 0:
116 self.ui.interpreterPicker.setCurrentIndex(0)
117 129
118 if dialogType == 0: # start debug dialog 130 if dialogType == 0: # start debug dialog
119 self.ui.tracePythonCheckBox.setChecked(tracePython) 131 self.ui.tracePythonCheckBox.setChecked(tracePython)
120 self.ui.tracePythonCheckBox.show() 132 self.ui.tracePythonCheckBox.show()
121 self.ui.autoContinueCheckBox.setChecked(autoContinue) 133 self.ui.autoContinueCheckBox.setChecked(autoContinue)
151 clear interpreter flag (boolean) and run in console flag (boolean) 163 clear interpreter flag (boolean) and run in console flag (boolean)
152 """ 164 """
153 cmdLine = self.ui.cmdlineCombo.currentText() 165 cmdLine = self.ui.cmdlineCombo.currentText()
154 workdir = self.ui.workdirPicker.currentText() 166 workdir = self.ui.workdirPicker.currentText()
155 environment = self.ui.environmentCombo.currentText() 167 environment = self.ui.environmentCombo.currentText()
156 interpreter = self.ui.interpreterPicker.currentText() 168 venvName = self.ui.venvComboBox.currentText()
157 169
158 return (interpreter, 170 return (venvName,
159 cmdLine, 171 cmdLine,
160 workdir, 172 workdir,
161 environment, 173 environment,
162 self.ui.exceptionCheckBox.isChecked(), 174 self.ui.exceptionCheckBox.isChecked(),
163 self.ui.clearShellCheckBox.isChecked(), 175 self.ui.clearShellCheckBox.isChecked(),
225 self.__historiesModified = False # clear catches it all 237 self.__historiesModified = False # clear catches it all
226 238
227 cmdLine = self.ui.cmdlineCombo.currentText() 239 cmdLine = self.ui.cmdlineCombo.currentText()
228 workdir = self.ui.workdirPicker.currentText() 240 workdir = self.ui.workdirPicker.currentText()
229 environment = self.ui.environmentCombo.currentText() 241 environment = self.ui.environmentCombo.currentText()
230 interpreter = self.ui.interpreterPicker.currentText()
231 242
232 self.ui.cmdlineCombo.clear() 243 self.ui.cmdlineCombo.clear()
233 self.ui.workdirPicker.clear() 244 self.ui.workdirPicker.clear()
234 self.ui.environmentCombo.clear() 245 self.ui.environmentCombo.clear()
235 self.ui.interpreterPicker.clear()
236 246
237 self.ui.cmdlineCombo.addItem(cmdLine) 247 self.ui.cmdlineCombo.addItem(cmdLine)
238 self.ui.workdirPicker.addItem(workdir) 248 self.ui.workdirPicker.addItem(workdir)
239 self.ui.environmentCombo.addItem(environment) 249 self.ui.environmentCombo.addItem(environment)
240 self.ui.interpreterPicker.addItem(interpreter)
241 250
242 def __editHistory(self): 251 def __editHistory(self):
243 """ 252 """
244 Private slot to edit a history list. 253 Private slot to edit a history list.
245 """ 254 """
246 histories = [ 255 histories = [
247 "", 256 "",
248 self.tr("Interpreter"),
249 self.tr("Command Line"), 257 self.tr("Command Line"),
250 self.tr("Working Directory"), 258 self.tr("Working Directory"),
251 self.tr("Environment"), 259 self.tr("Environment"),
252 ] 260 ]
253 historyKind, ok = QInputDialog.getItem( 261 historyKind, ok = QInputDialog.getItem(
256 self.tr("Select the history list to be edited:"), 264 self.tr("Select the history list to be edited:"),
257 histories, 265 histories,
258 0, False) 266 0, False)
259 if ok and historyKind: 267 if ok and historyKind:
260 historiesIndex = histories.index(historyKind) 268 historiesIndex = histories.index(historyKind)
261 if historiesIndex == 3: 269 if historiesIndex == 2:
262 history = self.ui.workdirPicker.getPathItems() 270 history = self.ui.workdirPicker.getPathItems()
263 elif historiesIndex == 1:
264 history = self.ui.interpreterPicker.getPathItems()
265 else: 271 else:
266 history = [] 272 history = []
267 if historiesIndex == 2: 273 if historiesIndex == 1:
268 combo = self.ui.cmdlineCombo 274 combo = self.ui.cmdlineCombo
269 else: 275 else:
270 combo = self.ui.environmentCombo 276 combo = self.ui.environmentCombo
271 for index in range(combo.count()): 277 for index in range(combo.count()):
272 history.append(combo.itemText(index)) 278 history.append(combo.itemText(index))
274 from .StartHistoryEditDialog import StartHistoryEditDialog 280 from .StartHistoryEditDialog import StartHistoryEditDialog
275 dlg = StartHistoryEditDialog(history, self) 281 dlg = StartHistoryEditDialog(history, self)
276 if dlg.exec_() == QDialog.Accepted: 282 if dlg.exec_() == QDialog.Accepted:
277 history = dlg.getHistory() 283 history = dlg.getHistory()
278 if historiesIndex == 1: 284 if historiesIndex == 1:
279 combo = self.ui.interpreterPicker 285 combo = self.ui.cmdlineCombo
280 elif historiesIndex == 2: 286 elif historiesIndex == 2:
281 combo = self.ui.cmdlineCombo
282 elif historiesIndex == 3:
283 combo = self.ui.workdirPicker 287 combo = self.ui.workdirPicker
284 else: 288 else:
285 combo = self.ui.environmentCombo 289 combo = self.ui.environmentCombo
286 combo.clear() 290 combo.clear()
287 combo.addItems(history) 291 combo.addItems(history)
318 [self.ui.cmdlineCombo.itemText(index) for index in range( 322 [self.ui.cmdlineCombo.itemText(index) for index in range(
319 self.ui.cmdlineCombo.count())], 323 self.ui.cmdlineCombo.count())],
320 self.ui.workdirPicker.getPathItems(), 324 self.ui.workdirPicker.getPathItems(),
321 [self.ui.environmentCombo.itemText(index) for index in range( 325 [self.ui.environmentCombo.itemText(index) for index in range(
322 self.ui.environmentCombo.count())], 326 self.ui.environmentCombo.count())],
323 self.ui.interpreterPicker.getPathItems(),
324 ) 327 )
325 328
326 def on_buttonBox_clicked(self, button): 329 def on_buttonBox_clicked(self, button):
327 """ 330 """
328 Private slot called by a button of the button box clicked. 331 Private slot called by a button of the button box clicked.

eric ide

mercurial