eric6/Preferences/ConfigurationPages/MicroPythonPage.py

Fri, 16 Aug 2019 17:17:32 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Fri, 16 Aug 2019 17:17:32 +0200
branch
micropython
changeset 7140
22f5fd76c10f
parent 7135
44fcfc99b864
child 7161
728018c32b09
permissions
-rw-r--r--

MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.

7079
d1564b590677 Preferences: added a configuration pyge for the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
d1564b590677 Preferences: added a configuration pyge for the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
d1564b590677 Preferences: added a configuration pyge for the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
3 # Copyright (c) 2019 Detlev Offenbach <detlev@die-offenbachs.de>
d1564b590677 Preferences: added a configuration pyge for the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
d1564b590677 Preferences: added a configuration pyge for the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
d1564b590677 Preferences: added a configuration pyge for the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
d1564b590677 Preferences: added a configuration pyge for the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing the MicroPython configuration page.
d1564b590677 Preferences: added a configuration pyge for the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
d1564b590677 Preferences: added a configuration pyge for the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
d1564b590677 Preferences: added a configuration pyge for the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 from __future__ import unicode_literals
d1564b590677 Preferences: added a configuration pyge for the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11
7140
22f5fd76c10f MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7135
diff changeset
12 from E5Gui.E5PathPicker import E5PathPickerModes
22f5fd76c10f MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7135
diff changeset
13
7079
d1564b590677 Preferences: added a configuration pyge for the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14 from .ConfigurationPageBase import ConfigurationPageBase
d1564b590677 Preferences: added a configuration pyge for the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15 from .Ui_MicroPythonPage import Ui_MicroPythonPage
d1564b590677 Preferences: added a configuration pyge for the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
d1564b590677 Preferences: added a configuration pyge for the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 import Preferences
d1564b590677 Preferences: added a configuration pyge for the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18
7134
21d23ca51680 Renamed "MicroPythonReplWidget" to "MicroPythonWidget".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7099
diff changeset
19 from MicroPython.MicroPythonWidget import AnsiColorSchemes
7079
d1564b590677 Preferences: added a configuration pyge for the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20
d1564b590677 Preferences: added a configuration pyge for the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21
d1564b590677 Preferences: added a configuration pyge for the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 class MicroPythonPage(ConfigurationPageBase, Ui_MicroPythonPage):
d1564b590677 Preferences: added a configuration pyge for the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 """
d1564b590677 Preferences: added a configuration pyge for the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 Class implementing the MicroPython configuration page.
d1564b590677 Preferences: added a configuration pyge for the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 """
d1564b590677 Preferences: added a configuration pyge for the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 def __init__(self, parent=None):
d1564b590677 Preferences: added a configuration pyge for the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 """
d1564b590677 Preferences: added a configuration pyge for the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 Constructor
d1564b590677 Preferences: added a configuration pyge for the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29
d1564b590677 Preferences: added a configuration pyge for the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 @param parent reference to the parent widget
d1564b590677 Preferences: added a configuration pyge for the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 @type QWidget
d1564b590677 Preferences: added a configuration pyge for the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 """
d1564b590677 Preferences: added a configuration pyge for the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 super(MicroPythonPage, self).__init__()
d1564b590677 Preferences: added a configuration pyge for the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 self.setupUi(self)
d1564b590677 Preferences: added a configuration pyge for the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 self.setObjectName("MicroPythonPage")
d1564b590677 Preferences: added a configuration pyge for the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36
d1564b590677 Preferences: added a configuration pyge for the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 self.colorSchemeComboBox.addItems(sorted(AnsiColorSchemes.keys()))
d1564b590677 Preferences: added a configuration pyge for the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38
7140
22f5fd76c10f MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7135
diff changeset
39 self.mpyCrossPicker.setMode(E5PathPickerModes.OpenFileMode)
22f5fd76c10f MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7135
diff changeset
40 self.mpyCrossPicker.setFilters(self.tr("All Files (*)"))
22f5fd76c10f MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7135
diff changeset
41
7079
d1564b590677 Preferences: added a configuration pyge for the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 # set initial values
7099
89f11ae6bec3 Preferences: added an option to configure the REPL pane line wrap mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7086
diff changeset
43 self.timeoutSpinBox.setValue(
89f11ae6bec3 Preferences: added an option to configure the REPL pane line wrap mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7086
diff changeset
44 Preferences.getMicroPython("SerialTimeout") / 1000)
89f11ae6bec3 Preferences: added an option to configure the REPL pane line wrap mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7086
diff changeset
45 # converted to seconds
7135
44fcfc99b864 MicroPython: added an option to synchronize the device time to the host time after connecting the serial port.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7134
diff changeset
46 self.syncTimeCheckBox.setChecked(
44fcfc99b864 MicroPython: added an option to synchronize the device time to the host time after connecting the serial port.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7134
diff changeset
47 Preferences.getMicroPython("SyncTimeAfterConnect"))
7079
d1564b590677 Preferences: added a configuration pyge for the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 self.colorSchemeComboBox.setCurrentIndex(
d1564b590677 Preferences: added a configuration pyge for the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 self.colorSchemeComboBox.findText(
d1564b590677 Preferences: added a configuration pyge for the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 Preferences.getMicroPython("ColorScheme")))
7099
89f11ae6bec3 Preferences: added an option to configure the REPL pane line wrap mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7086
diff changeset
51 self.replWrapCheckBox.setChecked(
89f11ae6bec3 Preferences: added an option to configure the REPL pane line wrap mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7086
diff changeset
52 Preferences.getMicroPython("ReplLineWrap"))
7140
22f5fd76c10f MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7135
diff changeset
53 self.mpyCrossPicker.setText(
22f5fd76c10f MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7135
diff changeset
54 Preferences.getMicroPython("MpyCrossCompiler"))
7079
d1564b590677 Preferences: added a configuration pyge for the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55
d1564b590677 Preferences: added a configuration pyge for the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 def save(self):
d1564b590677 Preferences: added a configuration pyge for the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 """
d1564b590677 Preferences: added a configuration pyge for the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 Public slot to save the MicroPython configuration.
d1564b590677 Preferences: added a configuration pyge for the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 """
d1564b590677 Preferences: added a configuration pyge for the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 Preferences.setMicroPython(
7099
89f11ae6bec3 Preferences: added an option to configure the REPL pane line wrap mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7086
diff changeset
61 "SerialTimeout", self.timeoutSpinBox.value() * 1000)
89f11ae6bec3 Preferences: added an option to configure the REPL pane line wrap mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7086
diff changeset
62 # converted to milliseconds
89f11ae6bec3 Preferences: added an option to configure the REPL pane line wrap mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7086
diff changeset
63 Preferences.setMicroPython(
7135
44fcfc99b864 MicroPython: added an option to synchronize the device time to the host time after connecting the serial port.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7134
diff changeset
64 "SyncTimeAfterConnect", self.syncTimeCheckBox.isChecked())
44fcfc99b864 MicroPython: added an option to synchronize the device time to the host time after connecting the serial port.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7134
diff changeset
65 Preferences.setMicroPython(
7079
d1564b590677 Preferences: added a configuration pyge for the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 "ColorScheme", self.colorSchemeComboBox.currentText())
7086
b757db426076 Preferences: added config option for the MicroPython serial communication timeout.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7079
diff changeset
67 Preferences.setMicroPython(
7099
89f11ae6bec3 Preferences: added an option to configure the REPL pane line wrap mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7086
diff changeset
68 "ReplLineWrap", self.replWrapCheckBox.isChecked())
7140
22f5fd76c10f MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7135
diff changeset
69 Preferences.setMicroPython(
22f5fd76c10f MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7135
diff changeset
70 "MpyCrossCompiler", self.mpyCrossPicker.text())
7079
d1564b590677 Preferences: added a configuration pyge for the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71
d1564b590677 Preferences: added a configuration pyge for the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72
d1564b590677 Preferences: added a configuration pyge for the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 def create(dlg):
d1564b590677 Preferences: added a configuration pyge for the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 """
d1564b590677 Preferences: added a configuration pyge for the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 Module function to create the configuration page.
d1564b590677 Preferences: added a configuration pyge for the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76
d1564b590677 Preferences: added a configuration pyge for the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 @param dlg reference to the configuration dialog
d1564b590677 Preferences: added a configuration pyge for the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 @return reference to the instantiated page (ConfigurationPageBase)
d1564b590677 Preferences: added a configuration pyge for the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 """
7140
22f5fd76c10f MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7135
diff changeset
80 return MicroPythonPage()

eric ide

mercurial