13 Commits

Author SHA1 Message Date
bbdbaadb92 filtering inactive records 2025-04-27 12:22:25 +02:00
ad66988e09 sorting of columns was not nice, should be better now 2025-04-27 11:54:32 +02:00
3fd0147158 implemented status bar covering #8 2025-04-27 00:33:10 +02:00
aec7770e74 added statusbar with stringvar 2025-04-27 00:24:30 +02:00
d16aefe20f refactoring 2025-04-27 00:21:12 +02:00
307057a387 0.6a release 2025-04-26 23:41:57 +02:00
4917e5e9bd added version number to compile script 2025-04-26 23:40:20 +02:00
3f6b22abc8 added version number to compile script 2025-04-26 23:40:13 +02:00
6785a8f46d icon png version 2025-04-26 23:09:21 +02:00
dd51921784 Merge branch 'detached' with bugfix #5 2025-04-26 22:55:21 +02:00
15dc182a37 bugfix #5 final and tested 2025-04-26 22:47:03 +02:00
057e0a02de #5 new fix 2025-04-26 13:27:45 +02:00
6c8ce7b208 bugfix #5 2025-04-26 13:03:15 +02:00
5 changed files with 69 additions and 28 deletions

View File

@@ -3,6 +3,16 @@ if [ $VIRTUAL_ENV=="" ]
then then
source venv/bin/activate source venv/bin/activate
fi fi
version=$(cat version.txt)
echo "current version set to: $version"
new_version=""
read -r -p "Enter new version or empty to keep the current: " new_version
if [ "$new_version" != "" ]
then
echo "$new_version" | tee version.txt
fi
sed -i "s/VERSION = '[0-9]\.[0-9]\w'/VERSION = '$(cat version.txt)'/g" src/brovski-adress-etiketten-verwaltung.py
sed -i "s/Version: [0-9]\.[0-9]\w/Version: $(cat version.txt)/g" deb-package/brovski-adressetiketten/DEBIAN/control
pyinstaller --clean --onefile src/brovski-adress-etiketten-verwaltung.py pyinstaller --clean --onefile src/brovski-adress-etiketten-verwaltung.py
cp dist/brovski-adress-etiketten-verwaltung deb-package/brovski-adressetiketten/usr/local/bin/brovski-adressetiketten cp dist/brovski-adress-etiketten-verwaltung deb-package/brovski-adressetiketten/usr/local/bin/brovski-adressetiketten

View File

@@ -1,5 +1,5 @@
Package: brovski-adressetiketten Package: brovski-adressetiketten
Version: 0.4a Version: 0.6a
Maintainer: Ovski Maintainer: Ovski
Architecture: all Architecture: all
Description: manage csv files for glables address labels Description: manage csv files for glables address labels

Binary file not shown.

After

Width:  |  Height:  |  Size: 89 KiB

View File

