Python Forum
tkinter -- after() method and return from function -- (python 3)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
tkinter -- after() method and return from function -- (python 3)
#6
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.
Reply


Messages In This Thread
RE: tkinter -- after() method and return from function -- (python 3) - by deanhystad - Feb-20-2021, 06:21 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Using Tkinter inside function not working Ensaimadeta 5 5,089 Dec-03-2023, 01:50 PM
Last Post: deanhystad
  TKinter Widget Attribute and Method Quick Reference zunebuggy 3 870 Oct-15-2023, 05:49 PM
Last Post: zunebuggy
  Tkinter won't run my simple function AthertonH 6 3,911 May-03-2022, 02:33 PM
Last Post: deanhystad
  [Tkinter] tkinter best way to pass parameters to a function Pedroski55 3 4,901 Nov-17-2021, 03:21 AM
Last Post: deanhystad
  Creating a function interrupt button tkinter AnotherSam 2 5,575 Oct-07-2021, 02:56 PM
Last Post: AnotherSam
  [Tkinter] Have tkinter button toggle on and off a continuously running function AnotherSam 5 5,052 Oct-01-2021, 05:00 PM
Last Post: Yoriz
  return a variable from a function snakes 3 2,821 Apr-09-2021, 06:47 PM
Last Post: snakes
  tkinter get function finndude 2 2,979 Mar-02-2021, 03:53 PM
Last Post: finndude
  function in new window (tkinter) Dale22 7 5,196 Nov-24-2020, 11:28 PM
Last Post: Dale22
Star [Tkinter] How to perform math function in different page of Tkinter GUI ravaru 2 4,612 Oct-23-2020, 05:46 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020