Preferences/ConfigurationPages/DebuggerPython2Page.py

changeset 6381
37f23590dbbc
parent 6357
ceb3d7c25650
child 6386
91dc4fa9bc9c
equal deleted inserted replaced
6380:4a932a7ab987 6381:37f23590dbbc
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2006 - 2018 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing the Debugger Python2 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_DebuggerPython2Page import Ui_DebuggerPython2Page
19
20 import Preferences
21 import UI.PixmapCache
22
23
24 class DebuggerPython2Page(ConfigurationPageBase, Ui_DebuggerPython2Page):
25 """
26 Class implementing the Debugger Python2 configuration page.
27 """
28 def __init__(self):
29 """
30 Constructor
31 """
32 super(DebuggerPython2Page, self).__init__()
33 self.setupUi(self)
34 self.setObjectName("DebuggerPython2Page")
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 *.py2)"))
48
49 self.__populateAndSetVenvComboBox()
50
51 # set initial values
52 dct = Preferences.getDebugger("DebugClientType")
53 if dct == "standard":
54 self.standardButton.setChecked(True)
55 else:
56 self.customButton.setChecked(True)
57 self.debugClientPicker.setText(
58 Preferences.getDebugger("DebugClient"), toNative=False)
59 self.pyRedirectCheckBox.setChecked(
60 Preferences.getDebugger("PythonRedirect"))
61 self.pyNoEncodingCheckBox.setChecked(
62 Preferences.getDebugger("PythonNoEncoding"))
63 self.sourceExtensionsEdit.setText(
64 Preferences.getDebugger("PythonExtensions"))
65
66 def save(self):
67 """
68 Public slot to save the Debugger Python configuration.
69 """
70 Preferences.setDebugger(
71 "Python2VirtualEnv",
72 self.venvComboBox.currentText())
73 if self.standardButton.isChecked():
74 dct = "standard"
75 else:
76 dct = "custom"
77 Preferences.setDebugger("DebugClientType", dct)
78 Preferences.setDebugger(
79 "DebugClient",
80 self.debugClientPicker.text(toNative=False))
81 Preferences.setDebugger(
82 "PythonRedirect",
83 self.pyRedirectCheckBox.isChecked())
84 Preferences.setDebugger(
85 "PythonNoEncoding",
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(2))
96 )
97
98 # set initial value
99 venvName = Preferences.getDebugger("Python2VirtualEnv")
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("PythonExtensions"))
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_()
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 = DebuggerPython2Page()
133 return page

eric ide

mercurial