Advertisement
ALEXANDAR_GEORGIEV

accounting

Jul 29th, 2022 (edited)
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.67 KB | None | 0 0
  1. from tkinter import *
  2.  
  3.  
  4. class AccountCompany(Toplevel):
  5.  
  6.     def __init__(self):
  7.         super().__init__()
  8.         self.title('Съставител на финансовия отчет')
  9.         self.geometry('700x500+600+200')
  10.         self.attributes('-topmost', 'true')
  11.         self.var = IntVar()
  12.         self.selection = None
  13.         self.acc_dict = {
  14.             'name': None,
  15.             'sit': None,
  16.             'addr': None,
  17.             'eik': None,
  18.             'men': None,
  19.             'office_tel': None,
  20.             'email': None,
  21.             'trade_obj': None
  22.         }
  23.         self.fl_dict = {
  24.             'name': None,
  25.             'sit': None,
  26.             'office_tel': None,
  27.             'email': None,
  28.             'trade_obj': None
  29.         }
  30.  
  31.     def open_acc(self):
  32.         # Radio button  radio_n(self, x, y, text, value, command):
  33.         self.fl = self.radio_n(200, 20, "ФЛ", 1, self.choice)
  34.         self.sp = self.radio_n(250, 20, "СП", 2, self.choice)
  35.         # Create Button
  36.         btn_save = self.button_n(500, 18, ' ЗАПИШИ ', 'blue', ('Bookman Old Style Bold', 8), 2, 10, lambda: self.add_to_dict())
  37.         btn_change = self.button_n(500, 78, ' ПРОМЯНА ', 'red', ('Bookman Old Style Bold', 8), 2, 10, None)
  38.         btn_exit = self.button_n(500, 318, 'OK', 'green', ('Bookman Old Style Bold', 8), 2, 10, self.destroy)
  39.         btn_help = self.button_n(500, 378, 'Помощ', 'black', ('Bookman Old Style Bold', 8), 1, 10, None)  # h=1 , w=10
  40.  
  41.     def fl_form(self):
  42.         # Create Label
  43.         flname_l = self.label_n(20, 60, 20, 'Име')
  44.         flsit_l = self.label_n(20, 100, 20, 'Адрес')
  45.         flphone1_l = self.label_n(20, 140, 20, 'Телефон:')
  46.         flmail_l = self.label_n(20, 180, 20, 'e-mail:')
  47.         flact_place_l = self.label_n(20, 220, 20, 'Адрес за кореспонденция:')
  48.         # Create Entry
  49.         self.flname_e = self.entry_n(200, 60, 40)
  50.         self.flsit_e = self.entry_n(200, 100, 40)
  51.         self.flphone1_e = self.entry_n(200, 140, 40)
  52.         self.flmail_e = self.entry_n(200, 180, 40)
  53.         self.flact_place_e = self.entry_n(200, 220, 40)
  54.  
  55.     def sp_form(self):
  56.         # Create Label
  57.         name_l = self.label_n(20, 60, 20, 'Наименование на СП')
  58.         sit_l = self.label_n(20, 100, 20, 'Седалище')
  59.         addr_l = self.label_n(20, 140, 20, 'Адрес на управление')
  60.         e_num_l = self.label_n(20, 180, 20, 'ЕИК (Булстат)')
  61.         men_l = self.label_n(20, 220, 20, 'Представляващ СП')
  62.         phone1_l = self.label_n(20, 260, 20, 'Офис тел:')
  63.         mail_l = self.label_n(20, 300, 20, 'Счетоводство e-mail:')
  64.         act_place_l = self.label_n(20, 340, 20, 'Адрес за кореспонденция:')
  65.         # Create Entry
  66.         self.name_e = self.entry_n(200, 60, 40)
  67.         self.sit_e = self.entry_n(200, 100, 40)
  68.         self.addr_e = self.entry_n(200, 140, 40)
  69.         self.e_num_e = self.entry_n(200, 180, 40)
  70.         self.men_e = self.entry_n(200, 220, 40)
  71.         self.phone1_e = self.entry_n(200, 260, 40)
  72.         self.mail_e = self.entry_n(200, 300, 40)
  73.         self.act_place_e = self.entry_n(200, 340, 40)
  74.  
  75.  
  76.     def label_n(self, x, y, w, t):
  77.         bord_color = Frame(self, width=w, background='green')
  78.         bord_color.place(x=x, y=y)
  79.         lab = Label(bord_color, text=t, font=('Times', 10, 'italic'))
  80.         lab.pack(padx=0, pady=(0, 1))
  81.  
  82.     def entry_n(self, x, y, w):
  83.         ent = Entry(self, bd=4, width=w)
  84.         ent.place(x=x, y=y)
  85.         return ent
  86.  
  87.     def button_n(geo, x, y, t, f, fnt, h, w, comm):
  88.         btn = Button(geo, text=t, fg=f, command=comm, font=fnt, height=h, width=w)
  89.         btn.place(x=x, y=y)
  90.  
  91.     def radio_n(self, x, y, t, v, comm):
  92.         radio_butt = Radiobutton(self, text=t, variable=self.var, value=v, command=comm)
  93.         radio_butt.place(x=x, y=y)
  94.         return radio_butt
  95.  
  96.     def choice(self):
  97.         self.selection = self.var.get()
  98.         print(self.selection)
  99.         if self.selection == 1:
  100.             self.sp.configure(state='disabled')
  101.             self.fl_form()
  102.         elif self.selection == 2:
  103.             self.fl.configure(state='disabled')
  104.             self.sp_form()
  105.         return self.selection
  106.  
  107.     def add_to_dict(self):
  108.         print(self.acc_dict)
  109.         print(self.selection)
  110.         if self.selection == 1:
  111.             self.fl_dict['name'] = self.flname_e.get()
  112.             self.fl_dict['sit'] = self.flsit_e.get()
  113.             self.fl_dict['office_tel'] = self.flphone1_e.get()
  114.             self.fl_dict['email'] = self.flmail_e.get()
  115.             self.fl_dict['trade_obj'] = self.flact_place_e.get()
  116.             print(self.fl_dict)
  117.             return self.fl_dict
  118.         elif self.selection == 2:
  119.             self.acc_dict['name'] = self.name_e.get()
  120.             self.acc_dict['sit'] = self.sit_e.get()
  121.             self.acc_dict['addr'] = self.addr_e.get()
  122.             self.acc_dict['eik'] = self.e_num_e.get()
  123.             self.acc_dict['men'] = self.men_e.get()
  124.             self.acc_dict['office_tel'] = self.phone1_e.get()
  125.             self.acc_dict['email'] = self.mail_e.get()
  126.             self.acc_dict['trade_obj'] = self.act_place_e.get()
  127.             print(self.acc_dict)
  128.             return self.acc_dict
  129.  
  130.  
  131.  
  132.  
  133.  
  134. if __name__ == '__main__':
  135.  
  136.     root = Tk()
  137.     root.geometry('100x100+300+200')
  138.     root.attributes('-topmost', 'true')     # Винаги да е отгоре
  139.     ext = Button(root, text='Exit', command=root.destroy)
  140.     ext.pack(side='bottom')
  141.  
  142.     inp_win = AccountCompany()
  143.     inp_win.open_acc()
  144.  
  145.     inp_win.mainloop()
  146.  
  147.  
  148.     root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement