Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.48 KB | None | 0 0
  1. from appJar import gui
  2. app=gui("Rubrica")
  3. app.setOnTop(stay=True)
  4. app.setResizable(False)
  5. app.setSize(500,400)
  6. app.setBg("lightblue")
  7. l=[]
  8. i=0
  9.  
  10. class Rubrica(object):
  11. def __init__(self,nome,numero,mail):
  12. self.nome=nome
  13. self.numero=numero
  14. self.mail=mail
  15. def modifica(self):
  16. print(self.nome)
  17. def elimina(self):
  18. print(self.numero)
  19.  
  20. def press3(pp):
  21. global i
  22. global l
  23. z=0
  24. for z in range(i):
  25. if pp==(str(z)):
  26. app.removeAllWidgets()
  27. app.addLabel("alt","Contatto "+l[z].nome,0,0)
  28. app.setLabelBg("alt", "yellow")
  29. app.addLabel("nome","Nome: "+l[z].nome,2,0)
  30. app.addLabel("numero","Numero: "+l[z].numero,3,0)
  31. app.addLabel("mail","Mail: "+l[z].mail,4,0)
  32. app.addNamedButton("<","sss",fai,6,0)
  33. if pp=="Cerca":
  34. if (len(app.getEntry("Cerc")))==0:
  35. fdsg=0
  36. else:
  37. dd=app.getEntry("Cerc")
  38. t=dd.lower()
  39. app.removeAllWidgets()
  40. app.addLabel("B","Rubrica Contatti by Spataro",0,0)
  41. app.setLabelBg("B", "yellow")
  42. app.addEntry("Cerc",1,0)
  43. app.addButton("Cerca",press3,1,1)
  44. app.addButton("x",fai,1,2)
  45. app.setEntry("Cerc", dd)
  46. k=0
  47. u=0
  48. for k in range(i):
  49. if k==0:
  50. u=2
  51. if (t in ((l[k].nome).lower()))==True:
  52. app.addLabel("c"+str(k),l[k].nome,u+2,0)
  53. app.setLabelBg("c"+str(k), "orange")
  54. app.addNamedButton("Visualizza", str(k), press3,u+2,1)
  55. u=u+1
  56. app.addButton("Esci",press,u+2,0)
  57. app.addButton("Svuota Rubrica",press3,u+2,1)
  58. app.addButton("+",press,u+2,5)
  59.  
  60. def fai():
  61. global l
  62. global i
  63. app.removeAllWidgets()
  64. app.addLabel("B","Rubrica Contatti by Spataro",0,0)
  65. app.setLabelBg("B", "yellow")
  66. app.addEntry("Cerc",1,0)
  67. app.addButton("Cerca",press3,1,1)
  68. k=0
  69. u=0
  70. for k in range(i):
  71. if k==0:
  72. u=2
  73. app.addLabel("c"+str(k),l[k].nome,u+2,0)
  74. app.setLabelBg("c"+str(k), "orange")
  75. app.addNamedButton("Visualizza", str(k), press3,u+2,1)
  76. u=u+1
  77. app.addButton("Esci",press,u+2,0)
  78. app.addButton("Svuota Rubrica",press3,u+2,1)
  79. app.addButton("+",press,u+2,5)
  80. def press1(p):
  81. global l
  82. global i
  83. if p=="<":
  84. fai()
  85. if p=="Conferma":
  86. l.append("p")
  87. l[i]=Rubrica(app.getEntry("Nome"),app.getEntry("Numero"),app.getEntry("Mail"))
  88. i=i+1
  89. file=open("contatti.txt","a")
  90. file.write(app.getEntry("Nome")+","+app.getEntry("Numero")+","+app.getEntry("Mail")+",\n")
  91. file.close()
  92. fai()
  93. def press(pulsante):
  94. if pulsante=="+":
  95. app.removeAllWidgets()
  96. app.addLabel("A","Nuovo Contatto",0,0)
  97. app.setLabelBg("A", "white")
  98. app.addLabelEntry("Nome",1,0)
  99. app.addLabelEntry("Numero",2,0)
  100. app.addLabelEntry("Mail",3,0)
  101. app.addButton("<",press1,5,0)
  102. app.addButton("Conferma",press1,5,5)
  103. if pulsante=="Esci":
  104. app.stop()
  105.  
  106.  
  107. fai()
  108. """
  109. x=Rubrica("Ciao","356")
  110. y=Rubrica("Bello","467")
  111. x.stampa()
  112. y.stampa()
  113. x.stampa1()
  114. y.stampa1()
  115. """
  116.  
  117. app.go()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement