-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_tkinter_5.py
More file actions
40 lines (28 loc) · 881 Bytes
/
test_tkinter_5.py
File metadata and controls
40 lines (28 loc) · 881 Bytes
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
35
36
37
38
39
40
from tkinter import *
from tkinter.ttk import *
def displayText():
""" Display the Entry text value. """
global entryWidget
if entryWidget.get().strip() == "":
print("None")
else:
print(entryWidget.get().strip())
if __name__ == "__main__":
root = Tk()
root.title("Tkinter Entry Widget")
root["padx"] = 40
root["pady"] = 20
# Create a text frame to hold the text Label and the Entry widget
textFrame = Frame(root)
#Create a Label in textFrame
entryLabel = Label(textFrame)
entryLabel["text"] = "Enter the text:"
entryLabel.pack(side=LEFT)
# Create an Entry Widget in textFrame
entryWidget = Entry(textFrame)
entryWidget["width"] = 50
entryWidget.pack(side=LEFT)
textFrame.pack()
button = Button(root, text="Submit", command=displayText)
button.pack()
root.mainloop()