ive been learning python since the last couple days and am stuck on this "project"
basically what i am making is a program where a list of picture names appear in a list on one side and when you click them they should appear on the other side in a canvas.
below i included what i have so far. when i run the program it says that "list" does not have attribute "bind". im pretty sure it does, but i cant figure this one out and i lost the source material so i cannot reference it. this is driving me nuts. please help!!!!
-------
#!/usr/bin/python
from Tkinter import *
from os import listdir
def Pushed():
friend_name = ent.get()
friend_info = tex.get(0.0,END )
friend_name = "friends/" + friend_name
fil = file(friend_nam e,'w')
fil.write(frien d_info)
fil.close()
li.delete(0,END )
fil = listdir('friend s/')
for item in fil:
li.insert(END,i tem)
def Press(self):
tex.delete(0.0, END)
ent.delete(0,EN D)
selec = li.curselection ()
str = li.get(selec[0])
ent.insert(END, str)
str = 'friends/' + str
fin = file(str,'r')
outp = fin.read()
fin.close()
tex.insert(END, outp)
root = Tk()
root.geometry(' 500x350+270+50' )
lab = Label(root,text = "Friend directory")
name = Label(root, text = "name")
butto = Button(root, text = "New Friend", command = Pushed)
ent = Entry(root, bg = 'white', width = 40)
li = Listbox(root, bg = 'white', height = 13)
tex = Text(root, bg = 'white', font=("Helvatic a",15), width = 30, height = 15)
lab.grid(row = 0, columnspan = 3)
name.grid(row = 1, column = 0)
ent.grid(row = 1, column = 1)
li.grid(rowspan = 2, column = 0 )
tex.grid(row = 2, column = 1)
butto.grid(row = 3, column = 1)
fil = listdir('friend s/')
for item in fil:
li.insert(END,i tem)
li.bind("<Doubl e-Button-1>",Press)
root.mainloop()
basically what i am making is a program where a list of picture names appear in a list on one side and when you click them they should appear on the other side in a canvas.
below i included what i have so far. when i run the program it says that "list" does not have attribute "bind". im pretty sure it does, but i cant figure this one out and i lost the source material so i cannot reference it. this is driving me nuts. please help!!!!
-------
#!/usr/bin/python
from Tkinter import *
from os import listdir
def Pushed():
friend_name = ent.get()
friend_info = tex.get(0.0,END )
friend_name = "friends/" + friend_name
fil = file(friend_nam e,'w')
fil.write(frien d_info)
fil.close()
li.delete(0,END )
fil = listdir('friend s/')
for item in fil:
li.insert(END,i tem)
def Press(self):
tex.delete(0.0, END)
ent.delete(0,EN D)
selec = li.curselection ()
str = li.get(selec[0])
ent.insert(END, str)
str = 'friends/' + str
fin = file(str,'r')
outp = fin.read()
fin.close()
tex.insert(END, outp)
root = Tk()
root.geometry(' 500x350+270+50' )
lab = Label(root,text = "Friend directory")
name = Label(root, text = "name")
butto = Button(root, text = "New Friend", command = Pushed)
ent = Entry(root, bg = 'white', width = 40)
li = Listbox(root, bg = 'white', height = 13)
tex = Text(root, bg = 'white', font=("Helvatic a",15), width = 30, height = 15)
lab.grid(row = 0, columnspan = 3)
name.grid(row = 1, column = 0)
ent.grid(row = 1, column = 1)
li.grid(rowspan = 2, column = 0 )
tex.grid(row = 2, column = 1)
butto.grid(row = 3, column = 1)
fil = listdir('friend s/')
for item in fil:
li.insert(END,i tem)
li.bind("<Doubl e-Button-1>",Press)
root.mainloop()
Comment