Howdy, Stranger!

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

Supported by

AttributeError: 'Window' object has no attribute '_closed'

The experiment can run, but these errors and warnings have occurred, which may delay the process. How do I fix this? Help~

Comments

  • Hi @Ornella ,

    This seems like a bug in PsychoPy, and I suspect you're using an older version of OpenSesame (bundled with an older version of PsychoPy). Is that correct? If so, then I would update to the latest version of OpenSesame.

    Also, I don't think the error itself is necessarily a problem, because I suspect it occurs at the very end when the experiment closes, right?

    — Sebastiaan

  • Hi @sebastiaan,

    I have updated the version of OpenSesame. It works! Thank you very much!☺️😀

  • Hi, I am getting the same error, but with opensesame 4.0.32 and psychopy 2024.2.5.

    fyi I am trying to run an experiment where for speed reasons the canvases are drawn and stored in advance, and I get this error for every single canvas drawn, i.e. thousands of times per trial, so it kills the functionality of the experiment.

  • @jevrihanna Can you post the code that you use to create the canvases and the exact error message that you get?

  • edited February 21

    Hi @sebastiaan, the code is as follows. First a template canvas is created:

    # setup canvas and stimuli
    canvas = Canvas(color="gray")
    fix_pos = (0, ang2pix(7))
    fix_symb = "F" if follow else "S"
    canvas["fix"] = Text(fix_symb, x=fix_pos[0], y=fix_pos[1], color="black", font_size=72, font_bold=True)
    circle_kwargs = {"color":"black", "penwidth":14}
    
    # need to get the image size
    canvas["image"] = Image(pool[filename])
    image_size = canvas["image"].size
    circle_size = max(image_size)/2
    circle_size -= int(round(circle_size * circle_reduction))
    del canvas["image"]
    canvas["circle"] = Circle(0, 0, circle_size, **circle_kwargs)
    canvas["fix_circle"] = Circle(0, 0, circle_size, **circle_kwargs)
    
    # instructions
    instr_str = follow_str if follow else fix_str
    if practice:
        canvas["instructions"] = Text(f"{instr_str}\n\nFirst, keep your focus on the {fix_symb} below.", y=-ang2pix(6), color="black", font_size=48)
    
    # get basic parameters calculated
    img_width = image_size[0]
    left_point = -1 * (width // 2) - img_width // 2 - circle_kwargs["penwidth"]
    right_point = (width // 2) + img_width // 2 + circle_kwargs["penwidth"]
    sleep_time = 1#1000 / mon_refresh - 5
    
    # get the x coordinates 
    cur_x = 0.
    x_frames = []
    
    # left to centre
    while cur_x > left_point:
        x_frames.append(cur_x)
        cur_x -= pix_per_frame
    # flip the order to make it left to centre
    x_frames = x_frames[::-1]
    # centre to right 
    cur_x = 0.
    while cur_x < right_point:
        cur_x += pix_per_frame
        x_frames.append(cur_x)
    # flip if right to left
    if not left:
        x_frames = x_frames[::-1]
    canvas["circle"].x = x_frames[0]
    
    # block/trial info
    cur_trial += 1
    cur_block = (cur_trial // block_size) + 1
    print(f"{cur_trial} {cur_block}")
    

    Then we wait for eyetracker fixation:

    canvas.show()
    # wait for eyes to fixate for a certain period of time, and recalibrate if necessary
    if not wait_for_gaze(fix_pos, 2500, tolerance=32, gaze_timeout=10000):
        send_triggers(3,'Recalibration start')
        eyetracker.calibrate()
        eyetracker.start_recording()
        send_triggers(4,'Recalibration end')
        items.run(u"fixate")
        
    if practice:
        del canvas["instructions"]
    # replace instructional symbol with +
    del canvas["fix"]
    canvas["fix"] = Text("+", x=fix_pos[0], y=fix_pos[1], color="black", font_size=48, font_bold=True)
    canvas.show()
    # jittered delay
    clock.sleep(random.randint(jitt_low, jitt_high))
    

    Then the canvas is iteratively copied with small translational changes to one object

    start_time = clock.time()
    canvases = []
    ## move the stimuli across the screen
    revealed= False
    ur_canvas = canvas
    for x_idx, x_f in enumerate(x_frames):
        this_canvas = Canvas()
        this_canvas.copy(ur_canvas)
        if x_f == 0.: # centre
            revealed = True
            zero_idx = x_idx
            # this if-else makes the moving image overlap the still image during SP,
            # and reversed if fixation
            if follow:
                this_canvas["fix_stimulus"] = Image(pool[filename])
                this_canvas["stimulus"] = Image(pool[filename])
            else:
                this_canvas["stimulus"] = Image(pool[filename])
                this_canvas["fix_stimulus"] = Image(pool[filename])
        if revealed:
            this_canvas["stimulus"].x = x_f
        this_canvas["circle"].x = x_f
        canvases.append(this_canvas)
        ur_canvas = this_canvas
    stop_time = clock.time()
    print(stop_time-start_time)
    
    
    

    This error message is repeated 100s of times:

    AttributeError: 'Window' object has no attribute '_closed'Exception ignored in: <function Window.__del__ at 0x7f727ebed040>
    
    Traceback (most recent call last):
    
     File "/home/stimulus/miniconda3/envs/2025SP1/lib/python3.9/site-packages/psychopy/visual/window.py", line 664, in __del__
    
       if self._closed is False:
    


Sign In or Register to comment.