@@ -18,7 +18,8 @@ class Application:
y_offset = 200 y_offset = 200
width = 1050 width = 1050
height = 700 height = 700
title = "Brovski Adress-Etiketten Verwaltung" VERSION = '0.6a'
title = f"Brovski Adress-Etiketten Verwaltung {VERSION}"
self.root = tk.Tk(className="BrovskiAdressEtiketten") self.root = tk.Tk(className="BrovskiAdressEtiketten")
self.root.title(title) self.root.title(title)
@@ -31,6 +32,8 @@ class Application:
self.address_list = [] self.address_list = []
self.current_record: int | None = None self.current_record: int | None = None
self.sort_order = False self.sort_order = False
self.last_sort_field = "#3"
self.filter_active = tk.BooleanVar(value=False)
# init paths to json and csv file # init paths to json and csv file
self.json_file_name = "brovski-adress-etiketten-verwaltung.json" self.json_file_name = "brovski-adress-etiketten-verwaltung.json"
@@ -41,6 +44,11 @@ class Application:
self.json_file = os.path.join(self.json_path, self.json_file_name) self.json_file = os.path.join(self.json_path, self.json_file_name)
self.csv_file = os.path.join(self.csv_path, self.csv_file_name) self.csv_file = os.path.join(self.csv_path, self.csv_file_name)
# status bar content
self.statusbar = tk.StringVar()
self.length_address_list = None
self.length_address_list_active = None
# leave application if settings are bad # leave application if settings are bad
if not self.config_good: if not self.config_good:
show_error(message_title="Fehler Konfiguration", show_error(message_title="Fehler Konfiguration",
@@ -49,19 +57,25 @@ class Application:
) )
sys.exit() sys.exit()
# frames
top_frame = tk.Frame(self.root) top_frame = tk.Frame(self.root)
top_frame.pack(side=tk.TOP, fill=tk.X) top_frame.pack(side=tk.TOP, fill=tk.X)
data_frame = tk.Frame(self.root, bg="teal")
data_frame.pack(side=tk.TOP, fill=tk.BOTH, expand=True)
bottom_frame = tk.Frame(self.root)
bottom_frame.pack(side=tk.BOTTOM, fill=tk.X)
# top buttons
button_width = 8 button_width = 8
tk.Button(top_frame, text="Insert", command=self.insert_record, width=button_width).pack(side=tk.LEFT) tk.Button(top_frame, text="Insert", command=self.insert_record, width=button_width).pack(side=tk.LEFT)
tk.Button(top_frame, text="Delete", command=self.delete_record, width=button_width).pack(side=tk.LEFT) 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="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.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(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="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) tk.Button(top_frame, text="Settings", command=self.show_settings, width=button_width).pack(side=tk.RIGHT)
data_frame = tk.Frame(self.root, bg="teal") # table content
data_frame.pack(side=tk.TOP, fill=tk.BOTH, expand=True)
scrollbar = ttk.Scrollbar(data_frame, orient=tk.VERTICAL) scrollbar = ttk.Scrollbar(data_frame, orient=tk.VERTICAL)
self.table = ttk.Treeview(data_frame, yscrollcommand=scrollbar.set, columns=("0", "1", "2", "3", "4"), self.table = ttk.Treeview(data_frame, yscrollcommand=scrollbar.set, columns=("0", "1", "2", "3", "4"),
show="headings") show="headings")
@@ -79,8 +93,13 @@ class Application:
self.table.bind("<Return>", self.mouse_click_double) self.table.bind("<Return>", self.mouse_click_double)
self.table.bind("<Double-1>", self.mouse_click_double) self.table.bind("<Double-1>", self.mouse_click_double)
# bottom status bar
tk.Label(bottom_frame, textvariable=self.statusbar).pack(side=tk.LEFT)
self._load_json_file() self._load_json_file()
self.first_sort_after_start()
self.root.mainloop() self.root.mainloop()
def load_config(self): def load_config(self):
@@ -183,25 +202,17 @@ class Application:
def click_on_header(self, event): def click_on_header(self, event):
column = self.table.identify_column(event.x) column = self.table.identify_column(event.x)
match column: if self.last_sort_field == column:
case "#1": self.sort_order = False if self.sort_order else True
self.address_list.sort(key=lambda x: x[int(column[-1]) - 1], reverse=self.sort_order) else:
self.populate_table() self.sort_order = False
case "#2": self.last_sort_field = column
self.address_list.sort(key=lambda x: x[int(column[-1]) - 1], reverse=self.sort_order) self.address_list.sort(key=lambda x: (x[int(column[-1]) - 1]), reverse=self.sort_order)
self.populate_table()
case "#3": # special case company sort
self.address_list.sort(key=lambda x: x[int(column[-1]) - 1], reverse=self.sort_order) if column == "#2":
self.populate_table() self.address_list.sort(key=lambda x: (x[1], x[2]), reverse=self.sort_order)
case "#4": self.populate_table()
self.address_list.sort(key=lambda x: x[int(column[-1]) - 1], reverse=self.sort_order)
self.populate_table()
case "#5":
self.address_list.sort(key=lambda x: x[int(column[-1]) - 1], reverse=self.sort_order)
self.populate_table()
case _:
print(column)
self.sort_order = not self.sort_order
def click_on_cell(self): def click_on_cell(self):
self.current_record = self.table.focus() self.current_record = self.table.focus()
@@ -243,10 +254,10 @@ class Application:
for address in self.address_list: for address in self.address_list:
if address[0] != "x": if address[0] != "x":
continue continue
del address[0] if address[1] == "":
if address[0] == "": writer.writerow(address[2:])
del address[0] else:
writer.writerow(address) writer.writerow(address[1:])
except FileNotFoundError: except FileNotFoundError:
show_error(message_title="Unexpected error", show_error(message_title="Unexpected error",
message=f"Could not write file {self.csv_file}", message=f"Could not write file {self.csv_file}",
@@ -256,7 +267,11 @@ class Application:
def populate_table(self): def populate_table(self):
self.delete_all_table_items() self.delete_all_table_items()
for index, item in enumerate(self.address_list): for index, item in enumerate(self.address_list):
# skip inactive records if filter is true
if self.filter_active.get() and item[0] != "x":
continue
self.table.insert('', 'end', iid=index, values=item) self.table.insert('', 'end', iid=index, values=item)
self.update_status_bar()
def export_table_to_address_list(self): def export_table_to_address_list(self):
self.address_list.clear() self.address_list.clear()
@@ -264,6 +279,7 @@ class Application:
self.address_list.append([]) self.address_list.append([])
for value in self.table.item(child)['values']: for value in self.table.item(child)['values']:
self.address_list[-1].append(value) self.address_list[-1].append(value)
self.update_status_bar()
def delete_all_table_items(self): def delete_all_table_items(self):
for item in self.table.get_children(): for item in self.table.get_children():
@@ -282,7 +298,21 @@ class Application:
window.wait_visibility() window.wait_visibility()
window.grab_set() window.grab_set()
def update_status_bar(self):
self._count_address_records()
self.statusbar.set(f"Adressen: {self.length_address_list} | Aktive Adressen: {self.length_address_list_active}")
def _count_address_records(self):
self.length_address_list = len(self.address_list)
count = 0
for address in self.address_list:
if address[0] == "x":
count += 1
self.length_address_list_active = count
def first_sort_after_start(self):
self.address_list.sort(key=lambda x: (x[1], x[2]))
self.populate_table()
if __name__ == '__main__': if __name__ == '__main__':

1
version.txt Normal file
View File

@@ -0,0 +1 @@
0.6a