21 |
21 |
22 class DebuggerPython3Page(ConfigurationPageBase, Ui_DebuggerPython3Page): |
22 class DebuggerPython3Page(ConfigurationPageBase, Ui_DebuggerPython3Page): |
23 """ |
23 """ |
24 Class implementing the Debugger Python3 configuration page. |
24 Class implementing the Debugger Python3 configuration page. |
25 """ |
25 """ |
|
26 |
26 def __init__(self): |
27 def __init__(self): |
27 """ |
28 """ |
28 Constructor |
29 Constructor |
29 """ |
30 """ |
30 super().__init__() |
31 super().__init__() |
31 self.setupUi(self) |
32 self.setupUi(self) |
32 self.setObjectName("DebuggerPython3Page") |
33 self.setObjectName("DebuggerPython3Page") |
33 |
34 |
34 try: |
35 try: |
35 self.__virtualenvManager = ericApp().getObject("VirtualEnvManager") |
36 self.__virtualenvManager = ericApp().getObject("VirtualEnvManager") |
36 self.__standalone = False |
37 self.__standalone = False |
37 except KeyError: |
38 except KeyError: |
38 from VirtualEnv.VirtualenvManager import VirtualenvManager |
39 from VirtualEnv.VirtualenvManager import VirtualenvManager |
|
40 |
39 self.__virtualenvManager = VirtualenvManager() |
41 self.__virtualenvManager = VirtualenvManager() |
40 self.__standalone = True |
42 self.__standalone = True |
41 |
43 |
42 self.venvDlgButton.setVisible(self.__standalone) |
44 self.venvDlgButton.setVisible(self.__standalone) |
43 self.venvDlgButton.setIcon(UI.PixmapCache.getIcon("virtualenv")) |
45 self.venvDlgButton.setIcon(UI.PixmapCache.getIcon("virtualenv")) |
44 |
46 |
45 self.venvRefreshButton.setVisible(not self.__standalone) |
47 self.venvRefreshButton.setVisible(not self.__standalone) |
46 self.venvRefreshButton.setIcon(UI.PixmapCache.getIcon("reload")) |
48 self.venvRefreshButton.setIcon(UI.PixmapCache.getIcon("reload")) |
47 |
49 |
48 self.debugClientPicker.setMode(EricPathPickerModes.OPEN_FILE_MODE) |
50 self.debugClientPicker.setMode(EricPathPickerModes.OPEN_FILE_MODE) |
49 self.debugClientPicker.setToolTip(self.tr( |
51 self.debugClientPicker.setToolTip( |
50 "Press to select the Debug Client via a file selection dialog")) |
52 self.tr("Press to select the Debug Client via a file selection dialog") |
|
53 ) |
51 self.debugClientPicker.setFilters(self.tr("Python Files (*.py *.py3)")) |
54 self.debugClientPicker.setFilters(self.tr("Python Files (*.py *.py3)")) |
52 |
55 |
53 self.__populateAndSetVenvComboBox() |
56 self.__populateAndSetVenvComboBox() |
54 |
57 |
55 # set initial values |
58 # set initial values |
56 dct = Preferences.getDebugger("DebugClientType3") |
59 dct = Preferences.getDebugger("DebugClientType3") |
57 if dct == "standard": |
60 if dct == "standard": |
58 self.standardButton.setChecked(True) |
61 self.standardButton.setChecked(True) |
59 else: |
62 else: |
60 self.customButton.setChecked(True) |
63 self.customButton.setChecked(True) |
61 self.debugClientPicker.setText( |
64 self.debugClientPicker.setText( |
62 Preferences.getDebugger("DebugClient3"), toNative=False) |
65 Preferences.getDebugger("DebugClient3"), toNative=False |
63 self.pyRedirectCheckBox.setChecked( |
66 ) |
64 Preferences.getDebugger("Python3Redirect")) |
67 self.pyRedirectCheckBox.setChecked(Preferences.getDebugger("Python3Redirect")) |
65 self.pyNoEncodingCheckBox.setChecked( |
68 self.pyNoEncodingCheckBox.setChecked( |
66 Preferences.getDebugger("Python3NoEncoding")) |
69 Preferences.getDebugger("Python3NoEncoding") |
67 self.sourceExtensionsEdit.setText( |
70 ) |
68 Preferences.getDebugger("Python3Extensions")) |
71 self.sourceExtensionsEdit.setText(Preferences.getDebugger("Python3Extensions")) |
69 |
72 |
70 def save(self): |
73 def save(self): |
71 """ |
74 """ |
72 Public slot to save the Debugger Python configuration. |
75 Public slot to save the Debugger Python configuration. |
73 """ |
76 """ |
74 Preferences.setDebugger( |
77 Preferences.setDebugger("Python3VirtualEnv", self.venvComboBox.currentText()) |
75 "Python3VirtualEnv", |
|
76 self.venvComboBox.currentText()) |
|
77 dct = "standard" if self.standardButton.isChecked() else "custom" |
78 dct = "standard" if self.standardButton.isChecked() else "custom" |
78 Preferences.setDebugger("DebugClientType3", dct) |
79 Preferences.setDebugger("DebugClientType3", dct) |
79 Preferences.setDebugger( |
80 Preferences.setDebugger( |
80 "DebugClient3", |
81 "DebugClient3", self.debugClientPicker.text(toNative=False) |
81 self.debugClientPicker.text(toNative=False)) |
82 ) |
|
83 Preferences.setDebugger("Python3Redirect", self.pyRedirectCheckBox.isChecked()) |
82 Preferences.setDebugger( |
84 Preferences.setDebugger( |
83 "Python3Redirect", |
85 "Python3NoEncoding", self.pyNoEncodingCheckBox.isChecked() |
84 self.pyRedirectCheckBox.isChecked()) |
86 ) |
85 Preferences.setDebugger( |
87 |
86 "Python3NoEncoding", |
|
87 self.pyNoEncodingCheckBox.isChecked()) |
|
88 |
|
89 def __populateAndSetVenvComboBox(self): |
88 def __populateAndSetVenvComboBox(self): |
90 """ |
89 """ |
91 Private method to populate and set the virtual environment combo box. |
90 Private method to populate and set the virtual environment combo box. |
92 """ |
91 """ |
93 self.venvComboBox.clear() |
92 self.venvComboBox.clear() |
94 self.venvComboBox.addItems( |
93 self.venvComboBox.addItems( |
95 [""] + |
94 [""] + sorted(self.__virtualenvManager.getVirtualenvNames()) |
96 sorted(self.__virtualenvManager.getVirtualenvNames()) |
|
97 ) |
95 ) |
98 |
96 |
99 # set initial value |
97 # set initial value |
100 venvName = Preferences.getDebugger("Python3VirtualEnv") |
98 venvName = Preferences.getDebugger("Python3VirtualEnv") |
101 if venvName: |
99 if venvName: |
102 index = self.venvComboBox.findText(venvName) |
100 index = self.venvComboBox.findText(venvName) |
103 if index < 0: |
101 if index < 0: |
104 index = 0 |
102 index = 0 |
105 self.venvComboBox.setCurrentIndex(index) |
103 self.venvComboBox.setCurrentIndex(index) |
106 |
104 |
107 @pyqtSlot() |
105 @pyqtSlot() |
108 def on_refreshButton_clicked(self): |
106 def on_refreshButton_clicked(self): |
109 """ |
107 """ |
110 Private slot handling a click of the refresh button. |
108 Private slot handling a click of the refresh button. |
111 """ |
109 """ |
112 self.sourceExtensionsEdit.setText( |
110 self.sourceExtensionsEdit.setText(Preferences.getDebugger("Python3Extensions")) |
113 Preferences.getDebugger("Python3Extensions")) |
111 |
114 |
|
115 @pyqtSlot() |
112 @pyqtSlot() |
116 def on_venvDlgButton_clicked(self): |
113 def on_venvDlgButton_clicked(self): |
117 """ |
114 """ |
118 Private slot to show the virtual environment manager dialog. |
115 Private slot to show the virtual environment manager dialog. |
119 """ |
116 """ |
120 if self.__standalone: |
117 if self.__standalone: |
121 self.__virtualenvManager.showVirtualenvManagerDialog(modal=True) |
118 self.__virtualenvManager.showVirtualenvManagerDialog(modal=True) |
122 self.__populateAndSetVenvComboBox() |
119 self.__populateAndSetVenvComboBox() |
123 self.activateWindow() |
120 self.activateWindow() |
124 self.raise_() |
121 self.raise_() |
125 |
122 |
126 @pyqtSlot() |
123 @pyqtSlot() |
127 def on_venvRefreshButton_clicked(self): |
124 def on_venvRefreshButton_clicked(self): |
128 """ |
125 """ |
129 Private slot to reload the list of virtual environments. |
126 Private slot to reload the list of virtual environments. |
130 """ |
127 """ |
131 self.__populateAndSetVenvComboBox() |
128 self.__populateAndSetVenvComboBox() |
132 |
129 |
133 |
130 |
134 def create(dlg): |
131 def create(dlg): |
135 """ |
132 """ |
136 Module function to create the configuration page. |
133 Module function to create the configuration page. |
137 |
134 |
138 @param dlg reference to the configuration dialog |
135 @param dlg reference to the configuration dialog |
139 @return reference to the instantiated page (ConfigurationPageBase) |
136 @return reference to the instantiated page (ConfigurationPageBase) |
140 """ |
137 """ |
141 page = DebuggerPython3Page() |
138 page = DebuggerPython3Page() |
142 return page |
139 return page |