practical_work - директория
Часть кода
главный виджет main.py
import tkinter as tk
from tkinter import ttk
from practical_work import workers
class Main(tk.Frame):
def __init__(self, root):
super().__init__(root)
self.init_main()
def init_main(self):
toolbar = tk.Frame(bg='#d7d8e0', bd=2)
toolbar.pack(side=tk.TOP, fill=tk.X)
btn_workers = tk.Button(toolbar, text='test', bg='#d7d8e0', bd=0, image=self.add_img,
compound=tk.TOP, command=workers)
btn_workers.pack(side=tk.RIGHT)
if __name__ == "__main__":
root = tk.Tk()
app = Main(root)
app.pack()
root.title("v_1")
root.geometry("750x500+300+200")
root.resizable(True, True)
root.mainloop()
Часть кода
импортируемый виджет workers.py
import tkinter as tk
from tkinter import ttk
class Workers(tk.Frame):
def __init__(self, root):
super().__init__(root)
self.init_workers()
def init_workers(self):
self.tree.column('ID', width=30, anchor=tk.CENTER)
self.tree.column('name', width=150, anchor=tk.CENTER)
self.tree.column('salary', width=150, anchor=tk.CENTER)
self.tree.heading('ID', text='ID')
self.tree.heading('name', text='name')
self.tree.heading('salary', text='salary')
self.tree.pack()
root = tk.Tk()
app = Workers(root)
app.pack()
root.title("Сотрудники")
root.geometry("750x500+300+200")
root.resizable(True, True)
root.mainloop()