Advertisement
deadmarshal

Untitled

Sep 6th, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.45 KB | None | 0 0
  1. #! /usr/bin/env python3
  2. __author__ = 'deadmarshal'
  3. import sqlite3 as sqlite
  4. import tkinter as tk
  5. from tkinter import Listbox
  6. from tkinter import Text
  7. from tkinter import Entry
  8. from tkinter import Scrollbar
  9. from tkinter import ttk
  10.  
  11. #GUI
  12. root = tk.Tk()
  13.  
  14. frame1 = ttk.LabelFrame(root)
  15. frame1.config(height=200, width=300, text="Words")
  16. frame1.pack(side=tk.LEFT, anchor='nw')
  17. frame1.config(padding=(3, 5))
  18. frame2 = ttk.LabelFrame(root)
  19. frame2.config(height=200, width=300, text="Definitions")
  20. frame2.pack(side=tk.RIGHT, anchor='ne')
  21. frame2.config(padding=(3, 5))
  22.  
  23. entry = tk.Entry(frame1, width=30)
  24. entry.grid(row=0, column=0)
  25.  
  26. button = ttk.Button(frame1, text="Search")
  27. button.grid(row=0, column=1)
  28.  
  29. textbox = Text(frame2, width=60, height=30)
  30. textbox.pack()
  31. listbox = Listbox(frame1, height=30, width=30)
  32. s = Scrollbar(frame1, orient=tk.VERTICAL)
  33. listbox.configure(yscrollcommand=s.set)
  34. listbox.grid(row=1, column=0)
  35.  
  36.  
  37.  
  38. def listboxitemclicked():
  39.     listbox.bind('<Button-1>')
  40.    
  41. #sqlite
  42. db = sqlite.connect(r'/home/deadmarshal/PycharmProjects/Geologydict/test.db')
  43. cur = db.cursor()
  44. cur.execute('select Esperanto from Words')
  45.  
  46. for row in cur:
  47.     listbox.insert(tk.END, row)
  48.     if listboxitemclicked():
  49.         for row in cur:
  50.             cur.execute('select English from Words')
  51.             textbox.insert(tk.END, cur)
  52.  
  53.  
  54. #db tbl name: Words
  55. ##db first field name: Esperanto
  56. ##db second field name: English
  57.  
  58. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement