-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathletterCounter.py
49 lines (42 loc) · 1.56 KB
/
letterCounter.py
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
41
42
43
44
45
46
47
48
49
# simple letter counter
import tkinter as tk
frameWindow = tk()
frameWindow.geometry("400x260+50+50")
frameWindow.title("simple letter counter")
message1 = tk.StringVar()
letter1 = tk.StringVar()
def printMessage():
message = message1.get()
letter = letter1.get()
message = message.lower()
letter = letter.lower()
letterCount = message.count(letter)
a = "your message have : " + str(letterCount) + " " + letter + "'s in it."
labelFrameWindow = tk.Label(
frameWindow, text=a, font=("arial", 15), fg="black"
).place(x=10, y=10)
labelTextField = tk.Label(
frameWindow,
text="Enter the letter you want to count",
font=("ubuntu", 15),
fg="black",
).place(x=10, y=80)
textField1 = tk.Entry(
frameWindow, font=("arial", 15), textVariable=message1, bg="white", fg="black"
).place(x=10, y=40, height=40, width=340)
textField2 = tk.Entry(
frameWindow, font=("arial", 15), textVariable=letter1, bg="white", fg="black"
).place(x=10, y=120, height=40, width=340)
buttonCount = tk.Button(
frameWindow,
text="Check letter",
command=printMessage,
cursor="hand2",
font=("Times new roman", 30),
fg="white",
bg="black",
).place(x=10, y=170, height=40, width=380)
# print("In this app, I will count the number of times that a specific letter occurs in a message.")
# message = input("\nPlease enter a message: ")
# letter = input("Which letter would you like to count the occurrences of?: ")
frameWindow.mainloop()