[Tutor] Clickable listbox opening .txt files

Ali Moradi adeadmarshal at gmail.com
Thu Jan 14 06:39:44 EST 2016


Hi, you said my click event grabs text and doesn't show it. So how do get
it to show on the Text widget? So that when i clicked on item 1, 1.txt
shows on the Text widget. I can't connect click event to Text widget

from Tkinter import *
root = Tk()
root.title("Renkontoj kun Diferenculoj")
root.iconbitmap(r"C:\python27\DLLs/py.ico")
root.resizable(0, 0)
frame1 = LabelFrame(root, height=300, width=400, text='Lecionoj')
frame2 = LabelFrame(root, height=300, width=400, text='Tekstoj')
frame1.grid(row=0, column=0) frame2.grid(row=0, column=1)
def click(event):
index = list.curselection()[0]
file = open(r"C:\Users\deadmarshal\PycharmProjects\ali\1.txt").read()
list = Listbox(frame1)
list.insert(1, "Konatiĝu kun Kamila") list.insert(2, "Sinjoro Johano")
list.insert(3, "Onklino Marta")
scroll = Scrollbar(frame1, orient=VERTICAL, command=list.yview)
scroll.grid(row=0, column=2, sticky='ns') list.grid(row=0, column=1)
list.bind("<ButtonRelease-1>", click)
text = Text(frame2).grid() root.mainloop()


More information about the Tutor mailing list