Attributeerror: 'Function' Object has no attribute 'values'

Asked

Viewed 65 times

0

Hello I am creating a program to create projects only when starting the program to see if started the window, where asks the path and the name of the project I came across this error

Traceback (Most recent call last): File "F: Projects Project Creator main.py", line 24, in main(main values) Attributeerror: 'Function' Object has no attribute 'values'

I don’t know what to do!

Here’s my file code main py.

import PySimpleGUI as sg
import criar_pasta

def main(values):
    layout = [
        [sg.Text("Insira o nome do projeto")], [sg.Input(key="nome_do_projeto")],
        [sg.Text("Insira a path do projeto")], [sg.Input(key="path")],
        [sg.Button("Criar ficheiro de programação")], [sg.Button("Cancelar")]
    ]
    window = sg.Window("Project creator", layout=layout)
    while True:
        event, values = window.read()
        if event == sg.WIN_CLOSED:
            break
        if event == "Cancelar":
            break
        if event == "Criar ficheiro de programação":
            criar_pasta.criar_pasta()

    window.close()

if __name__ == '__main__':
    main(values)```
  • The oblema is in: if __name__ == '__main__': main(values). You did not initialize values

  • I didn’t realize, is that I don’t understand very well about modules... The problem is in the if __name__ == "__main__": main(values)?

1 answer

0


The variable values is not initialized before the call to main(...) on line 23.

Is this exactly the code you are running? The error message is on line 24, but this code goes to line 23 (if I counted correctly).

The error is compatible with trying to write main.values, trying to access an attribute in a function.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.