Skip to content

Settings --> Dictionaries #6

@demisjohn

Description

@demisjohn

Use ordered dictionaries for the settings? Might make very large lists of settings easier to set up.

Example:
Microscope_Calibrations_user_settings.py:

from Collections import OrderedDict as oDict

Cals = oDict( )    # initialize the dictionary
Cals['FluoroScope 5x'] = 100.0
Cals['FluoroScope 20x'] = 25.0
Cals['FluoroScope 100x'] = 5.0
Cals['Nikon DSLR 5x'] = 120.0
Cals['Nikon DSLR 10x'] = 101.0
Cals['Nikon DSLR 50x'] = 76.0

Units = oDict( )    # initialize the dictionary
Units['FluoroScope 5x'] = 'um'
Units['FluoroScope 20x'] = 'um'
Units['FluoroScope 100x'] = 'um'
Units['Nikon DSLR 5x'] = 'um'
Units['Nikon DSLR 10x'] = 'um'
Units['Nikon DSLR 50x'] = 'um'

# Settings for "Draw-Measurement - Line":
LineWidth_Default = 10.0
FontSize_Default = 10.0

LineWidth = oDict( )    # initialize the dictionary
LineWidth['FluoroScope 5x'] = 7.0
LineWidth['FluoroScope 20x'] = 7.0
LineWidth['FluoroScope 100x'] = 7.0
# any items that don't have a value will use the default values.  This way a particular microscope can have custom annotation sizes etc.

Is this more user-friendly that the current method of using Lists? It does add the ability to override defaults only for a select few settings, but does increase the chance of Typo's (in the oDict key name).

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions