Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/bin/env python3
- import sqlite3 as sqlite
- import tkinter as tk
- from tkinter import Listbox
- from tkinter import Text
- from tkinter import Entry
- from tkinter import Scrollbar
- from tkinter import ttk
- #GUI
- root = tk.Tk()
- #sqlite
- db = sqlite.connect(r'/home/deadmarshal/PycharmProjects/Geologydict/test.db')
- cur = db.cursor()
- cur.execute('select Esperanto from Words')
- def enter_meaning(*args):
- if listbox.curselection():
- cur.execute('select English from Words')
- cur.fetchall()
- for i in cur:
- textbox.insert(tk.END, i)
- frame1 = ttk.LabelFrame(root)
- frame1.config(height=200, width=300, text="Words")
- frame1.pack(side=tk.LEFT, anchor='nw')
- frame1.config(padding=(3, 5))
- frame2 = ttk.LabelFrame(root)
- frame2.config(height=200, width=300, text="Definitions")
- frame2.pack(side=tk.RIGHT, anchor='ne')
- frame2.config(padding=(3, 5))
- entry = tk.Entry(frame1, width=30)
- entry.grid(row=0, column=0)
- entry.insert(0, "Type to Search")
- def entry_callback(event):
- entry.delete(0, tk.END)
- return None
- entry.bind('<Button-1>', entry_callback)
- button = ttk.Button(frame1, text="Search")
- button.grid(row=0, column=1)
- logo = tk.PhotoImage(file='/home/deadmarshal/PycharmProjects/Geologydict/search.png')
- small_logo = logo.subsample(3, 3)
- button.config(image=small_logo, compound=tk.LEFT)
- textbox = Text(frame2, width=60, height=34)
- textbox.pack()
- textbox.config(wrap='word')
- listbox = Listbox(frame1, height=30, width=30)
- s = Scrollbar(frame1, orient=tk.VERTICAL)
- listbox.configure(yscrollcommand=s.set)
- listbox.grid(row=1, column=0)
- listbox.bind('<<ListboxSelect>>', enter_meaning)
- for row in cur:
- listbox.insert(tk.END, row)
- if listbox.bind('<Button-1>'):
- cur.execute('select Esperanto from Words')
- textbox.insert(tk.END, cur)
- #db tbl name: Words
- ##db first field name: Esperanto
- ##db second field name: English
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement