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=False, height= False)
- root.title("Dic")
- root.configure(background='skyblue')
- ########### DEF FOR SEARCH #######
- def search():
- #try:
- conn= sqlite3.connect('Example.db')
- cur= conn.cursor()
- tex.delete(1.0,"end")
- data= v.get()
- cur.execute("SELECT definition, Image FROM tables WHERE Word= ?", (data.lower(),))
- var= cur.fetchone()
- tex.insert("end", var[0]) # accessing the meaning
- #####################################
- img_path = var[1] # accessing thge 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")
- ########## GUI DESIGN ##############
- v= tk.StringVar()
- entry= tk.Entry(root, width=20,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", 9))
- Butt.place(x=190, y=25)
- tex=tk.Text(root, font= ("Bahnschrift SemiLight",12),bg= "#999ccc",bd= 0,width=35,height= 10)
- tex.place(x=50,y=55)
- ImageLabel= tk.Label(root,font=("calibra", 9), width=30, height= 13, bg= "white")
- ImageLabel.place(x=50, y= 250)
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment