# -*- coding: utf-8 -*- # Rehber uygulaması # 2008 - rohanrhu@pardus from Tkinter import * import os, sys, shelve, re def lboxr(): lbox.delete(0, END) for i in tel: lbox.insert(END, i) def nogoster(event): index = lbox.curselection()[0] no = lbox.get(index) numara.delete(0, END) no2 = tel[no] numara.insert(0, no2) def sil(): index = lbox.curselection()[0] no = lbox.get(index) del tel[no] lboxr() def eklep(): def ekle(): tel[isimtext.get()] = numaratext.get(); lboxr() ep = Toplevel() ep.title("Ekle") Label(ep, text="İsim").pack() isimtext = Entry(ep) isimtext.pack() Label(ep, text="Numara").pack() numaratext = Entry(ep) numaratext.pack() Button(ep, text="Tamam", command=ekle).pack() def ara(): telr = tel.keys() no = 0 for i in range(len(telr)): if re.search(aratext.get(), telr[i]): no += 1 lbox.insert(0, telr[i]) lbox.delete(no, END) def yenile(): lboxr() tel = shelve.open("/home/%s/.rehber.db" % os.getenv("USER")) pencere = Tk() pencere.geometry("440x240") pencere.title("Telefon Rehberi") sbar = Scrollbar(pencere) sbar.pack(side=RIGHT, fill=Y) lbox = Listbox(pencere) lbox.place(x=15, y=15) Label(text="Numara:").place(x=193, y=149) numara = Entry(pencere) numara.config(fg="red") numara.place(x=192, y=170) aratext = Entry(pencere) aratext.place(x=200, y=50) Button(pencere, text="Yenile", command=yenile).place(x=310, y=80) Button(pencere, text="Ara", command=ara).place(x=250, y=80) Button(pencere, text="Ekle", command=eklep).place(x=190, y=80) Button(pencere, text="Sil", command=sil).place(x=190, y=120) lboxr() lbox.bind("", nogoster) #aratext.bind("", ara) sbar.config(command=lbox.yview) lbox.config(yscrollcommand=sbar.set) pencere.mainloop()