Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import tksheet as table
- import tkinter as tk
- from tksheet import theme_light_blue
- def insert_row():
- count_rows = sheet.get_total_rows()
- sheet.insert_row(["Nowiq red"], idx=(count_rows - 4))
- print(count_rows)
- def delete_row():
- count_rows = sheet.get_total_rows()
- sheet.delete_row(idx=(count_rows - 5))
- def save_b():
- quit()
- top = tk.Tk()
- top.geometry("760x440") # 640x440
- top.title("Пътен лист")
- # outline_thickness: int = 0,
- # outline_color: str = theme_light_blue["outline_color"],
- # column_drag_and_drop_perform: bool = True,
- # row_drag_and_drop_perform: bool = True,
- # empty_horizontal: int = 150,
- # empty_vertical: int = 100,
- # selected_rows_to_end_of_window: bool = False,
- # horizontal_grid_to_end_of_window: bool = False,
- # vertical_grid_to_end_of_window: bool = False,
- # show_vertical_grid: bool = True,
- # show_horizontal_grid: bool = True,
- sheet = table.Sheet(top, width=640, height=360, outline_thickness = 2, )
- sheet.grid()
- save_b = tk.Button(top, text="ЗАПИС", fg="blue", font=("Bookman Old Style Bold", 8), command=save_b)
- save_b.grid(row=1, column=0, pady=20)
- insert_row_b = tk.Button(top, text="ВМЪКНИ РЕД", command=insert_row)
- insert_row_b.grid(row=1, column=1, pady=20, padx=20)
- delete_row_b = tk.Button(top, text="ИЗТРИЙ РЕД", command=delete_row)
- delete_row_b.grid(row=0, column=1, pady=20, padx=20)
- # sheet.set_sheet_data([[f"{ri+cj}" for cj in range(7)] for ri in range(10)]) # Попълва данните
- # sheet.set_sheet_data([[f"" for cj in range(7)] for ri in range(10)]) # Попълва данните
- sheet.set_sheet_data([[" ", " ", " ", " ", " ", "РВ 9499 АТ", " ", "обем:", "60 л"],
- [" ", " ", " ", " ", "Януари", "2023г", " ", "л/100км:", "5.20"],
- [" ", " ", " ", " ", " ", " ", " ", "Налично (л):", "60.00"],
- ["от дата", "до дата", "Начало км", "Край км", "Пробег", "Направление", " ", "Заредено\n(литри)", "лева"],
- [" "], [" "], [" "], ["ОБЩО:", "", "", "", "10 250"],
- [" ", " ", " ", " ", "10 000", "км направление", " ", "Разход (л):", "29.95"],
- [" ", " ", " ", " ", "250", "км лични нужди", " ", "Рх (лева):", "59.90"] ,
- [" ", " ", " ", " ", " ", " ", " ", "Налично (л):", "86.46"], ] ) # Попълва данните
- # sheet.headers(["Начална\nдата", "Крайна\nдата", "Начален\nкилометраж", "Краен\nкилометраж", "Изминати км", "Направление"])
- sheet.set_height_of_header_to_text()
- sheet.set_column_widths()
- sheet.set_all_cell_sizes_to_text()
- # sheet.highlight_rows(rows=3, bg="#e4e8f0")
- # sheet.highlight_rows(rows=7, bg="#e4e8f0")
- # sheet.highlight_cells(row=[0], column=0, cells=[[1, 1], [2, 4]], bg="#c3f760", )
- sheet.highlight_cells(cells=[[3, 0], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5], [3, 7], [3, 8]], bg="#e4e8f0", )
- sheet.highlight_cells(cells=[[7, 0], [7, 1], [7, 2], [7, 3], [7, 4], [7, 5], [7, 7], [7, 8]], bg="#e4e8f0", )
- # table enable choices listed below:
- # sheet.set_cell_data(r=1, c=1, value='gggg', redraw=False)
- sheet.enable_bindings(("single_select",
- "row_select",
- "column_width_resize",
- "arrowkeys",
- "right_click_popup_menu",
- "rc_select",
- "copy",
- "cut",
- "paste",
- "delete",
- "undo", # Ctrl + Z
- "redo",
- "edit_cell"
- ))
- # sheet.disable_bindings() # Забранява цялата таблица
- # sheet.cell_edit_binding(enable=False, keys=[[4], [5]], )
- sheet.readonly_rows(rows=[0], readonly=True, redraw=True)
- sheet.readonly_rows(rows=[1], readonly=True, redraw=True)
- sheet.readonly_rows(rows=[2], readonly=True, redraw=True)
- sheet.readonly_rows(rows=[3], readonly=True, redraw=True)
- sheet.readonly_rows(rows=[7], readonly=True, redraw=True)
- sheet.readonly_rows(rows=[8], readonly=True, redraw=True)
- sheet.readonly_rows(rows=[9], readonly=True, redraw=True)
- sheet.readonly_rows(rows=[10], readonly=True, redraw=True)
- sheet.readonly_columns(columns=[4], readonly=True, redraw=True)
- # sheet.readonly_columns(columns=[5], readonly=True, redraw=True)
- sheet.readonly_columns(columns=[6], readonly=True, redraw=True)
- test_list = ["избери !", "Обект Асеновград", "Обект Пловдив", "Обект Брацигово", "Доставчици", "Клиенти", "Нов шанс ЕООД"]
- sheet.dropdown_cell(4, 5, test_list)
- top.mainloop()
Add Comment
Please, Sign In to add comment