Preferences/ConfigurationPages/DebuggerPythonPage.py

changeset 6346
92ed63434dce
parent 6048
82ad8ec9548c
child 6349
17b3c75913de
equal deleted inserted replaced
6345:b41a239a4949 6346:92ed63434dce
7 Module implementing the Debugger Python configuration page. 7 Module implementing the Debugger Python configuration page.
8 """ 8 """
9 9
10 from __future__ import unicode_literals 10 from __future__ import unicode_literals
11 11
12 from E5Gui.E5Application import e5App
12 from E5Gui.E5PathPicker import E5PathPickerModes 13 from E5Gui.E5PathPicker import E5PathPickerModes
13 14
14 from .ConfigurationPageBase import ConfigurationPageBase 15 from .ConfigurationPageBase import ConfigurationPageBase
15 from .Ui_DebuggerPythonPage import Ui_DebuggerPythonPage 16 from .Ui_DebuggerPythonPage import Ui_DebuggerPythonPage
16 17
27 """ 28 """
28 super(DebuggerPythonPage, self).__init__() 29 super(DebuggerPythonPage, self).__init__()
29 self.setupUi(self) 30 self.setupUi(self)
30 self.setObjectName("DebuggerPythonPage") 31 self.setObjectName("DebuggerPythonPage")
31 32
32 self.interpreterPicker.setMode(E5PathPickerModes.OpenFileMode) 33 try:
33 self.interpreterPicker.setToolTip(self.tr( 34 virtualenvManager = e5App().getObject("VirtualEnvManager")
34 "Press to select the Python interpreter via a file selection" 35 except KeyError:
35 " dialog")) 36 from VirtualEnv.VirtualenvManager import VirtualenvManager
37 virtualenvManager = VirtualenvManager()
38 self.venvComboBox.addItems(
39 [""] + sorted(virtualenvManager.getVirtualenvNames()))
36 40
37 self.debugClientPicker.setMode(E5PathPickerModes.OpenFileMode) 41 self.debugClientPicker.setMode(E5PathPickerModes.OpenFileMode)
38 self.debugClientPicker.setToolTip(self.tr( 42 self.debugClientPicker.setToolTip(self.tr(
39 "Press to select the Debug Client via a file selection dialog")) 43 "Press to select the Debug Client via a file selection dialog"))
40 self.debugClientPicker.setFilters(self.tr("Python Files (*.py *.py2)")) 44 self.debugClientPicker.setFilters(self.tr("Python Files (*.py *.py2)"))
41 45
42 # set initial values 46 # set initial values
43 self.interpreterPicker.setText( 47 venvName = Preferences.getDebugger("Python2VirtualEnv")
44 Preferences.getDebugger("PythonInterpreter"), toNative=False) 48 if venvName:
49 index = self.venvComboBox.findText(venvName)
50 if index < 0:
51 index = 0
52 self.venvComboBox.setCurrentIndex(index)
45 dct = Preferences.getDebugger("DebugClientType") 53 dct = Preferences.getDebugger("DebugClientType")
46 if dct == "standard": 54 if dct == "standard":
47 self.standardButton.setChecked(True) 55 self.standardButton.setChecked(True)
48 else: 56 else:
49 self.customButton.setChecked(True) 57 self.customButton.setChecked(True)
58 66
59 def save(self): 67 def save(self):
60 """ 68 """
61 Public slot to save the Debugger Python configuration. 69 Public slot to save the Debugger Python configuration.
62 """ 70 """
63 Preferences.setDebugger( 71 venvName = self.venvComboBox.currentText()
64 "PythonInterpreter", 72 if venvName:
65 self.interpreterPicker.text(toNative=False)) 73 Preferences.setDebugger(
74 "Python2VirtualEnv",
75 venvName)
66 if self.standardButton.isChecked(): 76 if self.standardButton.isChecked():
67 dct = "standard" 77 dct = "standard"
68 else: 78 else:
69 dct = "custom" 79 dct = "custom"
70 Preferences.setDebugger("DebugClientType", dct) 80 Preferences.setDebugger("DebugClientType", dct)

eric ide

mercurial