eric6/Preferences/ConfigurationPages/DebuggerPython3Page.py

changeset 6942
2602857055c5
parent 6645
ad476851d7e0
child 7229
53054eb5b15a
equal deleted inserted replaced
6941:f99d60d6b59b 6942:2602857055c5
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2009 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing the Debugger Python3 configuration page.
8 """
9
10 from __future__ import unicode_literals
11
12 from PyQt5.QtCore import pyqtSlot
13
14 from E5Gui.E5Application import e5App
15 from E5Gui.E5PathPicker import E5PathPickerModes
16
17 from .ConfigurationPageBase import ConfigurationPageBase
18 from .Ui_DebuggerPython3Page import Ui_DebuggerPython3Page
19
20 import Preferences
21 import UI.PixmapCache
22
23
24 class DebuggerPython3Page(ConfigurationPageBase, Ui_DebuggerPython3Page):
25 """
26 Class implementing the Debugger Python3 configuration page.
27 """
28 def __init__(self):
29 """
30 Constructor
31 """
32 super(DebuggerPython3Page, self).__init__()
33 self.setupUi(self)
34 self.setObjectName("DebuggerPython3Page")
35
36 try:
37 self.__virtualenvManager = e5App().getObject("VirtualEnvManager")
38 except KeyError:
39 from VirtualEnv.VirtualenvManager import VirtualenvManager
40 self.__virtualenvManager = VirtualenvManager()
41
42 self.venvDlgButton.setIcon(UI.PixmapCache.getIcon("virtualenv.png"))
43
44 self.debugClientPicker.setMode(E5PathPickerModes.OpenFileMode)
45 self.debugClientPicker.setToolTip(self.tr(
46 "Press to select the Debug Client via a file selection dialog"))
47 self.debugClientPicker.setFilters(self.tr("Python Files (*.py *.py3)"))
48
49 self.__populateAndSetVenvComboBox()
50
51 # set initial values
52 dct = Preferences.getDebugger("DebugClientType3")
53 if dct == "standard":
54 self.standardButton.setChecked(True)
55 else:
56 self.customButton.setChecked(True)
57 self.debugClientPicker.setText(
58 Preferences.getDebugger("DebugClient3"), toNative=False)
59 self.pyRedirectCheckBox.setChecked(
60 Preferences.getDebugger("Python3Redirect"))
61 self.pyNoEncodingCheckBox.setChecked(
62 Preferences.getDebugger("Python3NoEncoding"))
63 self.sourceExtensionsEdit.setText(
64 Preferences.getDebugger("Python3Extensions"))
65
66 def save(self):
67 """
68 Public slot to save the Debugger Python configuration.
69 """
70 Preferences.setDebugger(
71 "Python3VirtualEnv",
72 self.venvComboBox.currentText())
73 if self.standardButton.isChecked():
74 dct = "standard"
75 else:
76 dct = "custom"
77 Preferences.setDebugger("DebugClientType3", dct)
78 Preferences.setDebugger(
79 "DebugClient3",
80 self.debugClientPicker.text(toNative=False))
81 Preferences.setDebugger(
82 "Python3Redirect",
83 self.pyRedirectCheckBox.isChecked())
84 Preferences.setDebugger(
85 "Python3NoEncoding",
86 self.pyNoEncodingCheckBox.isChecked())
87
88 def __populateAndSetVenvComboBox(self):
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 Private slot to show the virtual environment manager dialog.
118 """
119 self.__virtualenvManager.showVirtualenvManagerDialog(modal=True)
120 self.__populateAndSetVenvComboBox()
121 self.activateWindow()
122 self.raise_()
123
124
125 def create(dlg):
126 """
127 Module function to create the configuration page.
128
129 @param dlg reference to the configuration dialog
130 @return reference to the instantiated page (ConfigurationPageBase)
131 """
132 page = DebuggerPython3Page()
133 return page

eric ide

mercurial