|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2006 - 2009 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing the Python configuration page. |
|
8 """ |
|
9 |
|
10 from ConfigurationPageBase import ConfigurationPageBase |
|
11 from Ui_PythonPage import Ui_PythonPage |
|
12 |
|
13 import Preferences |
|
14 from Utilities import supportedCodecs |
|
15 |
|
16 class PythonPage(ConfigurationPageBase, Ui_PythonPage): |
|
17 """ |
|
18 Class implementing the Python configuration page. |
|
19 """ |
|
20 def __init__(self): |
|
21 """ |
|
22 Constructor |
|
23 """ |
|
24 ConfigurationPageBase.__init__(self) |
|
25 self.setupUi(self) |
|
26 self.setObjectName("PythonPage") |
|
27 |
|
28 self.stringEncodingComboBox.addItems(sorted(supportedCodecs)) |
|
29 self.ioEncodingComboBox.addItems(sorted(supportedCodecs)) |
|
30 |
|
31 # set initial values |
|
32 index = self.stringEncodingComboBox.findText(\ |
|
33 Preferences.getSystem("StringEncoding")) |
|
34 self.stringEncodingComboBox.setCurrentIndex(index) |
|
35 index = self.ioEncodingComboBox.findText(\ |
|
36 Preferences.getSystem("IOEncoding")) |
|
37 self.ioEncodingComboBox.setCurrentIndex(index) |
|
38 |
|
39 # these are the same as in the debugger pages |
|
40 self.py2ExtensionsEdit.setText( |
|
41 Preferences.getDebugger("PythonExtensions")) |
|
42 self.py3ExtensionsEdit.setText( |
|
43 Preferences.getDebugger("Python3Extensions")) |
|
44 |
|
45 def save(self): |
|
46 """ |
|
47 Public slot to save the Python configuration. |
|
48 """ |
|
49 enc = self.stringEncodingComboBox.currentText() |
|
50 if not enc: |
|
51 enc = "utf-8" |
|
52 Preferences.setSystem("StringEncoding", enc) |
|
53 |
|
54 enc = self.ioEncodingComboBox.currentText() |
|
55 if not enc: |
|
56 enc = "utf-8" |
|
57 Preferences.setSystem("IOEncoding", enc) |
|
58 |
|
59 Preferences.setDebugger("PythonExtensions", |
|
60 self.py2ExtensionsEdit.text()) |
|
61 Preferences.setDebugger("Python3Extensions", |
|
62 self.py3ExtensionsEdit.text()) |
|
63 |
|
64 def create(dlg): |
|
65 """ |
|
66 Module function to create the configuration page. |
|
67 |
|
68 @param dlg reference to the configuration dialog |
|
69 """ |
|
70 page = PythonPage() |
|
71 return page |