Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

[open] Adjust number of displayed experiments on Android runtime

edited December 2015 in OpenSesame

Hi,

Just a short and practical question: Is there a way to display more than 8 experiments in the experiment menu? For example by creating two columns or a second page?

Comments

  • edited 8:33PM

    Hi,

    Not really, no. You could take a look at the menu 'experiment' though. This is the code that implements the startup menu on OpenSesame for Android, and it's just a normal OpenSesame experiment.

    If you feel so inclined, you could see if you can come up with a better design?

    Cheers,
    Sebastiaan

    There's much bigger issues in the world, I know. But I first have to take care of the world I know.
    cogsci.nl/smathot

  • edited 8:33PM

    Hi Sebastiaan,

    Here is my attempt at creating a second column, i reckon it isn't the most elegant but it does the trick:

    # Create a form to select the experiment
    max_file_list_size = 16
    form = widgets.form(exp, cols=[1,1], rows=[1]*(max_file_list_size/2)+[1], 
        margins=[32,32,32,32])
    
    i = 1
    j = 1
    path_dict = {}
    if len(experiments) == 0:
        label_notfound = widgets.label(form, text='No experiments found!' % src)
        form.set_widget(label_notfound, (0,0))
    else:
        label_title = widgets.label(form,
            text='Select experiment<br><span size=8>Showing up to %d files</span>' \
            % max_file_list_size)
        form.set_widget(label_title, (0,0), colspan=2)
        for path in experiments[0:(max_file_list_size/2)+1]:
    
            name = os.path.basename(path).split('.')[0].replace('_', ' ').capitalize()
            text = '%s<br /><span size=16>%s</span>' % (name, path)
            path_dict[text] = path
            button_exp = widgets.button(form, text=text)
            form.set_widget(button_exp, (0,i))
            i+= 1
            if i == (max_file_list_size/2)+1:
                break
        for path in experiments[(max_file_list_size/2):max_file_list_size+1]:
    
            name = os.path.basename(path).split('.')[0].replace('_', ' ').capitalize()
            text = '%s<br /><span size=16>%s</span>' % (name, path)
            path_dict[text] = path
            button_exp = widgets.button(form, text=text)
            form.set_widget(button_exp, (1,j))
            j+= 1   
            if j == (max_file_list_size/2)+1:
                break
    
    exp._experiment = path_dict[form._exec()]
    

    Basically, it creates buttons for the first half of the list until it breaks and continues on the second column with the second half of the experiments list. The amount of experiments is now doubled to 16 but in the unlikely scenario of needing more than that amount (let's hope this will never happen :) ) the font size should be adjusted too.

    Alternatively, i could stick to one column and reserve the final row for a 'next page' button which leads to an identical form that loops through the second half of the experiments list. Let me know what you think.

    Laurent

  • edited December 2015

    I've also added another piece that passes the chosen experiment into the logfile path. Might be handy when you have multiple experiments running and want the logfile into the corresponding folder of that experiment, instead of manually switching between folders. I couldn't find a variable for the chosen experiment so it strips the path of the experiment until only the title remains:

    # Detect and strip experiment file path         
    exp._experiment = path_dict[form._exec()]
    experiment = str(exp._experiment)
    experiment = experiment.split('.')[0]
    
    if '\\' in experiment:
        experiment = experiment.split('\\')[-1]
    
    if '/' in experiment:
        experiment = experiment.split('/')[-1]
    

    And later on in the select logfile form:

    text_input_logfile = widgets.text_input(form,
        text=os.path.join(logfile_folder, experiment, 'subject-%d.csv' % exp._subject_nr),
        var='_logfile', return_accepts=True)
    

    Again, probably not the prettiest but it works on my end :)

    Cheers,

    Laurent

Sign In or Register to comment.