[Tutor] making a list in Tkinter with clickable items (Python 2.x)

Ali Moradi adeadmarshal at gmail.com
Thu Apr 16 12:00:29 CEST 2015


Hi, i want to load a bunch of words from my database into the listbox in
Tkinter, make them clickable, and when i clicked on them the specific
meaning of that word apears in a textbox beside the listbox.

i have a code but it's not complete. i'm a beginner in Python :(

code:
#!/bin/python
from tkinter import *
from tkinter import ttk

def z():
    global entry
    if(lb.get(lb.curselection())):
        txt.insert(END, lb.get(lb.curselection()))


root = Tk()

entry = ttk.Entry(root);entry.grid(row = 0, column = 0)


lb = Listbox(root)

a=lb.insert(1, "crime")
b=lb.insert(2, "murder")
lb.insert(3, "get")
lb.insert(4, "take")

Button(root, text="BUtt", command=z).grid()

lb.grid(row = 1, column = 0)

scroll = Scrollbar(root, orient = VERTICAL, command = lb.yview)
scroll.grid(row = 0, column = 1, sticky = 'ns')
lb.config(yscrollcommand = scroll.set)

txt = Text(root, width = 60, height = 30,)
txt.grid(row = 1, column = 2)

root.mainloop()
-----------------------------------
thanks.


More information about the Tutor mailing list