Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import tkinter as tk
- title = tk.Tk()
- title.title('Нематериални активи')
- title.geometry('400x200+200+150') # 1060
- title.resizable(True, True)
- title.attributes('-topmost', 'true')
- col_0 = col_1 = col_2 = col_3 = col_4 = dict
- row_0 = row_1 = row_2 = row_3 = dict
- val_0 = val_1 = val_2 = val_3 = val_4 = tk.Label()
- # col_0 col_1 col_2 col_3 col_4
- # --------------------------------------------
- # row_0: показатели | Ant_1 | Ant_2 | Ant_3 | Ant_4
- # row_1: dma | 200 | 300 | 400 | 500
- # row_2: dna | 20 | 30 | 40 | 50
- # row_3: dfa | 2 | 3 | 4 | 5
- da = {'row_0': {'col_0': {'val_0': 'Показатели'}, 'col_1': {'val_1': 'Ant_1'}, 'col_2': {'val_2': 'Ant_2'}, 'col_3': {'val_3': 'Ant_3'}, 'col_4': {'val_4': 'Ant_4'}},
- 'row_1': {'col_0': {'val_0': 'dma'}, 'col_1': {'val_1': '200'}, 'col_2': {'val_2': '300'}, 'col_3': {'val_3': '400'}, 'col_4': {'val_4': '500'}},
- 'row_2': {'col_0': {'val_0': 'dna'}, 'col_1': {'val_1': '20'}, 'col_2': {'val_2': '30'}, 'col_3': {'val_3': '40'}, 'col_4': {'val_4': '50'}},
- 'row_3': {'col_0': {'val_0': 'dfa'}, 'col_1': {'val_1': '2'}, 'col_2': {'val_2': '3'}, 'col_3': {'val_3': '4'}, 'col_4': {'val_4': '5'}}
- }
- count_row = len(da)
- count_col = len(da['row_0'])
- print('count_row: ', count_row)
- print('count_col: ', count_col)
- # print(da['row_0']['col_0']['val_0'])
- def create_label(text, row_x, col_y):
- label = tk.Label(title, text=text, font=('Times New Roman', 12, 'bold'), bg='white', height=1,
- anchor='center', fg='black', justify='center')
- label.grid(row=row_x, column=col_y, padx=(10, 10), pady=(10, 10), sticky='nswe')
- def create_table():
- row_n = 0
- for row in da: # Редове
- col_n = 0
- for column in da[row]: # Колони
- for val in da[row][column]:
- # print('text: ', da[row][column][val])
- text = da[row][column][val]
- create_label(text=text, row_x=row_n, col_y=col_n)
- col_n += 1
- row_n += 1
- create_table()
- # create_label(text=da[row][column][val])
- title.mainloop()
- # def create_label(text, row_x, col_y):
- # label = tk.Label(title, text=text, font=('Times New Roman', 12, 'bold'), bg='white', height=5,
- # anchor='center', fg='black', justify='center')
- # label.grid(row=row_x, column=col_y, padx=(10, 10), pady=(10, 10), sticky='nswe')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement