Skip to content
Advertisement

Issue with folder path in tkinter (python)

I am having an issue of finding the bug in my code in relation to the folder path using filedialog. I have the following code

JavaScript

The following error shows up:

JavaScript

Advertisement

Answer

To use

JavaScript

you have to first create

JavaScript

global doesn’t create variable but it is only used in function to inform this function to use external/global variable when you use = to assign value (instead of creating local variable).

The same problem you will have with user_input.

So you could create variables at start

JavaScript

and it resolves problem with these variables


EDIT: I found that you use folder_path = StringVar() in create_widgets_in_first_frame but it create local variable. You have to uses global to inform function to assign StringVar() to external/glboal variable

JavaScript

and then it will create global folder_path and you don’t have to create it at start.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement