Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import tkinter as tk
- import sqlite3
- from tkinter import messagebox
- root = tk.Tk()
- root.geometry("400x500")
- root.resizable(width=True, height= True)
- root.title("Dic")
- root.configure(background='white')
- ########### DEF FOR SEARCH #######
- def search():
- try:
- conn= sqlite3.connect('GIS_DICTION.db')
- cur= conn.cursor()
- tex.delete(1.0,"end")
- data= v.get()
- cur.execute("SELECT Meaning, Image FROM DICTION WHERE Words= ?", (data.lower(),))
- var= cur.fetchone()
- tex.insert("end", var[0]) # accessing the meaning
- #####################################
- img_path = var[1] # accessing the path to the image
- image_object = tk.PhotoImage(file=img_path) # here I'm not using PIL, but tkinter PhotoImage
- ImageLabel.config(image=image_object)
- ImageLabel.image = image_object # keep a reference to the image
- ######################################
- except:
- messagebox.showinfo("Dic","Word not found")
- def refresh():
- entry.delete(0, "end")
- tex.delete(1.0, "end")
- ########## GUI DESIGN ##############
- v= tk.StringVar()
- entry= tk.Entry(root, width=20,font= ("Bahnschrift SemiLight",11), bg= "#FFFFFf",bd=2, textvariable= v)
- entry.place(x=50, y= 25)
- Butt= tk.Button(root, width=10, height= 1,command= search, text= "Search", bg= "#666699",fg="white",bd=0,font=("rockwell", 10))
- Butt.place(x=220, y=25)
- Refr= tk.Button(root, width=10, height= 1,command= refresh, text= "Refresh", bg= "#666699",fg="white",bd=0,font=("rockwell", 10))
- Refr.place(x=300, y=25)
- tex=tk.Text(root, font= ("Bahnschrift SemiLight",12),bg= "#999ccc",bd= 0,width=35,height= 10)
- tex.place(x=50,y=55)
- frame= tk.Frame(root, bg= "white")
- frame.place(x=40, y= 250)
- ImageLabel= tk.Label(frame,font=("calibra", 9), bg= "white")
- ImageLabel.pack(expand=True, fill= tk.BOTH,padx= 65, pady=20)
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement