eric6/Preferences/ConfigurationPages/MicroPythonPage.py

Tue, 13 Aug 2019 16:28:43 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 13 Aug 2019 16:28:43 +0200
branch
micropython
changeset 7135
44fcfc99b864
parent 7134
21d23ca51680
child 7140
22f5fd76c10f
permissions
-rw-r--r--

MicroPython: added an option to synchronize the device time to the host time after connecting the serial port.

# -*- coding: utf-8 -*-

# Copyright (c) 2019 Detlev Offenbach <detlev@die-offenbachs.de>
#

"""
Module implementing the MicroPython configuration page.
"""

from __future__ import unicode_literals

from .ConfigurationPageBase import ConfigurationPageBase
from .Ui_MicroPythonPage import Ui_MicroPythonPage

import Preferences

from MicroPython.MicroPythonWidget import AnsiColorSchemes


class MicroPythonPage(ConfigurationPageBase, Ui_MicroPythonPage):
    """
    Class implementing the MicroPython configuration page.
    """
    def __init__(self, parent=None):
        """
        Constructor
        
        @param parent reference to the parent widget
        @type QWidget
        """
        super(MicroPythonPage, self).__init__()
        self.setupUi(self)
        self.setObjectName("MicroPythonPage")
        
        self.colorSchemeComboBox.addItems(sorted(AnsiColorSchemes.keys()))
        
        # set initial values
        self.timeoutSpinBox.setValue(
            Preferences.getMicroPython("SerialTimeout") / 1000)
        # converted to seconds
        self.syncTimeCheckBox.setChecked(
            Preferences.getMicroPython("SyncTimeAfterConnect"))
        self.colorSchemeComboBox.setCurrentIndex(
            self.colorSchemeComboBox.findText(
                Preferences.getMicroPython("ColorScheme")))
        self.replWrapCheckBox.setChecked(
            Preferences.getMicroPython("ReplLineWrap"))
    
    def save(self):
        """
        Public slot to save the MicroPython configuration.
        """
        Preferences.setMicroPython(
            "SerialTimeout", self.timeoutSpinBox.value() * 1000)
        # converted to milliseconds
        Preferences.setMicroPython(
            "SyncTimeAfterConnect", self.syncTimeCheckBox.isChecked())
        Preferences.setMicroPython(
            "ColorScheme", self.colorSchemeComboBox.currentText())
        Preferences.setMicroPython(
            "ReplLineWrap", self.replWrapCheckBox.isChecked())
    

def create(dlg):
    """
    Module function to create the configuration page.
    
    @param dlg reference to the configuration dialog
    @return reference to the instantiated page (ConfigurationPageBase)
    """
    page = MicroPythonPage()
    return page

eric ide

mercurial