Howdy, Stranger!

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

Supported by

[solved] Python inline script: Widgets in form overlapping

edited April 2014 in OpenSesame

Hello,

I recently updated Open Sesame to the newest version 2.8.1. Unfortunately, I now always get an error message in a python inline script stating me that one or more widgets in my form are overlapping. However, I cannot find the overlap. Is there an option to see which widgets are overlapping and causing the error message to occur?

Or maybe, I am too blind to find the overlap:

form_pdg_test.set_widget(choice_heading, (0,10), colspan=100,rowspan=8)
form_pdg_test.set_widget(choice_question, (50,28), colspan=10,rowspan=7)
form_pdg_test.set_widget(checkbox_c, (43,36),colspan=16,rowspan=4)
form_pdg_test.set_widget(checkbox_d, (57,36),colspan=16,rowspan=4)

form_pdg_test.set_widget(o_choice, (17,44), colspan=15, rowspan=4)
form_pdg_test.set_widget(o_coop, (32,41), colspan=10, rowspan=4)
form_pdg_test.set_widget(o_defect, (32,48), colspan=10, rowspan=4)

form_pdg_test.set_widget(s_reward, (42,41), colspan=10, rowspan=2)
form_pdg_test.set_widget(o_reward, (46,43), colspan=10, rowspan=2)

form_pdg_test.set_widget(s_sucker, (42,48), colspan=10, rowspan=2)
form_pdg_test.set_widget(o_temptation, (46,50), colspan=10, rowspan=2)

form_pdg_test.set_widget(s_temptation, (56,41), colspan=10, rowspan=2)
form_pdg_test.set_widget(o_sucker, (60,43), colspan=10, rowspan=2)

form_pdg_test.set_widget(s_punish, (56,48), colspan=10, rowspan=2)
form_pdg_test.set_widget(o_punish, (60,50), colspan=10, rowspan=2)

form_pdg_test.set_widget(finished_button_mc, (45,60),colspan=10,rowspan=5)

Thank you in advance for your help!

Best regards,
Isabel

