Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from appJar import gui
- app=gui("Rubrica")
- app.setOnTop(stay=True)
- app.setResizable(False)
- app.setSize(500,400)
- app.setBg("lightblue")
- l=[]
- i=0
- class Rubrica(object):
- def __init__(self,nome,numero,mail):
- self.nome=nome
- self.numero=numero
- self.mail=mail
- def modifica(self):
- print(self.nome)
- def elimina(self):
- print(self.numero)
- def press3(pp):
- global i
- global l
- z=0
- for z in range(i):
- if pp==(str(z)):
- app.removeAllWidgets()
- app.addLabel("alt","Contatto "+l[z].nome,0,0)
- app.setLabelBg("alt", "yellow")
- app.addLabel("nome","Nome: "+l[z].nome,2,0)
- app.addLabel("numero","Numero: "+l[z].numero,3,0)
- app.addLabel("mail","Mail: "+l[z].mail,4,0)
- app.addNamedButton("<","sss",fai,6,0)
- if pp=="Cerca":
- if (len(app.getEntry("Cerc")))==0:
- fdsg=0
- else:
- dd=app.getEntry("Cerc")
- t=dd.lower()
- app.removeAllWidgets()
- app.addLabel("B","Rubrica Contatti by Spataro",0,0)
- app.setLabelBg("B", "yellow")
- app.addEntry("Cerc",1,0)
- app.addButton("Cerca",press3,1,1)
- app.addButton("x",fai,1,2)
- app.setEntry("Cerc", dd)
- k=0
- u=0
- for k in range(i):
- if k==0:
- u=2
- if (t in ((l[k].nome).lower()))==True:
- app.addLabel("c"+str(k),l[k].nome,u+2,0)
- app.setLabelBg("c"+str(k), "orange")
- app.addNamedButton("Visualizza", str(k), press3,u+2,1)
- u=u+1
- app.addButton("Esci",press,u+2,0)
- app.addButton("Svuota Rubrica",press3,u+2,1)
- app.addButton("+",press,u+2,5)
- def fai():
- global l
- global i
- app.removeAllWidgets()
- app.addLabel("B","Rubrica Contatti by Spataro",0,0)
- app.setLabelBg("B", "yellow")
- app.addEntry("Cerc",1,0)
- app.addButton("Cerca",press3,1,1)
- k=0
- u=0
- for k in range(i):
- if k==0:
- u=2
- app.addLabel("c"+str(k),l[k].nome,u+2,0)
- app.setLabelBg("c"+str(k), "orange")
- app.addNamedButton("Visualizza", str(k), press3,u+2,1)
- u=u+1
- app.addButton("Esci",press,u+2,0)
- app.addButton("Svuota Rubrica",press3,u+2,1)
- app.addButton("+",press,u+2,5)
- def press1(p):
- global l
- global i
- if p=="<":
- fai()
- if p=="Conferma":
- l.append("p")
- l[i]=Rubrica(app.getEntry("Nome"),app.getEntry("Numero"),app.getEntry("Mail"))
- i=i+1
- file=open("contatti.txt","a")
- file.write(app.getEntry("Nome")+","+app.getEntry("Numero")+","+app.getEntry("Mail")+",\n")
- file.close()
- fai()
- def press(pulsante):
- if pulsante=="+":
- app.removeAllWidgets()
- app.addLabel("A","Nuovo Contatto",0,0)
- app.setLabelBg("A", "white")
- app.addLabelEntry("Nome",1,0)
- app.addLabelEntry("Numero",2,0)
- app.addLabelEntry("Mail",3,0)
- app.addButton("<",press1,5,0)
- app.addButton("Conferma",press1,5,5)
- if pulsante=="Esci":
- app.stop()
- fai()
- """
- x=Rubrica("Ciao","356")
- y=Rubrica("Bello","467")
- x.stampa()
- y.stampa()
- x.stampa1()
- y.stampa1()
- """
- app.go()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement