python - Interactive Listbox Tkinter -



python - Interactive Listbox Tkinter -

i have 2 listboxes in user interface, pbs , f, 1 next other. in pbs have list of problems have associated several filenames. want when 1 of problems pbs clicked, corresponding list of files appear in f. have managed far index of selected alternative pbs , files appear correctly after first click, after several clicks, files displayed other problem selected one.

also not sure storing correctly index. tried 2 options:

storing name of problems , of files in dictionary - problem here entries ordered , no want this; want them in way entered them having list problems , list files - problem here cannot index listbox integer

these problems , files (as dictionary , lists):

problems = { 'pb_1':['1.txt','2.txt','3.txt'], 'pb_a':['a_1.txt','a_2.txt','a_3.txt'] } problems=['pb_1','pb_a'] files=[['1.txt','2.txt','3.txt'],['a_1.txt','a_2.txt','a_3.txt']]

and code:

def immd(e): in problems[pbs.get('active')]: f.insert(end,i) root = tk() root.title('title') frame2 = frame(root) frame2.pack(side=right) l3 = label(frame2, text='problems:').grid(row=0,column=0) pbs = listbox(frame2, height=10) pbs.grid(row=1,column=0) in problems: pbs.insert(end,i) pbs.bind('<<listboxselect>>',immd) l4 = label(frame2, text='files:').grid(row=0,column=1) f = listbox(frame2, height=10) f.grid(row=1,column=1) root.mainloop()

using listbox.curselection, can indice of selected items. indices list of strings; should convert strings ints.

def immd(e): indice = pbs.curselection() index = int(indice[0]) ....

python listbox tkinter interactive

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -