[Python] AttributeError: module 'PySimpleGUI' has no attribute 'Window'

Discussão em 'Python' iniciado por Stack, Julho 28, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to get up and running with PySimpleGUI. I tried running the following code (from https://pysimplegui.readthedocs.io/en/latest/#the-quick-tour):

    import PySimpleGUI as sg
    event, values = sg.Window('Get filename example', [[sg.Text('Filename')], [sg.Input(), sg.FileBrowse()], [sg.OK(), sg.Cancel()] ]).Read()


    This is on a Windows 7 box, with Python 3.7.1, and PySimpleGUI version 4.18.0.

    BTW, those two lines should work from a python command line, I think. But, even if I save them as a file (with no other python lines, just newlines and comments), I get

    (Traceback (most recent call last):
    File "C:\Users\blorfmorlfle\bin\MoveStagedFiles.py", line 15, in <module>
    event, values = sg.Window('Get filename example', [[sg.Text('Filename')], [sg.Input(), sg.FileBrowse()], [sg.OK(), sg.Cancel()] ]).Read()
    AttributeError: module 'PySimpleGUI' has no attribute 'Window'


    Searching stack overflow for similar errors, all the results threads were different.

    FWIW, I have uninstalled and reinstalled PySimpleGUI.

    FWIW2, the following works fine.

    sg.Popup('Hello From PySimpleGUI!', 'This is the shortest GUI program ever!')


    Any thoughts? I have heard some python releases are problematic for PySimpleGUI because of tkinter issues. Is there a recommended release?

    Continue reading...

Compartilhe esta Página