Feb-20-2021, 06:21 AM
(This post was last modified: Feb-20-2021, 06:21 AM by deanhystad.)
GUI programs are usually event driven. The user does something and you execute code to process what the user did. If you want a login screen you would have a button or a menu that pops up the login screen. It doesn't wait for a password. It doesn't care if you ever type anything into the dialog or close it. The code that pops open the login screen has done it's job, and that event handler is done.
The user types in their username and password. Maybe pressing the enter key is the accept event, or maybe the dialog has a button. Either way the user does something that indicates it is time to check the username and password. If the username and password are correct, the program executes some code associated with logging in (at the least closing the login window, probably putting the username in a status bar to show who is logged in). If the password or username is incorrect the program executes some code that is associated with a failed login (maybe drawing an error message, making a sound, probably closing the login window).
There is never any waiting in a GUI application. If you think you need to wait it usually means you are thinking about the problem the wrong way. Your program will spend most of it's time doing nothing. Doing nothing sounds like waiting, but there is one critical difference. An idle GUI program is always ready to respond to user events. A waiting program is unresponsive to user events.
To answer your question, "What about return values and use them (for example) in my other file (GUI-main.py) as you can see my last post?" There are no return values and GUI-main does now wait for Password() to complete. If the user enters the correct password, Password() will execute the login code that you probably, incorrectly, have in your GUI-main.py module.
The user types in their username and password. Maybe pressing the enter key is the accept event, or maybe the dialog has a button. Either way the user does something that indicates it is time to check the username and password. If the username and password are correct, the program executes some code associated with logging in (at the least closing the login window, probably putting the username in a status bar to show who is logged in). If the password or username is incorrect the program executes some code that is associated with a failed login (maybe drawing an error message, making a sound, probably closing the login window).
There is never any waiting in a GUI application. If you think you need to wait it usually means you are thinking about the problem the wrong way. Your program will spend most of it's time doing nothing. Doing nothing sounds like waiting, but there is one critical difference. An idle GUI program is always ready to respond to user events. A waiting program is unresponsive to user events.
To answer your question, "What about return values and use them (for example) in my other file (GUI-main.py) as you can see my last post?" There are no return values and GUI-main does now wait for Password() to complete. If the user enters the correct password, Password() will execute the login code that you probably, incorrectly, have in your GUI-main.py module.