|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2009 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing the Debugger Python3 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_DebuggerPython3Page import Ui_DebuggerPython3Page |
|
17 |
|
18 import Preferences |
|
19 import Utilities |
|
20 |
|
21 class DebuggerPython3Page(ConfigurationPageBase, Ui_DebuggerPython3Page): |
|
22 """ |
|
23 Class implementing the Debugger Python3 configuration page. |
|
24 """ |
|
25 def __init__(self): |
|
26 """ |
|
27 Constructor |
|
28 """ |
|
29 ConfigurationPageBase.__init__(self) |
|
30 self.setupUi(self) |
|
31 self.setObjectName("DebuggerPython3Page") |
|
32 |
|
33 self.interpreterCompleter = E4FileCompleter(self.interpreterEdit) |
|
34 self.debugClientCompleter = E4FileCompleter(self.debugClientEdit) |
|
35 |
|
36 # set initial values |
|
37 self.interpreterEdit.setText(\ |
|
38 Preferences.getDebugger("Python3Interpreter")) |
|
39 dct = Preferences.getDebugger("DebugClientType3") |
|
40 if dct == "standard": |
|
41 self.standardButton.setChecked(True) |
|
42 elif dct == "threaded": |
|
43 self.threadedButton.setChecked(True) |
|
44 else: |
|
45 self.customButton.setChecked(True) |
|
46 self.debugClientEdit.setText( |
|
47 Preferences.getDebugger("DebugClient3")) |
|
48 self.pyRedirectCheckBox.setChecked( |
|
49 Preferences.getDebugger("Python3Redirect")) |
|
50 self.pyNoEncodingCheckBox.setChecked( |
|
51 Preferences.getDebugger("Python3NoEncoding")) |
|
52 self.sourceExtensionsEdit.setText( |
|
53 Preferences.getDebugger("Python3Extensions")) |
|
54 |
|
55 def save(self): |
|
56 """ |
|
57 Public slot to save the Debugger Python configuration. |
|
58 """ |
|
59 Preferences.setDebugger("Python3Interpreter", |
|
60 self.interpreterEdit.text()) |
|
61 if self.standardButton.isChecked(): |
|
62 dct = "standard" |
|
63 elif self.threadedButton.isChecked(): |
|
64 dct = "threaded" |
|
65 else: |
|
66 dct = "custom" |
|
67 Preferences.setDebugger("DebugClientType3", dct) |
|
68 Preferences.setDebugger("DebugClient3", |
|
69 self.debugClientEdit.text()) |
|
70 Preferences.setDebugger("Python3Redirect", |
|
71 int(self.pyRedirectCheckBox.isChecked())) |
|
72 Preferences.setDebugger("Python3NoEncoding", |
|
73 int(self.pyNoEncodingCheckBox.isChecked())) |
|
74 Preferences.setDebugger("Python3Extensions", |
|
75 self.sourceExtensionsEdit.text()) |
|
76 |
|
77 @pyqtSlot() |
|
78 def on_interpreterButton_clicked(self): |
|
79 """ |
|
80 Private slot to handle the Python interpreter selection. |
|
81 """ |
|
82 file = QFileDialog.getOpenFileName(\ |
|
83 self, |
|
84 self.trUtf8("Select Python interpreter for Debug Client"), |
|
85 self.interpreterEdit.text(), |
|
86 "") |
|
87 |
|
88 if file: |
|
89 self.interpreterEdit.setText(\ |
|
90 Utilities.toNativeSeparators(file)) |
|
91 |
|
92 @pyqtSlot() |
|
93 def on_debugClientButton_clicked(self): |
|
94 """ |
|
95 Private slot to handle the Debug Client selection. |
|
96 """ |
|
97 file = QFileDialog.getOpenFileName(\ |
|
98 None, |
|
99 self.trUtf8("Select Debug Client"), |
|
100 self.debugClientEdit.text(), |
|
101 self.trUtf8("Python Files (*.py *.py3)")) |
|
102 |
|
103 if file: |
|
104 self.debugClientEdit.setText(\ |
|
105 Utilities.toNativeSeparators(file)) |
|
106 |
|
107 def create(dlg): |
|
108 """ |
|
109 Module function to create the configuration page. |
|
110 |
|
111 @param dlg reference to the configuration dialog |
|
112 """ |
|
113 page = DebuggerPython3Page() |
|
114 return page |