Skip to content

Enum Widget Support #109

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Enum Widget Support #109

wants to merge 4 commits into from

Conversation

dihm
Copy link
Contributor

@dihm dihm commented Apr 22, 2025

This PR adds basic Enum widget support to BLACS tabs. EnumOutputs are intended to be used for controls that only allow discrete values (ie an Enum-like control). Very basic support for EnumWidgets was added in labscript_utils v3.0.0b1. This PR uses those base widgets to add support for them within a device tab.

Example of EO widgets (from output_classes.py test script)
image

Incantation within a DeviceTab will look like

eo_prop = {
    'Enum1':{
        'options':['option 1', 'option 2'], # uses default 0-indexing
        'return_index':True, # widget will return integer index instead of string value when queried
    },
    'Enum2':{
        'options':{
            'option 1':{'index':2, 'tooltip':'description 1'},
            'option 2':4, # if tooltip not desired, just pass custom index
        }
    }
}
self.create_enum_outputs(eo_prop)
eo_widgets = self.auto_create_enum_widgets()

self.auto_place_widgets(('Enums', eo_widgets))

I've also updated the test script within device_base_class.py to run and show the new functionality.

image

It relies on a pre-compiled dummy connection table, which I've placed in a top level tests directory assuming we will eventually get to the point of implementing more rigorous testing.

dihm added 4 commits April 22, 2025 13:46
Does not attempt to add `EO` handling to the `auto_create_widgets` and
`auto_place_widgets` functions to better maintain backwards compatibility.
Also adds a `auto_create_enum_widgets` that mirrors `auto_create_widgets`
functionality, but just for enums (ie preserves backwards compat, enforces opt-in).
Creates a top-level `tests` directory which houses the dummy connectiontable object
necessary to run the test.
@dihm dihm added the enhancement New feature or request label Apr 22, 2025
@Json-To-String
Copy link
Contributor

I can confirm that this works pretty nicely in a few new devices just copying and pasting the snippet for the DeviceTab above, and also that the enum widgets process their updates nicely to the values handled by the Worker. The test works fine too.

What I can't quite replicate is why the docs build seems to have timed out - I can build them locally with seemingly little issue. I'll keep looking into that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants