Debugger/StartDialog.py

changeset 5899
0516f6548ca6
parent 5587
ea526b78ee6c
child 6048
82ad8ec9548c
equal deleted inserted replaced
5898:fc96d49f5fbf 5899:0516f6548ca6
23 It implements a dialog that is used to start an 23 It implements a dialog that is used to start an
24 application for debugging. It asks the user to enter 24 application for debugging. It asks the user to enter
25 the commandline parameters, the working directory and 25 the commandline parameters, the working directory and
26 whether exception reporting should be disabled. 26 whether exception reporting should be disabled.
27 """ 27 """
28 def __init__(self, caption, argvList, wdList, envList, exceptions, 28 def __init__(self, caption, interpreterList, argvList, wdList, envList,
29 exceptions,
29 parent=None, dialogType=0, modfuncList=None, 30 parent=None, dialogType=0, modfuncList=None,
30 tracePython=False, autoClearShell=True, autoContinue=True, 31 tracePython=False, autoClearShell=True, autoContinue=True,
31 autoFork=False, forkChild=False): 32 autoFork=False, forkChild=False):
32 """ 33 """
33 Constructor 34 Constructor
34 35
35 @param caption the caption to be displayed (string) 36 @param caption the caption to be displayed (string)
37 @param interpreterList list of interpreters (list of string)
36 @param argvList history list of commandline arguments (list of strings) 38 @param argvList history list of commandline arguments (list of strings)
37 @param wdList history list of working directories (list of strings) 39 @param wdList history list of working directories (list of strings)
38 @param envList history list of environment settings (list of strings) 40 @param envList history list of environment settings (list of strings)
39 @param exceptions exception reporting flag (boolean) 41 @param exceptions exception reporting flag (boolean)
40 @param parent parent widget of this dialog (QWidget) 42 @param parent parent widget of this dialog (QWidget)
72 self.ui = Ui_StartCoverageDialog() 74 self.ui = Ui_StartCoverageDialog()
73 elif dialogType == 3: 75 elif dialogType == 3:
74 from .Ui_StartProfileDialog import Ui_StartProfileDialog 76 from .Ui_StartProfileDialog import Ui_StartProfileDialog
75 self.ui = Ui_StartProfileDialog() 77 self.ui = Ui_StartProfileDialog()
76 self.ui.setupUi(self) 78 self.ui.setupUi(self)
79
80 self.ui.interpreterPicker.setMode(E5PathPickerModes.OpenFileMode)
81 self.ui.interpreterPicker.setInsertPolicy(QComboBox.InsertAtTop)
82 self.ui.interpreterPicker.setSizeAdjustPolicy(
83 QComboBox.AdjustToMinimumContentsLength)
84
77 self.ui.workdirPicker.setMode(E5PathPickerModes.DirectoryMode) 85 self.ui.workdirPicker.setMode(E5PathPickerModes.DirectoryMode)
78 self.ui.workdirPicker.setDefaultDirectory( 86 self.ui.workdirPicker.setDefaultDirectory(
79 Preferences.getMultiProject("Workspace")) 87 Preferences.getMultiProject("Workspace"))
80 self.ui.workdirPicker.setInsertPolicy(QComboBox.InsertAtTop) 88 self.ui.workdirPicker.setInsertPolicy(QComboBox.InsertAtTop)
81 self.ui.workdirPicker.setSizeAdjustPolicy( 89 self.ui.workdirPicker.setSizeAdjustPolicy(
100 self.ui.exceptionCheckBox.setChecked(exceptions) 108 self.ui.exceptionCheckBox.setChecked(exceptions)
101 self.ui.clearShellCheckBox.setChecked(autoClearShell) 109 self.ui.clearShellCheckBox.setChecked(autoClearShell)
102 self.ui.consoleCheckBox.setEnabled( 110 self.ui.consoleCheckBox.setEnabled(
103 Preferences.getDebugger("ConsoleDbgCommand") != "") 111 Preferences.getDebugger("ConsoleDbgCommand") != "")
104 self.ui.consoleCheckBox.setChecked(False) 112 self.ui.consoleCheckBox.setChecked(False)
113 self.ui.interpreterPicker.clear()
114 self.ui.interpreterPicker.addItems(interpreterList)
115 if len(interpreterList) > 0:
116 self.ui.interpreterPicker.setCurrentIndex(0)
105 117
106 if dialogType == 0: # start debug dialog 118 if dialogType == 0: # start debug dialog
107 self.ui.tracePythonCheckBox.setChecked(tracePython) 119 self.ui.tracePythonCheckBox.setChecked(tracePython)
108 self.ui.tracePythonCheckBox.show() 120 self.ui.tracePythonCheckBox.show()
109 self.ui.autoContinueCheckBox.setChecked(autoContinue) 121 self.ui.autoContinueCheckBox.setChecked(autoContinue)
132 144
133 def getData(self): 145 def getData(self):
134 """ 146 """
135 Public method to retrieve the data entered into this dialog. 147 Public method to retrieve the data entered into this dialog.
136 148
137 @return a tuple of argv (string), workdir (string), environment 149 @return a tuple of interpreter (string), argv (string), workdir
138 (string), exceptions flag (boolean), clear interpreter flag 150 (string), environment (string), exceptions flag (boolean),
139 (boolean) and run in console flag (boolean) 151 clear interpreter flag (boolean) and run in console flag (boolean)
140 """ 152 """
141 cmdLine = self.ui.cmdlineCombo.currentText() 153 cmdLine = self.ui.cmdlineCombo.currentText()
142 workdir = self.ui.workdirPicker.currentText() 154 workdir = self.ui.workdirPicker.currentText()
143 environment = self.ui.environmentCombo.currentText() 155 environment = self.ui.environmentCombo.currentText()
144 156 interpreter = self.ui.interpreterPicker.currentText()
145 return (cmdLine, 157
158 return (interpreter,
159 cmdLine,
146 workdir, 160 workdir,
147 environment, 161 environment,
148 self.ui.exceptionCheckBox.isChecked(), 162 self.ui.exceptionCheckBox.isChecked(),
149 self.ui.clearShellCheckBox.isChecked(), 163 self.ui.clearShellCheckBox.isChecked(),
150 self.ui.consoleCheckBox.isChecked()) 164 self.ui.consoleCheckBox.isChecked(),
165 )
151 166
152 def getDebugData(self): 167 def getDebugData(self):
153 """ 168 """
154 Public method to retrieve the debug related data entered into this 169 Public method to retrieve the debug related data entered into this
155 dialog. 170 dialog.
210 self.__historiesModified = False # clear catches it all 225 self.__historiesModified = False # clear catches it all
211 226
212 cmdLine = self.ui.cmdlineCombo.currentText() 227 cmdLine = self.ui.cmdlineCombo.currentText()
213 workdir = self.ui.workdirPicker.currentText() 228 workdir = self.ui.workdirPicker.currentText()
214 environment = self.ui.environmentCombo.currentText() 229 environment = self.ui.environmentCombo.currentText()
230 interpreter = self.ui.interpreterPicker.currentText()
215 231
216 self.ui.cmdlineCombo.clear() 232 self.ui.cmdlineCombo.clear()
217 self.ui.workdirPicker.clear() 233 self.ui.workdirPicker.clear()
218 self.ui.environmentCombo.clear() 234 self.ui.environmentCombo.clear()
235 self.ui.interpreterPicker.clear()
219 236
220 self.ui.cmdlineCombo.addItem(cmdLine) 237 self.ui.cmdlineCombo.addItem(cmdLine)
221 self.ui.workdirPicker.addItem(workdir) 238 self.ui.workdirPicker.addItem(workdir)
222 self.ui.environmentCombo.addItem(environment) 239 self.ui.environmentCombo.addItem(environment)
240 self.ui.interpreterPicker.addItem(interpreter)
223 241
224 def __editHistory(self): 242 def __editHistory(self):
225 """ 243 """
226 Private slot to edit a history list. 244 Private slot to edit a history list.
227 """ 245 """
228 histories = [ 246 histories = [
229 "", 247 "",
248 self.tr("Interpreter"),
230 self.tr("Command Line"), 249 self.tr("Command Line"),
231 self.tr("Working Directory"), 250 self.tr("Working Directory"),
232 self.tr("Environment"), 251 self.tr("Environment"),
233 ] 252 ]
234 historyKind, ok = QInputDialog.getItem( 253 historyKind, ok = QInputDialog.getItem(
237 self.tr("Select the history list to be edited:"), 256 self.tr("Select the history list to be edited:"),
238 histories, 257 histories,
239 0, False) 258 0, False)
240 if ok and historyKind: 259 if ok and historyKind:
241 historiesIndex = histories.index(historyKind) 260 historiesIndex = histories.index(historyKind)
242 if historiesIndex == 2: 261 if historiesIndex == 3:
243 history = self.ui.workdirPicker.getPathItems() 262 history = self.ui.workdirPicker.getPathItems()
263 elif historiesIndex == 1:
264 history = self.ui.interpreterPicker.getPathItems()
244 else: 265 else:
245 history = [] 266 history = []
246 if historiesIndex == 1: 267 if historiesIndex == 2:
247 combo = self.ui.cmdlineCombo 268 combo = self.ui.cmdlineCombo
248 else: 269 else:
249 combo = self.ui.environmentCombo 270 combo = self.ui.environmentCombo
250 for index in range(combo.count()): 271 for index in range(combo.count()):
251 history.append(combo.itemText(index)) 272 history.append(combo.itemText(index))
253 from .StartHistoryEditDialog import StartHistoryEditDialog 274 from .StartHistoryEditDialog import StartHistoryEditDialog
254 dlg = StartHistoryEditDialog(history, self) 275 dlg = StartHistoryEditDialog(history, self)
255 if dlg.exec_() == QDialog.Accepted: 276 if dlg.exec_() == QDialog.Accepted:
256 history = dlg.getHistory() 277 history = dlg.getHistory()
257 if historiesIndex == 1: 278 if historiesIndex == 1:
279 combo = self.ui.interpreterPicker
280 elif historiesIndex == 2:
258 combo = self.ui.cmdlineCombo 281 combo = self.ui.cmdlineCombo
259 elif historiesIndex == 2: 282 elif historiesIndex == 3:
260 combo = self.ui.workdirPicker 283 combo = self.ui.workdirPicker
261 else: 284 else:
262 combo = self.ui.environmentCombo 285 combo = self.ui.environmentCombo
263 combo.clear() 286 combo.clear()
264 combo.addItems(history) 287 combo.addItems(history)
286 def getHistories(self): 309 def getHistories(self):
287 """ 310 """
288 Public method to get the lists of histories. 311 Public method to get the lists of histories.
289 312
290 @return tuple containing the histories of command line arguments, 313 @return tuple containing the histories of command line arguments,
291 working directories and environment settings 314 working directories, environment settings and interpreters
292 @rtype tuple of three list of str 315 @rtype tuple of four list of str
293 """ 316 """
294 return ( 317 return (
295 [self.ui.cmdlineCombo.itemText(index) for index in range( 318 [self.ui.cmdlineCombo.itemText(index) for index in range(
296 self.ui.cmdlineCombo.count())], 319 self.ui.cmdlineCombo.count())],
297 self.ui.workdirPicker.getPathItems(), 320 self.ui.workdirPicker.getPathItems(),
298 [self.ui.environmentCombo.itemText(index) for index in range( 321 [self.ui.environmentCombo.itemText(index) for index in range(
299 self.ui.environmentCombo.count())], 322 self.ui.environmentCombo.count())],
323 self.ui.interpreterPicker.getPathItems(),
300 ) 324 )
301 325
302 def on_buttonBox_clicked(self, button): 326 def on_buttonBox_clicked(self, button):
303 """ 327 """
304 Private slot called by a button of the button box clicked. 328 Private slot called by a button of the button box clicked.

eric ide

mercurial