Advertisement
Guest User

Untitled

a guest
Aug 19th, 2018
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.14 KB | None | 0 0
  1. class Add(tk.Frame):
  2.     posy = 0.3063
  3.     nentry = 1
  4.     entry = list()
  5.     var = list()
  6.     def __init__(self, parent, controller):
  7.         tk.Frame.__init__(self, parent)
  8.         self.controller = controller
  9.         self.configure(bg=color["giallo_bg"])
  10.         l1 = tk.Label(self, text=title, font=('Helvetica', 60), bg=color["giallo_bg"])
  11.         l2 = tk.Label(self, text="Aggiungi match", font=('Helvetica', 40), bg=color["giallo_bg"])
  12.         bt_return = tk.Button(self, text='Ritorna alla home', font=('Helvetica', 15), command=lambda: controller.show_frame("Main"))
  13.         l3 = tk.Label(self, text="Inserisci l'ingrediente principale", font=('Helvetica', 20), bg=color["giallo_bg"])
  14.         l4 = tk.Label(self, text="Inserisci gli ingredienti secondari", font=('Helvetica', 20), bg=color["giallo_bg"])
  15.         global var_main
  16.         var_main = tk.StringVar(value='')
  17.         e1 = tk.Entry(self, textvariable=var_main, width=30)
  18.         bt_more =  tk.Button(self, text='+ Match', font=('Helvetica', 15), command=self.more)
  19.         self.var.append(tk.StringVar(value=''))
  20.         self.entry.append(tk.Entry(self, textvariable=self.var[0], width=30))
  21.         bt_save = tk.Button(self, text='Salva', font=('Helvetica', 15), command=self.save)
  22.         l1.pack()
  23.         l2.pack()
  24.         l3.place(relx=0, rely=0.2)
  25.         l4.place(relx=0, rely=0.3)
  26.         self.entry[0].place(relx=0.21, rely=self.posy)
  27.         e1.place(relx=0.2, rely=0.2063)
  28.         bt_more.place(relx=0.35, rely=0.3)
  29.         bt_save.place(relx=0.35, rely=0.35)
  30.         bt_return.place(relx=0.465, rely=0.90)
  31.  
  32.     def save(self):
  33.         content = list()
  34.         for count in range(len(self.entry)):
  35.             content.append(self.var[count].get())
  36.         main = var_main.get()
  37.         database.save(main, content)
  38.  
  39.     def more(self):
  40.         if self.nentry == 19:
  41.             pass
  42.         else:
  43.             self.posy += 0.03
  44.             self.var.append(tk.StringVar(value=''))
  45.             self.entry.append(tk.Entry(self, textvariable=self.var[len(self.entry)], width=30))
  46.             self.entry[self.nentry].place(relx=0.21, rely=self.posy)
  47.             self.nentry += 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement