0
0 комментариев

нужно сделать функцию вывода колонок и сохранения в екселе созданных колонок.

[apcode language=»python»]

import tkinter as tk
from tkinter import ttk
  root = tk.Tk()
label1 = tk.Label(root, text="Текст ячейки").pack()
enter1 = tk.Entry(root)
enter1.pack()
label2 = tk.Label(root, text="Количество колонок").pack()
enter2 = tk.Entry(root)
enter2.pack()
label3 = tk.Label(root, text="Количество строк").pack()
enter3 = tk.Entry(root)
enter3.pack()
heading = 'Заголовок колонки'
panel_of_tasks = ttk.Treeview(root, columns=[heading], show='headings')
panel_of_tasks.heading('#1', text=heading)
  def add_line(rows, cols):
    columns = []
    for i in range(cols):
        columns.append(i)
     panel_of_tasks.config(columns=(columns))
     for i in panel_of_tasks.get_children():
        panel_of_tasks.delete(i)
      for i in range(rows):
        panel_of_tasks.insert('', tk.END, values=([enter1.get() for j in range(cols)]))
     panel_of_tasks.config(height=len(panel_of_tasks.get_children([rows][cols])))
    root.config(height=panel_of_tasks['height'])
      def delList():
        select = enter.get()
        select.reverse()
        for i in select:
            panel_of_tasks.delete(i)
      def saveList():
        f = open('list000.txt', 'w')
        f.writelines("\n".join(panel_of_tasks.get(0, END)))
        f.close()
  button1 = ttk.Button(root, text='Add cells', command=lambda: add_line(int(enter3.get()), int(enter2.get()))).pack()
button2 = ttk.Button(root, text='Delete', command=lambda: (int(delList()).pack()
    panel_of_tasks.pack()
root.mainloop()

[/apcode]


Добавить комментарий