test2
This commit is contained in:
1 parent
f2a7d6773b
commit
e7bcd3bd3f
1 file changed
+65
-10
+65
-10
@@ -1,11 +1,66 @@
|
|||||||
from tkinter import *
|
import tkinter as tk
|
||||||
from tkinter.ttk import *
|
from tkinter import ttk
|
||||||
import PIL
|
from PIL import Image, ImageTk
|
||||||
import pytesseract
|
import os
|
||||||
|
from os import listdir
|
||||||
|
|
||||||
root = Tk()
|
parent = tk.Tk()
|
||||||
frm = ttk.Frame(root, padding=10)
|
parent.title("Image in Tkinter")
|
||||||
frm.grid()
|
|
||||||
ttk.Label(frm, text="Hello World!").grid(column=0, row=0)
|
|
||||||
ttk.Button(frm, text="Quit", command=root.destroy).grid(column=1, row=0)
|
def button_clicked():
|
||||||
root.mainloop()
|
global isittrue
|
||||||
|
if isittrue == 0:
|
||||||
|
image2 = Image.open("test/ssh.png")
|
||||||
|
image2 = ImageTk.PhotoImage(image2)
|
||||||
|
image_label.configure(image=image2)
|
||||||
|
image_label.image = image2
|
||||||
|
isittrue = 1
|
||||||
|
else:
|
||||||
|
image_label.configure(image=img)
|
||||||
|
image_label.image = img
|
||||||
|
isittrue = 0
|
||||||
|
|
||||||
|
|
||||||
|
isittrue = 0
|
||||||
|
|
||||||
|
button = tk.Button(
|
||||||
|
parent,
|
||||||
|
text="Click Me",
|
||||||
|
command=button_clicked,
|
||||||
|
activebackground="blue",
|
||||||
|
activeforeground="white",
|
||||||
|
anchor="center",
|
||||||
|
bd=3,
|
||||||
|
bg="lightgray",
|
||||||
|
cursor="hand2",
|
||||||
|
disabledforeground="gray",
|
||||||
|
fg="black",
|
||||||
|
font=("Arial", 12),
|
||||||
|
height=2,
|
||||||
|
highlightbackground="black",
|
||||||
|
highlightcolor="green",
|
||||||
|
highlightthickness=2,
|
||||||
|
justify="center",
|
||||||
|
overrelief="raised",
|
||||||
|
padx=10,
|
||||||
|
pady=5,
|
||||||
|
width=15,
|
||||||
|
wraplength=100,
|
||||||
|
)
|
||||||
|
|
||||||
|
button.pack(padx=20, pady=20)
|
||||||
|
|
||||||
|
folder_dir = "./test/"
|
||||||
|
for images in os.listdir(folder_dir):
|
||||||
|
|
||||||
|
if images.endswith(".png") or images.endswith(".jpg") or images.endswith(".jpeg"):
|
||||||
|
print(images)
|
||||||
|
|
||||||
|
img = Image.open("test/couv.png")
|
||||||
|
img = ImageTk.PhotoImage(img)
|
||||||
|
|
||||||
|
image_label = tk.Label(parent, image=img)
|
||||||
|
image_label.pack()
|
||||||
|
|
||||||
|
parent.mainloop()
|
||||||
Reference in new issue
Block a user