Skip to content

Just need help #2

@dkruben

Description

@dkruben

How to use SimpleConfBlockInterface?

i try this:

def init(self):
    self.ID = 'Test_01'
    self.version = '1.0.0 (%(file_compile_date)s)'
    self.author = 'Maintenance by: _DKRuben_EU'
    self.data = {
        'block1': {
            'enabled': True,
            'scale': 1.0,
            'displayMode': 'detailed',
        },
        'block2': {
            'enabled': True,
            'verticalPosition': 0.8,
            'firstDisplayTime': 5.0,
            'consecutiveDisplayTime': 3.0
        }
    }
    self.i18n = {
        'UI_description': self.ID,
        # Block 1 settings
        'UI_setting_scale_text': 'Scale',
        'UI_setting_scale_tooltip': '',
        'UI_setting_displayMode_text': 'Display Mode',
        'UI_setting_displayMode_tooltip': '',
        # Block 2 settings
        'UI_setting_verticalPosition_text': 'Vertical Position',
        'UI_setting_verticalPosition_tooltip': '',
        'UI_setting_firstDisplayTime_text': 'First Display Time',
        'UI_setting_firstDisplayTime_tooltip': '',
        'UI_setting_consecutiveDisplayTime_text': 'Consecutive Display Time',
        'UI_setting_consecutiveDisplayTime_tooltip': ''
    }
    super(ConfigInterface, self).init()

def createTemplate(self, blockID=None):
    if blockID == 'block1':
        return {
            'modDisplayName': self.i18n['UI_description'],
            'enabled': self.data[blockID]['enabled'],
            'column1': [
                # self.tb.createSlider('scale', 0.5, 2.0, 0.1, '{{value}}')
            ],
            'column2': [
                # self.tb.createOptions('displayMode', ['detailed', 'compact']),
            ]
        }
    elif blockID == 'block2':
        return {
            'modDisplayName': self.i18n['UI_description'],
            'enabled': self.data[blockID]['enabled'],
            'column1': [
                # self.tb.createSlider('verticalPosition', 0.0, 1.0, 0.1, '{{value}}'),
                # self.tb.createSlider('firstDisplayTime', 0.0, 10.0, 0.1, '{{value}}'),
                # self.tb.createSlider('consecutiveDisplayTime', 0.0, 10.0, 0.1, '{{value}}')
            ],
            'column2': []
        }

def onApplySettings(self, settings, blockID=None):
    super(ConfigInterface, self).onApplySettings(settings)
    if blockID in self.data:
        self.data[blockID]['enabled'] = settings.get('enabled', self.data[blockID]['enabled'])
        if blockID == 'block1':
            self.data[blockID]['scale'] = settings.get('scale', self.data[blockID]['scale'])
            self.data[blockID]['displayMode'] = settings.get('displayMode', self.data[blockID]['displayMode'])
        elif blockID == 'block2':
            self.data[blockID]['verticalPosition'] = settings.get('verticalPosition', self.data[blockID]['verticalPosition'])
            self.data[blockID]['firstDisplayTime'] = settings.get('firstDisplayTime', self.data[blockID]['firstDisplayTime'])
            self.data[blockID]['consecutiveDisplayTime'] = settings.get('consecutiveDisplayTime', self.data[blockID]['consecutiveDisplayTime'])

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions