|
|
|
|
@@ -5,11 +5,10 @@ import tkinter as tk
|
|
|
|
|
from configparser import NoSectionError, NoOptionError
|
|
|
|
|
from tkinter import messagebox
|
|
|
|
|
from tkinter import ttk
|
|
|
|
|
import json
|
|
|
|
|
|
|
|
|
|
from config import Config
|
|
|
|
|
from connector import JSONConnector
|
|
|
|
|
from windows import SettingsWindow, EditRecord, Window, show_error
|
|
|
|
|
from windows import SettingsWindow, EditRecord, show_error
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Application:
|
|
|
|
|
@@ -19,7 +18,7 @@ class Application:
|
|
|
|
|
y_offset = 200
|
|
|
|
|
width = 1050
|
|
|
|
|
height = 700
|
|
|
|
|
VERSION = '0.6a'
|
|
|
|
|
VERSION = '0.7a'
|
|
|
|
|
title = f"Brovski Adress-Etiketten Verwaltung {VERSION}"
|
|
|
|
|
|
|
|
|
|
self.root = tk.Tk(className="BrovskiAdressEtiketten")
|
|
|
|
|
@@ -73,7 +72,7 @@ class Application:
|
|
|
|
|
tk.Button(top_frame, text="Delete", command=self.delete_record, width=button_width).pack(side=tk.LEFT)
|
|
|
|
|
tk.Button(top_frame, text="Export CSV", command=self.export_csv, width=button_width).pack(side=tk.LEFT)
|
|
|
|
|
tk.Button(top_frame, text="Toggle Aktiv", command=self.toggle_active, width=button_width).pack(side=tk.LEFT)
|
|
|
|
|
tk.Checkbutton(top_frame, text="Filter aktive", variable=self.filter_active, command=self.populate_table).pack(
|
|
|
|
|
tk.Checkbutton(top_frame, text="Filter aktiv", variable=self.filter_active, command=self.populate_table).pack(
|
|
|
|
|
side=tk.LEFT)
|
|
|
|
|
tk.Button(top_frame, text="Quit", command=self.on_close, width=button_width).pack(side=tk.RIGHT)
|
|
|
|
|
tk.Button(top_frame, text="Settings", command=self.show_settings, width=button_width).pack(side=tk.RIGHT)
|
|
|
|
|
@@ -93,8 +92,10 @@ class Application:
|
|
|
|
|
scrollbar.pack(side=tk.LEFT, fill=tk.Y)
|
|
|
|
|
|
|
|
|
|
self.table.bind("<ButtonRelease-1>", self.mouse_click)
|
|
|
|
|
self.table.bind("<Return>", self.mouse_click_double)
|
|
|
|
|
self.table.bind("<Return>", self.enter_button)
|
|
|
|
|
self.table.bind("<Double-1>", self.mouse_click_double)
|
|
|
|
|
self.root.bind("<Up>", self.focus_table)
|
|
|
|
|
self.root.bind("<Down>", self.focus_table)
|
|
|
|
|
|
|
|
|
|
# bottom status bar
|
|
|
|
|
tk.Label(bottom_frame, textvariable=self.statusbar).pack(side=tk.LEFT)
|
|
|
|
|
@@ -156,7 +157,6 @@ class Application:
|
|
|
|
|
if messagebox.askyesno(
|
|
|
|
|
"Eintrag löschen?",
|
|
|
|
|
"Willst du diesen Eintrag wirklich löschen?\nDies kann nicht rückgängig gemacht werden"):
|
|
|
|
|
print(type(self.current_record))
|
|
|
|
|
self.model.delete_by_id(self.current_record)
|
|
|
|
|
|
|
|
|
|
self.deselect_tree()
|
|
|
|
|
@@ -203,11 +203,13 @@ class Application:
|
|
|
|
|
region = self.table.identify("region", event.x, event.y)
|
|
|
|
|
match region:
|
|
|
|
|
case "cell":
|
|
|
|
|
self.click_on_cell()
|
|
|
|
|
self.edit_selected_record()
|
|
|
|
|
|
|
|
|
|
def enter_button(self, event):
|
|
|
|
|
self.edit_selected_record()
|
|
|
|
|
|
|
|
|
|
def click_on_header(self, event):
|
|
|
|
|
column = self.table.identify_column(event.x)
|
|
|
|
|
print(f"col: {column}")
|
|
|
|
|
if self.last_sort_field == column:
|
|
|
|
|
self.sort_order = False if self.sort_order else True
|
|
|
|
|
else:
|
|
|
|
|
@@ -231,7 +233,9 @@ class Application:
|
|
|
|
|
self.address_list = self.model.get_all_sorted_by(field, self.sort_order)
|
|
|
|
|
self.populate_table(reload=False)
|
|
|
|
|
|
|
|
|
|
def click_on_cell(self):
|
|
|
|
|
def edit_selected_record(self):
|
|
|
|
|
if self.table.focus() is None or self.table.focus() == "":
|
|
|
|
|
return
|
|
|
|
|
self.current_record = int(self.table.focus())
|
|
|
|
|
self.open_window_edit_records(self.current_record)
|
|
|
|
|
|
|
|
|
|
@@ -266,7 +270,6 @@ class Application:
|
|
|
|
|
# skip inactive records if filter is true
|
|
|
|
|
if self.filter_active.get() and address["aktiv"] != "x":
|
|
|
|
|
continue
|
|
|
|
|
print(address)
|
|
|
|
|
self.table.insert('', 'end', iid=address["record_id"],
|
|
|
|
|
values=(address["aktiv"], address["firma"], address["name"], address["strasse"],
|
|
|
|
|
address["plzort"])
|
|
|
|
|
@@ -314,6 +317,16 @@ class Application:
|
|
|
|
|
self.address_list.sort(key=lambda x: (x["firma"], x["name"]))
|
|
|
|
|
self.populate_table()
|
|
|
|
|
|
|
|
|
|
def focus_table(self, event):
|
|
|
|
|
first = self.table.get_children()[0]
|
|
|
|
|
last = self.table.get_children()[-1]
|
|
|
|
|
goto = last if event.keysym == "Up" else first
|
|
|
|
|
if self.table.focus() == "":
|
|
|
|
|
self.table.selection_set(goto)
|
|
|
|
|
self.table.focus(goto)
|
|
|
|
|
self.table.see(goto)
|
|
|
|
|
self.table.focus_force()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
Application()
|
|
|
|
|
|