Comments

  • edited 1:41AM

    Hi Isabel,

    It's a bit difficult to spot by eye (you have so many columns and rows!), but you could debug this fairly easily by inserting a print statement after every set_widget(), like so:

    form_pdg_test.set_widget(choice_heading, (0,10), colspan=100,rowspan=8)
    print 1
    form_pdg_test.set_widget(choice_question, (50,28), colspan=10,rowspan=7)
    print 2
    form_pdg_test.set_widget(checkbox_c, (43,36),colspan=16,rowspan=4)
    print 3
    # (...) etc
    

    Then you can see in the debug window what the last printed digit is, and you know that the next widget is the problem.

    Cheers!
    Sebastiaan

  • edited 1:41AM

    Hi Sebastian,

    Thank you very much for your quick response. I tried the solution you recommended, but still I can't fix the problem. All the numbers that I define in the print statements after each set_widget (in the prepare phase) are indeed printed in the debug window. However, there seems to be a problem with a widget (a warning message) that I call in the run phase of the inline script. But even when I delete this widget, the error message still occurs.
    Do you have another idea for me on how to fix the problem. And by the way: sorry for the mess in my code and the huge number of cells ;)!

    Cheers,
    Isabel

  • edited 1:41AM

    Hi Isabel,

    Right, I forgot that the geometry is only validated when you execute the form, so you wouldn't get this error after set_widget(). That's inconvenient. Could you post the full script, i.e. including the bits where you create the widgets and execute the form?

    Cheers,
    Sebastiaan

  • edited April 2014

    Hi Sebastian,

    Of course, please find the full script below.
    Thanks again for your help!

    Cheers,
    Isabel

    # Import the widgets library
    from libopensesame import widgets
    
    # Create the form
    form_pdg_test = widgets.form(self.experiment, cols=100, rows=76, margins=(0,0,0,0), spacing=0)
    
    # Create widgets
    choice_heading = widgets.label(form_pdg_test, text='<b><span size="20">Testdurchgang</span></b><br><br>Sie haben folgende Tabelle ausgewählt. Die Frage ist nun:<br><br><b>Welche Option wählen Sie?',center=True)
    choice_question = widgets.label(form_pdg_test, text='<span color="blue">Ich</span> wähle</b>',center=True)
    checkbox_c = widgets.checkbox(form_pdg_test, text='Option A',group="choice_test",var="choice_test")
    checkbox_d = widgets.checkbox(form_pdg_test, text='Option B',group="choice_test",var="choice_test")
    
    o_choice = widgets.label(form_pdg_test, text='<span color=#009900>Spieler 2</span> wählt')
    o_coop = widgets.label(form_pdg_test, text='Option A')
    o_defect = widgets.label(form_pdg_test, text='Option B')
    
    s_reward = widgets.label(form_pdg_test, text='<span color="blue">[PDG_R_test]</span>')
    s_temptation = widgets.label(form_pdg_test, text='<span color="blue">[PDG_T_test]</span>')
    s_sucker = widgets.label(form_pdg_test, text='<span color="blue">[PDG_S_test]</span>')
    s_punish = widgets.label(form_pdg_test, text='<span color="blue">[PDG_P_test]</span>')
    o_reward = widgets.label(form_pdg_test, text='<span color=#009900>[PDG_R0_test]+/-?</span>')
    o_temptation = widgets.label(form_pdg_test, text='<span color=#009900>[PDG_T0_test]+/-?</span>')
    o_sucker = widgets.label(form_pdg_test, text='<span color=#009900>[PDG_S0_test]+/-?</span>')
    o_punish = widgets.label(form_pdg_test, text='<span color=#009900>[PDG_P0_test]+/-?</span>')
    
    finished_button_mc= widgets.button(form_pdg_test, text="Weiter")
    
    # Add the widgets to the form.
    form_pdg_test.set_widget(choice_heading, (0,10), colspan=100,rowspan=8)
    form_pdg_test.set_widget(choice_question, (50,28), colspan=10,rowspan=7)
    form_pdg_test.set_widget(checkbox_c, (43,36),colspan=16,rowspan=4)
    form_pdg_test.set_widget(checkbox_d, (57,36),colspan=16,rowspan=4)
    form_pdg_test.set_widget(o_choice, (17,44), colspan=15, rowspan=4)
    form_pdg_test.set_widget(o_coop, (32,41), colspan=10, rowspan=4)
    form_pdg_test.set_widget(o_defect, (32,48), colspan=10, rowspan=4)
    form_pdg_test.set_widget(s_reward, (42,41), colspan=10, rowspan=2)
    form_pdg_test.set_widget(o_reward, (46,43), colspan=10, rowspan=2)
    form_pdg_test.set_widget(s_sucker, (42,48), colspan=10, rowspan=2)
    form_pdg_test.set_widget(o_temptation, (46,50), colspan=10, rowspan=2)
    form_pdg_test.set_widget(s_temptation, (56,41), colspan=10, rowspan=2)
    form_pdg_test.set_widget(o_sucker, (60,43), colspan=10, rowspan=2)
    form_pdg_test.set_widget(s_punish, (56,48), colspan=10, rowspan=2)
    form_pdg_test.set_widget(o_punish, (60,50), colspan=10, rowspan=2)
    form_pdg_test.set_widget(finished_button_mc, (45,60),colspan=10,rowspan=5)
    
    #define variables to implement warning message
    input_correct=False
    warning_text=""
    
    
    while input_correct==False:
        #execute form and wait for response
        button_clicked = form_pdg_test._exec()
    
        # get choice response
        choice_test = self.get("choice_test")
    
        #check if number is in correct range:
        if choice_test != "no":
            # if this is the case, set input_correct to True to exit the while loop
            input_correct=True
    
        # if this is not the case, specify appropriate warning text
        else: 
            warning_text="Bitte entscheiden Sie sich für Option A oder Option B."
    
  • edited 1:41AM

    Ok, it's these two:

    form_pdg_test.set_widget(checkbox_c, (43,36),colspan=16,rowspan=4)
    form_pdg_test.set_widget(checkbox_d, (57,36),colspan=16,rowspan=4)
    

    43 + 16 > 57, and therefore the two widgets overlap. Reducing the colspan for checkbox_c to 14 will do the trick. (However, aesthetically, I feel that there is more room for improvement!)

  • edited 1:41AM

    Dear Sebastian,

    Thank you very much for your help! That was a typical example of blindness...sorry!
    And, of course, you're right. Aesthetically, it can (and will) be further improved.

    Best regards,
    Isabel

Sign In or Register to comment.