vertical scrollbar for table

This commit is contained in:
2025-04-18 12:03:20 +02:00
parent fb2eb44309
commit 5f568d3850

View File

@@ -9,6 +9,7 @@ from tkinter import messagebox
from tkinter import ttk
import json
class SettingsWindow(tk.Toplevel):
def __init__(self, root: tk.Tk):
super().__init__()
@@ -84,6 +85,7 @@ class SettingsWindow(tk.Toplevel):
self.root.deiconify()
self.destroy()
class Config:
parser: ConfigParser
@@ -129,13 +131,15 @@ class Application:
def __init__(self):
# tkinter settings
x_offset = 700
y_offset = 400
y_offset = 200
width = 1050
height = 1000
title = "Brovski Adress-Etiketten Verwaltung"
self.root = tk.Tk(className="BrovskiAdressEtiketten")
self.root.title(title)
self.root.protocol("WM_DELETE_WINDOW", self.on_close)
self.root.geometry(f"+{x_offset}+{y_offset}")
self.root.geometry(f"{width}x{height}+{x_offset}+{y_offset}")
self.config = Config()
self.config_good = False
@@ -194,13 +198,17 @@ class Application:
data_frame = tk.Frame(self.root, bg="teal")
data_frame.pack(side=tk.TOP, fill=tk.BOTH, expand=True)
self.table = ttk.Treeview(data_frame, columns=("0", "1", "2", "3", "4"), show="headings")
scrollbar = ttk.Scrollbar(data_frame, orient=tk.VERTICAL)
self.table = ttk.Treeview(data_frame, yscrollcommand=scrollbar.set, columns=("0", "1", "2", "3", "4"),
show="headings")
scrollbar.config(command=self.table.yview)
self.table.heading('0', text="Aktiv")
self.table.heading('1', text="Firma")
self.table.heading('2', text="Name")
self.table.heading('3', text="Strasse")
self.table.heading('4', text="Plz/Ort")
self.table.pack()
self.table.pack(side=tk.LEFT, fill=tk.BOTH, expand=True)
scrollbar.pack(side=tk.LEFT, fill=tk.Y)
self.table.bind("<ButtonRelease-1>", self.mouse_click)
@@ -220,7 +228,6 @@ class Application:
self.show_config_error()
self.show_settings()
def show_config_error(self):
if self.show_error("Fehlerhafte Konfiguration",
"Konnte benötigte Parameter in config.ini nicht finden"):
@@ -260,7 +267,6 @@ class Application:
self.clear_entry_fields()
self._save_json_file()
def clear_entry_fields(self):
entry_var_list = [self.aktiv, self.firma, self.name, self.strasse, self.plz_ort]
for entry in entry_var_list: