Advertisement
ALEXANDAR_GEORGIEV

open_comp

Jul 28th, 2022 (edited)
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 6.12 KB | None | 0 0
  1. from tkinter import *
  2.  
  3.  
  4. class InputCompany(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.hw = 500
  12.         self.next_tb_y = 420
  13.         self.dds = StringVar()
  14.         self.test = True # ВЕДНЪЖ ЗАПИСАНО ЕИК НОМЕРА НЕ ТРЯБВА ДА МОЖЕ ДА СЕ СМЕНЯ !!!
  15.         self.company_dict = {
  16.             'name': None,
  17.             'sit': None,
  18.             'addr': None,
  19.             'eik': None,
  20.             'men': None,
  21.             'code_act': None,
  22.             'dds': None,
  23.             'office_tel': None,
  24.             'acc_tel': None,
  25.             'email': None,
  26.             'trade_obj': None
  27.         }
  28.         #self.open_comp()
  29.  
  30.     def open_comp(self):
  31.         # Create Label
  32.         name_l = self.label_n(20, 20, 20, 'Наименование')
  33.         sit_l = self.label_n(20, 60, 20, 'Седалище')
  34.         addr_l = self.label_n(20, 100, 20, 'Адрес на управление')
  35.         e_num_l = self.label_n(20, 140, 20, 'ЕИК (Булстат)')
  36.         men_l = self.label_n(20, 180, 20, 'Ръководител')
  37.         act_num_l = self.label_n(20, 220, 20, 'Код на дейността')
  38.         dds_l = self.label_n(20, 260, 20, 'Рег. ЗДДС')
  39.         phone1_l = self.label_n(20, 300, 20, 'Офис тел:')
  40.         phone2_l = self.label_n(20, 340, 20, 'Счетоводство тел:')
  41.         mail_l = self.label_n(20, 380, 20, 'Счетоводство e-mail:')
  42.         act_place_l = self.label_n(20, 420, 20, 'Търговски обект:')
  43.         # Create Entry
  44.         self.name_e = self.entry_n(200, 20, 40)
  45.         self.sit_e = self.entry_n(200, 60, 40)
  46.         self.addr_e = self.entry_n(200, 100, 40)
  47.         self.e_num_e = self.entry_n(200, 140, 40)
  48.         self.men_e = self.entry_n(200, 180, 40)
  49.         self.act_num_e = self.entry_n(200, 220, 40)
  50.         self.dds_e = self.entry_n(200, 260, 40)
  51.         self.phone1_e = self.entry_n(200, 300, 40)
  52.         self.phone2_e = self.entry_n(200, 340, 40)
  53.         self.mail_e = self.entry_n(200, 380, 40)
  54.         #act_place_e = self.entry_n(200, 420, 40)
  55.         # Create Check_box
  56.         dds_ch = self.check_b(150, 260, '')
  57.         # Create Text box
  58.         self.txt_b = self.text_n(200, 420, 2, 35, ('Times', 10, 'italic'))
  59.         # Create Button
  60.         btn_plus = self.button_n(150, 420, '+', 'red', ('Times', 10, 'bold'), 1, 3, lambda: self.resize_win())
  61.         btn_save = self.button_n(500, 18, ' ЗАПИШИ ', 'blue', ('Bookman Old Style Bold', 8), 2, 10, lambda: self.add_to_dict())
  62.         btn_change = self.button_n(500, 78, ' ПРОМЯНА ', 'red', ('Bookman Old Style Bold', 8), 2, 10, None)
  63.         btn_exit = self.button_n(500, 318, 'OK', 'green', ('Bookman Old Style Bold', 8), 2, 10, self.destroy)
  64.         btn_help = self.button_n(500, 378, 'Помощ', 'black', ('Bookman Old Style Bold', 8), 1, 10, None)  # h=1 , w=10
  65.  
  66.  
  67.     def resize_win(self):
  68.         self.hw += 60
  69.         self.next_tb_y += 50
  70.         self.wm_geometry(f'700x{self.hw}')
  71.         # Create Text box
  72.         txt_b = self.text_n(200, self.next_tb_y, 2, 35, ('Times', 10, 'italic'))
  73.  
  74.     def label_n(self, x, y, w, t):
  75.         bord_color = Frame(self, width=w, background='green')
  76.         bord_color.place(x=x, y=y)
  77.         lab = Label(bord_color, text=t, font=('Times', 10, 'italic'))
  78.         lab.pack(padx=0, pady=(0, 1))
  79.  
  80.     def entry_n(self, x, y, w):
  81.         ent = Entry(self, bd=4, width=w)
  82.         ent.place(x=x, y=y)
  83.         return ent
  84.  
  85.     def check_b(self, x, y, t):
  86.         __cb = IntVar()
  87.         check = Checkbutton(self, text=t, onvalue=1, offvalue=0, variable=__cb, command=lambda: self.check_x(__cb))
  88.         check.place(x=x, y=y)
  89.  
  90.     def check_x(self, __cb):
  91.         dds = StringVar()
  92.         eik = self.e_num_e.get()
  93.         eik1 = eik[0:3]
  94.         eik2 = eik[3:6]
  95.         eik3 = eik[6:9]
  96.         eik = f'{eik1}' + ' ' + f'{eik2}' + ' ' + f'{eik3}'
  97.         eik_end = self.e_num_e.get()
  98.         self.e_num_e.delete(0, END)
  99.         self.e_num_e.insert(0, f'{eik}')
  100.         self.e_num_e.config(state=DISABLED)
  101.         if __cb.get() == 0:
  102.             self.dds_e.delete(0, END)
  103.             self.dds_e.insert(0, 'БЕЗ РЕГИСТРАЦИЯ ПО ЗДДС')
  104.         elif __cb.get() == 1:
  105.             self.dds_e.delete(0, END)
  106.             if self.test:
  107.                 self.dds_e.insert(0, f'BG{eik}')
  108.                 self.test = False
  109.             else:
  110.                 self.dds_e.insert(0, f'BG{eik_end}')
  111.  
  112.     def text_n(self, x, y, h, w, f):
  113.         txt = Text(self, height=h, width=w, font=f, relief='sunken', borderwidth=4)
  114.         txt.place(x=x, y=y)
  115.         return txt
  116.  
  117.     def button_n(geo, x, y, t, f, fnt, h, w, comm):
  118.         btn = Button(geo, text=t, fg=f, command=comm, font=fnt, height=h, width=w)
  119.         btn.place(x=x, y=y)
  120.  
  121.     def add_to_dict(self):
  122.         pass
  123.         self.company_dict['name'] = self.name_e.get()
  124.         self.company_dict['sit'] = self.sit_e.get()
  125.         self.company_dict['addr'] = self.addr_e.get()
  126.         self.company_dict['eik'] = self.e_num_e.get()
  127.         self.company_dict['men'] = self.men_e.get()
  128.         self.company_dict['code_act'] = self.act_num_e.get()
  129.         self.company_dict['dds'] = self.dds_e.get()
  130.         self.company_dict['office_tel'] = self.phone1_e.get()
  131.         self.company_dict['acc_tel'] = self.phone2_e.get()
  132.         self.company_dict['email'] = self.mail_e.get()
  133.         self.company_dict['trade_obj'] = self.txt_b.get('1.0', END)
  134.         print(self.company_dict)
  135.         print(self.company_dict['trade_obj'])
  136.         return self.company_dict
  137.  
  138.  
  139.  
  140.  
  141. if __name__ == '__main__':
  142.  
  143.     root = Tk()
  144.     root.geometry('100x100+300+200')
  145.     root.attributes('-topmost', 'true')     # Винаги да е отгоре
  146.     ext = Button(root, text='Exit', command=root.destroy)
  147.     ext.pack(side='bottom')
  148.  
  149.     inp_win = InputCompany()
  150.     inp_win.open_comp()
  151.  
  152.     inp_win.mainloop()
  153.  
  154.  
  155.     #cb = IntVar()
  156.     #open_comp(root)
  157.  
  158.     root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement