You don't show how you call your functions, but I assume you call
You declare
So, why do you create
Ideally you should refactor your spaghetti code and not use globals at all. As you see it's terrible to debug problem in such code.
The other "solution" is to initialize
As a side note - you use GUI, but print result in stdout??? Not to mention mixing pyautogui and tkinter???
search_book()
in order to display the GUI.You declare
cur
as global but actually it does not exists in the global scope. Once it complete the execution of the search_book
, there are no references to cur
and it is destroyed.So, why do you create
cur
in search_book
in the first place. Why not create it in submit()
where it is actually needed and used.Ideally you should refactor your spaghetti code and not use globals at all. As you see it's terrible to debug problem in such code.
The other "solution" is to initialize
cur
in the global namespace, e.g. cur = None
at the top, after the imports.As a side note - you use GUI, but print result in stdout??? Not to mention mixing pyautogui and tkinter???
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs