#!/usr/bin/python import Tkinter top = Tkinter.Tk() # Code to add widgets will go here... top.mainloop()
Here is what the above code is Doing:
1. It creates a Tkinter object called top.
2. It then creates a mainloop.
3. It then adds a widget to the top object.
4. It then runs the mainloop.
The mainloop is what makes the GUI keep running.
The widget is a button.
The button has a command associated with it.
The command is a function that prints “Hello, World!”.
When you click on the button, the function is called and “Hello, World!” is printed to the console.
Now, let’s add a few more widgets to the GUI.
We’ll add a label and an entry widget.
The label will be used to display text and the entry widget will be used to get input from the user.
Here’s the code: