Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- class AccountCompany(Toplevel):
- def __init__(self):
- super().__init__()
- self.title('Съставител на финансовия отчет')
- self.geometry('700x500+600+200')
- self.attributes('-topmost', 'true')
- self.var = IntVar()
- self.selection = None
- self.acc_dict = {
- 'name': None,
- 'sit': None,
- 'addr': None,
- 'eik': None,
- 'men': None,
- 'office_tel': None,
- 'email': None,
- 'trade_obj': None
- }
- self.fl_dict = {
- 'name': None,
- 'sit': None,
- 'office_tel': None,
- 'email': None,
- 'trade_obj': None
- }
- def open_acc(self):
- # Radio button radio_n(self, x, y, text, value, command):
- self.fl = self.radio_n(200, 20, "ФЛ", 1, self.choice)
- self.sp = self.radio_n(250, 20, "СП", 2, self.choice)
- # Create Button
- btn_save = self.button_n(500, 18, ' ЗАПИШИ ', 'blue', ('Bookman Old Style Bold', 8), 2, 10, lambda: self.add_to_dict())
- btn_change = self.button_n(500, 78, ' ПРОМЯНА ', 'red', ('Bookman Old Style Bold', 8), 2, 10, None)
- btn_exit = self.button_n(500, 318, 'OK', 'green', ('Bookman Old Style Bold', 8), 2, 10, self.destroy)
- btn_help = self.button_n(500, 378, 'Помощ', 'black', ('Bookman Old Style Bold', 8), 1, 10, None) # h=1 , w=10
- def fl_form(self):
- # Create Label
- flname_l = self.label_n(20, 60, 20, 'Име')
- flsit_l = self.label_n(20, 100, 20, 'Адрес')
- flphone1_l = self.label_n(20, 140, 20, 'Телефон:')
- flmail_l = self.label_n(20, 180, 20, 'e-mail:')
- flact_place_l = self.label_n(20, 220, 20, 'Адрес за кореспонденция:')
- # Create Entry
- self.flname_e = self.entry_n(200, 60, 40)
- self.flsit_e = self.entry_n(200, 100, 40)
- self.flphone1_e = self.entry_n(200, 140, 40)
- self.flmail_e = self.entry_n(200, 180, 40)
- self.flact_place_e = self.entry_n(200, 220, 40)
- def sp_form(self):
- # Create Label
- name_l = self.label_n(20, 60, 20, 'Наименование на СП')
- sit_l = self.label_n(20, 100, 20, 'Седалище')
- addr_l = self.label_n(20, 140, 20, 'Адрес на управление')
- e_num_l = self.label_n(20, 180, 20, 'ЕИК (Булстат)')
- men_l = self.label_n(20, 220, 20, 'Представляващ СП')
- phone1_l = self.label_n(20, 260, 20, 'Офис тел:')
- mail_l = self.label_n(20, 300, 20, 'Счетоводство e-mail:')
- act_place_l = self.label_n(20, 340, 20, 'Адрес за кореспонденция:')
- # Create Entry
- self.name_e = self.entry_n(200, 60, 40)
- self.sit_e = self.entry_n(200, 100, 40)
- self.addr_e = self.entry_n(200, 140, 40)
- self.e_num_e = self.entry_n(200, 180, 40)
- self.men_e = self.entry_n(200, 220, 40)
- self.phone1_e = self.entry_n(200, 260, 40)
- self.mail_e = self.entry_n(200, 300, 40)
- self.act_place_e = self.entry_n(200, 340, 40)
- def label_n(self, x, y, w, t):
- bord_color = Frame(self, width=w, background='green')
- bord_color.place(x=x, y=y)
- lab = Label(bord_color, text=t, font=('Times', 10, 'italic'))
- lab.pack(padx=0, pady=(0, 1))
- def entry_n(self, x, y, w):
- ent = Entry(self, bd=4, width=w)
- ent.place(x=x, y=y)
- return ent
- def button_n(geo, x, y, t, f, fnt, h, w, comm):
- btn = Button(geo, text=t, fg=f, command=comm, font=fnt, height=h, width=w)
- btn.place(x=x, y=y)
- def radio_n(self, x, y, t, v, comm):
- radio_butt = Radiobutton(self, text=t, variable=self.var, value=v, command=comm)
- radio_butt.place(x=x, y=y)
- return radio_butt
- def choice(self):
- self.selection = self.var.get()
- print(self.selection)
- if self.selection == 1:
- self.sp.configure(state='disabled')
- self.fl_form()
- elif self.selection == 2:
- self.fl.configure(state='disabled')
- self.sp_form()
- return self.selection
- def add_to_dict(self):
- print(self.acc_dict)
- print(self.selection)
- if self.selection == 1:
- self.fl_dict['name'] = self.flname_e.get()
- self.fl_dict['sit'] = self.flsit_e.get()
- self.fl_dict['office_tel'] = self.flphone1_e.get()
- self.fl_dict['email'] = self.flmail_e.get()
- self.fl_dict['trade_obj'] = self.flact_place_e.get()
- print(self.fl_dict)
- return self.fl_dict
- elif self.selection == 2:
- self.acc_dict['name'] = self.name_e.get()
- self.acc_dict['sit'] = self.sit_e.get()
- self.acc_dict['addr'] = self.addr_e.get()
- self.acc_dict['eik'] = self.e_num_e.get()
- self.acc_dict['men'] = self.men_e.get()
- self.acc_dict['office_tel'] = self.phone1_e.get()
- self.acc_dict['email'] = self.mail_e.get()
- self.acc_dict['trade_obj'] = self.act_place_e.get()
- print(self.acc_dict)
- return self.acc_dict
- if __name__ == '__main__':
- root = Tk()
- root.geometry('100x100+300+200')
- root.attributes('-topmost', 'true') # Винаги да е отгоре
- ext = Button(root, text='Exit', command=root.destroy)
- ext.pack(side='bottom')
- inp_win = AccountCompany()
- inp_win.open_acc()
- inp_win.mainloop()
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement