-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprogram_14_Tk_HelloWorld.py
More file actions
34 lines (28 loc) · 1.37 KB
/
program_14_Tk_HelloWorld.py
File metadata and controls
34 lines (28 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#----------------------------------------------------------
# These websites are a good reference for Tk
# http://www.tkdocs.com/tutorial/index.html
# http://www.pythonware.com/library/tkinter/introduction/
#----------------------------------------------------------
#----------------------------------------------------------
# This program is a simple GUI (Graphical User Interface)
# using the tkinter module from Python
#----------------------------------------------------------
# import the tkinter module and label it as 'tk'
import tkinter as tk
# To initialize tkinter, we have to create a Tk root widget.
# This is the main window, with a title bar and other
# decoration provided by your window manager. You should only
# create one root widget for each program, and it must be
# created before any other widgets.
root = tk.Tk()
# Create a Label widget as a child to the root window.
# A Label widget can display either text or an icon or other image.
# We use the text option to specify which text to display.
labelWidget = tk.Label( root, text = "Hello, world!" )
# Next, we call the pack method on this widget.
# pack() is a 'geometry manager' which controls the placement
# and size of the widgets. It also controls how the widget
# resizes itself to hold the text, or when the main window is resized.
labelWidget.pack()
# The tkinter event loop runs the program
root.mainloop()