Preferences/ConfigurationPages/DebuggerPythonPage.py

changeset 0
de9c2efb9d02
child 7
c679fb30c8f3
equal deleted inserted replaced
-1:000000000000 0:de9c2efb9d02
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2006 - 2009 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing the Debugger Python configuration page.
8 """
9
10 from PyQt4.QtCore import QDir, pyqtSlot
11 from PyQt4.QtGui import QFileDialog
12
13 from E4Gui.E4Completers import E4FileCompleter
14
15 from ConfigurationPageBase import ConfigurationPageBase
16 from Ui_DebuggerPythonPage import Ui_DebuggerPythonPage
17
18 import Preferences
19 import Utilities
20
21 class DebuggerPythonPage(ConfigurationPageBase, Ui_DebuggerPythonPage):
22 """
23 Class implementing the Debugger Python configuration page.
24 """
25 def __init__(self):
26 """
27 Constructor
28 """
29 ConfigurationPageBase.__init__(self)
30 self.setupUi(self)
31 self.setObjectName("DebuggerPythonPage")
32
33 self.interpreterCompleter = E4FileCompleter(self.interpreterEdit)
34 self.debugClientCompleter = E4FileCompleter(self.debugClientEdit)
35
36 # set initial values
37 self.customPyCheckBox.setChecked(\
38 Preferences.getDebugger("CustomPythonInterpreter"))
39 self.interpreterEdit.setText(\
40 Preferences.getDebugger("PythonInterpreter"))
41 dct = Preferences.getDebugger("DebugClientType")
42 if dct == "standard":
43 self.standardButton.setChecked(True)
44 elif dct == "threaded":
45 self.threadedButton.setChecked(True)
46 else:
47 self.customButton.setChecked(True)
48 self.debugClientEdit.setText(\
49 Preferences.getDebugger("DebugClient"))
50 self.pyRedirectCheckBox.setChecked(\
51 Preferences.getDebugger("PythonRedirect"))
52 self.pyNoEncodingCheckBox.setChecked(\
53 Preferences.getDebugger("PythonNoEncoding"))
54 self.sourceExtensionsEdit.setText(
55 Preferences.getDebugger("PythonExtensions"))
56
57 def save(self):
58 """
59 Public slot to save the Debugger Python configuration.
60 """
61 Preferences.setDebugger("CustomPythonInterpreter",
62 int(self.customPyCheckBox.isChecked()))
63 Preferences.setDebugger("PythonInterpreter",
64 self.interpreterEdit.text())
65 if self.standardButton.isChecked():
66 dct = "standard"
67 elif self.threadedButton.isChecked():
68 dct = "threaded"
69 else:
70 dct = "custom"
71 Preferences.setDebugger("DebugClientType", dct)
72 Preferences.setDebugger("DebugClient",
73 self.debugClientEdit.text())
74 Preferences.setDebugger("PythonRedirect",
75 int(self.pyRedirectCheckBox.isChecked()))
76 Preferences.setDebugger("PythonNoEncoding",
77 int(self.pyNoEncodingCheckBox.isChecked()))
78 Preferences.setDebugger("PythonExtensions",
79 self.sourceExtensionsEdit.text())
80
81 @pyqtSlot()
82 def on_interpreterButton_clicked(self):
83 """
84 Private slot to handle the Python interpreter selection.
85 """
86 file = QFileDialog.getOpenFileName(\
87 self,
88 self.trUtf8("Select Python interpreter for Debug Client"),
89 self.interpreterEdit.text(),
90 "")
91
92 if file:
93 self.interpreterEdit.setText(\
94 Utilities.toNativeSeparators(file))
95
96 @pyqtSlot()
97 def on_debugClientButton_clicked(self):
98 """
99 Private slot to handle the Debug Client selection.
100 """
101 file = QFileDialog.getOpenFileName(\
102 None,
103 self.trUtf8("Select Debug Client"),
104 self.debugClientEdit.text(),
105 self.trUtf8("Python Files (*.py)"))
106
107 if file:
108 self.debugClientEdit.setText(\
109 Utilities.toNativeSeparators(file))
110
111 def create(dlg):
112 """
113 Module function to create the configuration page.
114
115 @param dlg reference to the configuration dialog
116 """
117 page = DebuggerPythonPage()
118 return page

eric ide

mercurial