Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- class InputCompany(Toplevel):
- def __init__(self):
- super().__init__()
- self.title('Данни за предприятието')
- self.geometry('700x500+600+200')
- self.attributes('-topmost', 'true')
- self.hw = 500
- self.next_tb_y = 420
- self.dds = StringVar()
- self.test = True # ВЕДНЪЖ ЗАПИСАНО ЕИК НОМЕРА НЕ ТРЯБВА ДА МОЖЕ ДА СЕ СМЕНЯ !!!
- self.company_dict = {
- 'name': None,
- 'sit': None,
- 'addr': None,
- 'eik': None,
- 'men': None,
- 'code_act': None,
- 'dds': None,
- 'office_tel': None,
- 'acc_tel': None,
- 'email': None,
- 'trade_obj': None
- }
- #self.open_comp()
- def open_comp(self):
- # Create Label
- name_l = self.label_n(20, 20, 20, 'Наименование')
- sit_l = self.label_n(20, 60, 20, 'Седалище')
- addr_l = self.label_n(20, 100, 20, 'Адрес на управление')
- e_num_l = self.label_n(20, 140, 20, 'ЕИК (Булстат)')
- men_l = self.label_n(20, 180, 20, 'Ръководител')
- act_num_l = self.label_n(20, 220, 20, 'Код на дейността')
- dds_l = self.label_n(20, 260, 20, 'Рег. ЗДДС')
- phone1_l = self.label_n(20, 300, 20, 'Офис тел:')
- phone2_l = self.label_n(20, 340, 20, 'Счетоводство тел:')
- mail_l = self.label_n(20, 380, 20, 'Счетоводство e-mail:')
- act_place_l = self.label_n(20, 420, 20, 'Търговски обект:')
- # Create Entry
- self.name_e = self.entry_n(200, 20, 40)
- self.sit_e = self.entry_n(200, 60, 40)
- self.addr_e = self.entry_n(200, 100, 40)
- self.e_num_e = self.entry_n(200, 140, 40)
- self.men_e = self.entry_n(200, 180, 40)
- self.act_num_e = self.entry_n(200, 220, 40)
- self.dds_e = self.entry_n(200, 260, 40)
- self.phone1_e = self.entry_n(200, 300, 40)
- self.phone2_e = self.entry_n(200, 340, 40)
- self.mail_e = self.entry_n(200, 380, 40)
- #act_place_e = self.entry_n(200, 420, 40)
- # Create Check_box
- dds_ch = self.check_b(150, 260, '')
- # Create Text box
- self.txt_b = self.text_n(200, 420, 2, 35, ('Times', 10, 'italic'))
- # Create Button
- btn_plus = self.button_n(150, 420, '+', 'red', ('Times', 10, 'bold'), 1, 3, lambda: self.resize_win())
- 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 resize_win(self):
- self.hw += 60
- self.next_tb_y += 50
- self.wm_geometry(f'700x{self.hw}')
- # Create Text box
- txt_b = self.text_n(200, self.next_tb_y, 2, 35, ('Times', 10, 'italic'))
- 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 check_b(self, x, y, t):
- __cb = IntVar()
- check = Checkbutton(self, text=t, onvalue=1, offvalue=0, variable=__cb, command=lambda: self.check_x(__cb))
- check.place(x=x, y=y)
- def check_x(self, __cb):
- dds = StringVar()
- eik = self.e_num_e.get()
- eik1 = eik[0:3]
- eik2 = eik[3:6]
- eik3 = eik[6:9]
- eik = f'{eik1}' + ' ' + f'{eik2}' + ' ' + f'{eik3}'
- eik_end = self.e_num_e.get()
- self.e_num_e.delete(0, END)
- self.e_num_e.insert(0, f'{eik}')
- self.e_num_e.config(state=DISABLED)
- if __cb.get() == 0:
- self.dds_e.delete(0, END)
- self.dds_e.insert(0, 'БЕЗ РЕГИСТРАЦИЯ ПО ЗДДС')
- elif __cb.get() == 1:
- self.dds_e.delete(0, END)
- if self.test:
- self.dds_e.insert(0, f'BG{eik}')
- self.test = False
- else:
- self.dds_e.insert(0, f'BG{eik_end}')
- def text_n(self, x, y, h, w, f):
- txt = Text(self, height=h, width=w, font=f, relief='sunken', borderwidth=4)
- txt.place(x=x, y=y)
- return txt
- 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 add_to_dict(self):
- pass
- self.company_dict['name'] = self.name_e.get()
- self.company_dict['sit'] = self.sit_e.get()
- self.company_dict['addr'] = self.addr_e.get()
- self.company_dict['eik'] = self.e_num_e.get()
- self.company_dict['men'] = self.men_e.get()
- self.company_dict['code_act'] = self.act_num_e.get()
- self.company_dict['dds'] = self.dds_e.get()
- self.company_dict['office_tel'] = self.phone1_e.get()
- self.company_dict['acc_tel'] = self.phone2_e.get()
- self.company_dict['email'] = self.mail_e.get()
- self.company_dict['trade_obj'] = self.txt_b.get('1.0', END)
- print(self.company_dict)
- print(self.company_dict['trade_obj'])
- return self.company_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 = InputCompany()
- inp_win.open_comp()
- inp_win.mainloop()
- #cb = IntVar()
- #open_comp(root)
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement