Skip to content
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

Use chosen plugin for script UI values #135

Merged
merged 1 commit into from
Feb 24, 2020

Conversation

will-moore
Copy link
Member

@will-moore will-moore commented Feb 21, 2020

Ported from ome/openmicroscopy#6099

See https://forum.image.sc/t/file-browser-in-omero-script-gui/28117/16

To test:

  • Use the sample script below to generate a lot of directories to choose from in the script UI (based on use-case and code in the image.sc link above)
  • This generates > 2000 items to show in a list in the script UI
  • Without this PR, this is one select box and difficult to choose one (see screenshot)
  • With this PR you can search by typing (2nd screenshot)
  • Run the script - the chosen item appears in the output message

Screenshot 2020-02-21 at 15 26 25

Screenshot 2020-02-21 at 15 29 03

import omero.scripts as scripts
from omero.rtypes import rstring
import os

dir_list = []
for d in os.listdir('/'):
    dir_list.append(d)
    try:
        for f in os.listdir('/' + d):
            dir_list.append("%s/%s" % (d, f))
    except PermissionError:
        print(d, 'PermissionError')
    except NotADirectoryError:
        print(d, 'NotADirectoryError')

dirs = [rstring(d) for d in dir_list]
print(len(dirs))

client = scripts.client(
    'Test_Big_List.py',
    """Test listing lots of dirs""",
    scripts.String("Directories", values = dirs),
)

try:
    script_params = client.getInputs(unwrap=True)
    client.setOutput("Message", rstring(script_params['Directories']))

finally:
    client.closeSession()

@jburel
Copy link
Member

jburel commented Feb 24, 2020

Uploaded the script to merge-ci
It is possible to select a folder and filter by typing

@jburel jburel merged commit e18f767 into ome:master Feb 24, 2020
@will-moore will-moore deleted the chosen_for_script_ui branch February 26, 2020 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants