Skip to content

Commit ad2cae6

Browse files
committed
Add Project
1 parent ede51b2 commit ad2cae6

8 files changed

+187
-1
lines changed

DisplayImageAndReadTextFromFile.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
from tkinter import *
2+
from PIL import Image, ImageTk
3+
import time
4+
5+
root=Tk()
6+
root.wm_title("TEXTS")
7+
root.config(background = "#FFFFFF")
8+
root.geometry("1400x600")
9+
10+
leftFrame=Frame(root, width=900, height = 600, background="Yellow")
11+
leftFrame.grid(row=0, column=0)
12+
13+
rightFrame=Frame(root, width=500, height = 600, background="Yellow")
14+
rightFrame.grid(row=0, column=1)
15+
16+
text1=Label(rightFrame, text="READ TEXTS", font=('times', 20, 'bold'))
17+
text1.config(bg='yellow', fg='black')
18+
text1.grid(row=0, column=0, padx=2, pady=2)
19+
20+
text2=Label(rightFrame, text="SAVED TEXTS", font=('times', 20, 'bold'))
21+
text2.config(bg='yellow', fg='black')
22+
text2.grid(row=2, column=0, padx=2, pady=2)
23+
24+
colorLog=Text(rightFrame, width = 37, height = 10, takefocus=0, font=('times', 18))
25+
colorLog.grid(row=1, column=0, padx=10, pady=10)
26+
27+
colorLog2=Text(rightFrame, width = 37, height= 5, takefocus=0, font=('times', 18))
28+
colorLog2.grid(row=3, column=0, padx=10, pady=10)
29+
30+
fr=open("texts.txt", "r")
31+
str1=fr.read()
32+
str2=str1.split('_')
33+
34+
colorLog2.insert(0.0, str2[0]+"\n")
35+
colorLog2.insert(0.0, str2[1]+"\n")
36+
colorLog2.insert(0.0, str2[2]+"\n")
37+
38+
def my_mainloop():
39+
s1=time.asctime()
40+
print("Text")
41+
colorLog.insert(0.0, "Text "+s1+"\n")
42+
root.after(1000, my_mainloop)
43+
44+
image=Image.open("image.jpg")
45+
photo=ImageTk.PhotoImage(image)
46+
l1=Label(leftFrame, image=photo, height=600, width=900).pack()
47+
48+
root.after(1000, my_mainloop)
49+
root.mainloop()
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
from tkinter import *
2+
3+
root=Tk()
4+
root.wm_title("Window Title")
5+
root.config(background = "#FFFFFF")
6+
7+
def redCircle():
8+
circleCanvas.create_oval(20, 20, 80, 80, width=0, fill='red')
9+
colorLog.insert(0.0, "Red\n")
10+
11+
def yelCircle():
12+
circleCanvas.create_oval(20, 20, 80, 80, width=0, fill='yellow')
13+
colorLog.insert(0.0, "Yellow\n")
14+
15+
def grnCircle():
16+
circleCanvas.create_oval(20, 20, 80, 80, width=0, fill='green')
17+
colorLog.insert(0.0, "Green\n")
18+
19+
leftFrame=Frame(root, width=400, height = 800)
20+
leftFrame.grid(row=0, column=0, padx=10, pady=2)
21+
22+
Label(leftFrame, text="Instructions:").grid(row=0, column=0, padx=10, pady=2)
23+
24+
Instruct=Label(leftFrame, text="1\n2\n2\n3\n4\n5\n6\n7\n8\n9\n")
25+
Instruct.grid(row=1, column=0, padx=10, pady=2)
26+
27+
try:
28+
imageEx = PhotoImage(file = '/home/pi/1.jpg')
29+
Label(leftFrame, image=imageEx).grid(row=2, column=0, padx=10, pady=2)
30+
except:
31+
print("Image not found")
32+
33+
rightFrame=Frame(root, width=200, height = 600)
34+
rightFrame.grid(row=0, column=1, padx=10, pady=2)
35+
36+
circleCanvas=Canvas(rightFrame, width=100, height=100, bg='white')
37+
circleCanvas.grid(row=0, column=0, padx=10, pady=2)
38+
39+
btnFrame=Frame(rightFrame, width=200, height = 200)
40+
btnFrame.grid(row=1, column=0, padx=10, pady=2)
41+
42+
colorLog=Text(rightFrame, width = 30, height = 10, takefocus=0)
43+
colorLog.grid(row=2, column=0, padx=10, pady=2)
44+
45+
redBtn=Button(btnFrame, text="Red", command=redCircle)
46+
redBtn.grid(row=0, column=0, padx=10, pady=2)
47+
48+
yellowBtn=Button(btnFrame, text="Yellow", command=yelCircle)
49+
yellowBtn.grid(row=0, column=1, padx=10, pady=2)
50+
51+
greenBtn=Button(btnFrame, text="Green", command=grnCircle)
52+
greenBtn.grid(row=0, column=2, padx=10, pady=2)
53+
54+
root.mainloop()

PrintTextOnLabels.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
from tkinter import *
2+
import time
3+
4+
root=Tk()
5+
root.wm_title("TEXTS")
6+
root.config(background = "#FFFFFF")
7+
root.geometry("1400x600")
8+
9+
leftFrame=Frame(root, width=900, height = 600, background="Yellow")
10+
leftFrame.grid(row=0, column=0)
11+
12+
rightFrame=Frame(root, width=500, height = 600, background="Yellow")
13+
rightFrame.grid(row=0, column=1)
14+
15+
text1=Label(rightFrame, text="READ TEXTS", font=('times', 20, 'bold'))
16+
text1.config(bg='yellow', fg='black')
17+
text1.grid(row=0, column=0, padx=2, pady=2)
18+
19+
text2=Label(rightFrame, text="SAVED TEXTS", font=('times', 20, 'bold'))
20+
text2.config(bg='yellow', fg='black')
21+
text2.grid(row=2, column=0, padx=2, pady=2)
22+
23+
colorLog=Text(rightFrame, width = 37, height = 10, takefocus=0, font=('times', 18))
24+
colorLog.grid(row=1, column=0, padx=10, pady=10)
25+
26+
colorLog2=Text(rightFrame, width = 37, height= 5, takefocus=0, font=('times', 18))
27+
colorLog2.grid(row=3, column=0, padx=10, pady=10)
28+
29+
def my_mainloop():
30+
s1=time.asctime()
31+
print("Text")
32+
colorLog.insert(0.0, "Text "+s1+"\n")
33+
root.after(1000, my_mainloop)
34+
35+
root.after(1000, my_mainloop)
36+
root.mainloop()

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
1-
# Python-Tkinter-GUI-Examples
1+
# Python-Tkinter-GUI-Examples
2+
This repository contains examples of user interfaces created using the Tkinter module in Python. The interface examples utilize toolbox elements such as listbox and button.
3+
4+
Python IDEs: PyCharm, Thonny
5+
6+
Python Version: Python3
7+
8+
Python Modules: To install the necessary Python modules on the Windows, you should review the Python documentation according to the selected IDE.
9+
10+
Operating System: Windows, Linux

WriteTextToListBoxAtIntervals.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from tkinter import *
2+
3+
master=Tk()
4+
5+
listbox=Listbox(master)
6+
listbox.pack()
7+
8+
def my_mainloop():
9+
print("Hello World")
10+
listbox.insert(END, "Hello World")
11+
master.after(1000, my_mainloop)
12+
13+
master.after(1000, my_mainloop)
14+
master.mainloop()
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from tkinter import *
2+
import time
3+
4+
master=Tk()
5+
6+
listbox=Listbox(master)
7+
listbox.pack()
8+
9+
def my_mainloop():
10+
s1=time.asctime()
11+
print("Hello World")
12+
listbox.insert(END, "Hello"+s1)
13+
master.after(1000, my_mainloop)
14+
15+
def my_mainloop2():
16+
s2=time.asctime()
17+
print("Esen")
18+
listbox.insert(END, "Esen"+s2)
19+
master.after(1000,my_mainloop2)
20+
21+
master.after(1000, my_mainloop)
22+
master.after(1000, my_mainloop2)
23+
master.mainloop()

image.jpg

5.94 KB
Loading

texts.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
text1_text2_text3_

0 commit comments

Comments
 (0)