7 Module implementing the Debugger Python3 configuration page. |
7 Module implementing the Debugger Python3 configuration page. |
8 """ |
8 """ |
9 |
9 |
10 from __future__ import unicode_literals |
10 from __future__ import unicode_literals |
11 |
11 |
|
12 from PyQt5.QtCore import pyqtSlot |
|
13 |
12 from E5Gui.E5Application import e5App |
14 from E5Gui.E5Application import e5App |
13 from E5Gui.E5PathPicker import E5PathPickerModes |
15 from E5Gui.E5PathPicker import E5PathPickerModes |
14 |
16 |
15 from .ConfigurationPageBase import ConfigurationPageBase |
17 from .ConfigurationPageBase import ConfigurationPageBase |
16 from .Ui_DebuggerPython3Page import Ui_DebuggerPython3Page |
18 from .Ui_DebuggerPython3Page import Ui_DebuggerPython3Page |
17 |
19 |
18 import Preferences |
20 import Preferences |
|
21 import UI.PixmapCache |
19 |
22 |
20 |
23 |
21 class DebuggerPython3Page(ConfigurationPageBase, Ui_DebuggerPython3Page): |
24 class DebuggerPython3Page(ConfigurationPageBase, Ui_DebuggerPython3Page): |
22 """ |
25 """ |
23 Class implementing the Debugger Python3 configuration page. |
26 Class implementing the Debugger Python3 configuration page. |
29 super(DebuggerPython3Page, self).__init__() |
32 super(DebuggerPython3Page, self).__init__() |
30 self.setupUi(self) |
33 self.setupUi(self) |
31 self.setObjectName("DebuggerPython3Page") |
34 self.setObjectName("DebuggerPython3Page") |
32 |
35 |
33 try: |
36 try: |
34 virtualenvManager = e5App().getObject("VirtualEnvManager") |
37 self.__virtualenvManager = e5App().getObject("VirtualEnvManager") |
35 except KeyError: |
38 except KeyError: |
36 from VirtualEnv.VirtualenvManager import VirtualenvManager |
39 from VirtualEnv.VirtualenvManager import VirtualenvManager |
37 virtualenvManager = VirtualenvManager() |
40 self.__virtualenvManager = VirtualenvManager() |
38 self.venvComboBox.addItems( |
41 |
39 [""] + sorted(virtualenvManager.getVirtualenvNamesForVariant(3))) |
42 self.venvDlgButton.setIcon(UI.PixmapCache.getIcon("virtualenv.png")) |
40 |
43 |
41 self.debugClientPicker.setMode(E5PathPickerModes.OpenFileMode) |
44 self.debugClientPicker.setMode(E5PathPickerModes.OpenFileMode) |
42 self.debugClientPicker.setToolTip(self.tr( |
45 self.debugClientPicker.setToolTip(self.tr( |
43 "Press to select the Debug Client via a file selection dialog")) |
46 "Press to select the Debug Client via a file selection dialog")) |
44 self.debugClientPicker.setFilters(self.tr("Python Files (*.py *.py3)")) |
47 self.debugClientPicker.setFilters(self.tr("Python Files (*.py *.py3)")) |
45 |
48 |
|
49 self.__populateAndSetVenvComboBox() |
|
50 |
46 # set initial values |
51 # set initial values |
47 venvName = Preferences.getDebugger("Python3VirtualEnv") |
|
48 if venvName: |
|
49 index = self.venvComboBox.findText(venvName) |
|
50 if index < 0: |
|
51 index = 0 |
|
52 self.venvComboBox.setCurrentIndex(index) |
|
53 dct = Preferences.getDebugger("DebugClientType3") |
52 dct = Preferences.getDebugger("DebugClientType3") |
54 if dct == "standard": |
53 if dct == "standard": |
55 self.standardButton.setChecked(True) |
54 self.standardButton.setChecked(True) |
56 else: |
55 else: |
57 self.customButton.setChecked(True) |
56 self.customButton.setChecked(True) |
61 Preferences.getDebugger("Python3Redirect")) |
60 Preferences.getDebugger("Python3Redirect")) |
62 self.pyNoEncodingCheckBox.setChecked( |
61 self.pyNoEncodingCheckBox.setChecked( |
63 Preferences.getDebugger("Python3NoEncoding")) |
62 Preferences.getDebugger("Python3NoEncoding")) |
64 self.sourceExtensionsEdit.setText( |
63 self.sourceExtensionsEdit.setText( |
65 Preferences.getDebugger("Python3Extensions")) |
64 Preferences.getDebugger("Python3Extensions")) |
66 |
65 |
67 def save(self): |
66 def save(self): |
68 """ |
67 """ |
69 Public slot to save the Debugger Python configuration. |
68 Public slot to save the Debugger Python configuration. |
70 """ |
69 """ |
71 Preferences.setDebugger( |
70 Preferences.setDebugger( |
83 "Python3Redirect", |
82 "Python3Redirect", |
84 self.pyRedirectCheckBox.isChecked()) |
83 self.pyRedirectCheckBox.isChecked()) |
85 Preferences.setDebugger( |
84 Preferences.setDebugger( |
86 "Python3NoEncoding", |
85 "Python3NoEncoding", |
87 self.pyNoEncodingCheckBox.isChecked()) |
86 self.pyNoEncodingCheckBox.isChecked()) |
88 Preferences.setDebugger( |
87 |
89 "Python3Extensions", |
88 def __populateAndSetVenvComboBox(self): |
90 self.sourceExtensionsEdit.text()) |
89 """ |
|
90 Private method to populate and set the virtual environment combo box. |
|
91 """ |
|
92 self.venvComboBox.clear() |
|
93 self.venvComboBox.addItems( |
|
94 [""] + |
|
95 sorted(self.__virtualenvManager.getVirtualenvNamesForVariant(3)) |
|
96 ) |
|
97 |
|
98 # set initial value |
|
99 venvName = Preferences.getDebugger("Python3VirtualEnv") |
|
100 if venvName: |
|
101 index = self.venvComboBox.findText(venvName) |
|
102 if index < 0: |
|
103 index = 0 |
|
104 self.venvComboBox.setCurrentIndex(index) |
|
105 |
|
106 @pyqtSlot() |
|
107 def on_refreshButton_clicked(self): |
|
108 """ |
|
109 Private slot handling a click of the refresh button. |
|
110 """ |
|
111 self.sourceExtensionsEdit.setText( |
|
112 Preferences.getDebugger("Python3Extensions")) |
|
113 |
|
114 @pyqtSlot() |
|
115 def on_venvDlgButton_clicked(self): |
|
116 """ |
|
117 Slot documentation goes here. |
|
118 """ |
|
119 self.__virtualenvManager.showVirtualenvManagerDialog(modal=True) |
|
120 self.__populateAndSetVenvComboBox() |
|
121 self.activateWindow() |
|
122 self.raise_() |
91 |
123 |
92 |
124 |
93 def create(dlg): |
125 def create(dlg): |
94 """ |
126 """ |
95 Module function to create the configuration page. |
127 Module function to create the configuration page. |