1. Technology

"Hello, World!" in Python With Tkinter

By

10 of 10

Calling main()

As usual, the main() function is the brains of the program. But it is worthless unless it is called. Here we call the main() function when the application is invoked directly:

 if __name__ == "__main__": 
      main() 

By using this way of coding the program, the window is only created when the program is called directly. If, however, another Python program imports the file as a module, the program does not execute but stays secondary to the invoking application's processes. For more on __name__ and calling main(), see "What's in a Name?"

  1. About.com
  2. Technology
  3. Python
  4. Advanced Python
  5. Python Graphic Interface - Tkinter - Programming Tkinter - Python GUI Programming - Calling main()

©2014 About.com. All rights reserved.