Compare commits
9 Commits
beta-0.2.1
...
0.2.4b
| Author | SHA1 | Date | |
|---|---|---|---|
| ce032874f1 | |||
| 55091bbb87 | |||
| 8b55f74cd5 | |||
| c0aa8bc732 | |||
| 6c7113849f | |||
| 321cbc7f89 | |||
| aa5d5e6698 | |||
| 2b55aa62f0 | |||
| cda807a467 |
13
compile.sh
13
compile.sh
@@ -4,8 +4,19 @@ set -e
|
|||||||
|
|
||||||
if [ "$VIRTUAL_ENV" == "" ]
|
if [ "$VIRTUAL_ENV" == "" ]
|
||||||
then
|
then
|
||||||
source venv/bin/activate
|
if [ ! -d "./venv/bin" ]; then
|
||||||
|
echo "venv not found, trying to create one"
|
||||||
|
python3 -m venv venv
|
||||||
|
fi
|
||||||
|
source venv/bin/activate
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ ! $(pip3 freeze | grep pyinstaller) ]];
|
||||||
|
then
|
||||||
|
echo "pyinstaller not found"
|
||||||
|
pip3 install -r requirements.txt
|
||||||
|
fi
|
||||||
|
|
||||||
version=$(cat version.txt)
|
version=$(cat version.txt)
|
||||||
echo "current version set to: $version"
|
echo "current version set to: $version"
|
||||||
new_version=""
|
new_version=""
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
Package: brovski-adressetiketten
|
Package: brovski-adressetiketten
|
||||||
Version: 0.2.1b
|
Version: 0.2.4b
|
||||||
Maintainer: Ovski
|
Maintainer: Ovski
|
||||||
Architecture: all
|
Architecture: all
|
||||||
Description: manage csv files for glables address labels
|
Description: Manage and export addresses to csv. Can be used with glabels (example included in the source).
|
||||||
|
|||||||
5
requirements.txt
Normal file
5
requirements.txt
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
altgraph==0.17.4
|
||||||
|
packaging==25.0
|
||||||
|
pyinstaller==6.16.0
|
||||||
|
pyinstaller-hooks-contrib==2025.9
|
||||||
|
setuptools==80.9.0
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import _csv
|
||||||
import csv
|
import csv
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
@@ -20,7 +21,7 @@ class Application:
|
|||||||
y_offset = 200
|
y_offset = 200
|
||||||
width = 1050
|
width = 1050
|
||||||
height = 700
|
height = 700
|
||||||
VERSION = '0.2.1b'
|
VERSION = "0.2.3b"
|
||||||
title = f"Brovski Adress-Etiketten Verwaltung {VERSION}"
|
title = f"Brovski Adress-Etiketten Verwaltung {VERSION}"
|
||||||
|
|
||||||
self.root = tk.Tk(className="BrovskiAdressEtiketten")
|
self.root = tk.Tk(className="BrovskiAdressEtiketten")
|
||||||
@@ -51,13 +52,15 @@ class Application:
|
|||||||
self.statusbar = tk.StringVar()
|
self.statusbar = tk.StringVar()
|
||||||
self.length_address_list = None
|
self.length_address_list = None
|
||||||
self.length_address_list_active = None
|
self.length_address_list_active = None
|
||||||
|
self.count_coffee = 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="Die Konfiguration ist fehlerhaft, bitte prüfe deine config.ini",
|
message_title="Fehler Konfiguration",
|
||||||
parent=self.root
|
message="Die Konfiguration ist fehlerhaft, bitte prüfe deine config.ini",
|
||||||
)
|
parent=self.root,
|
||||||
|
)
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
# frames
|
# frames
|
||||||
@@ -70,27 +73,50 @@ class Application:
|
|||||||
|
|
||||||
# top buttons
|
# 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(
|
||||||
tk.Button(top_frame, text="Delete", command=self.delete_record, width=button_width).pack(side=tk.LEFT)
|
top_frame, text="Insert", command=self.insert_record, width=button_width
|
||||||
tk.Button(top_frame, text="Export CSV", command=self.export_csv, width=button_width).pack(side=tk.LEFT)
|
).pack(side=tk.LEFT)
|
||||||
tk.Button(top_frame, text="Toggle Aktiv", command=self.toggle_active, width=button_width).pack(side=tk.LEFT)
|
tk.Button(
|
||||||
tk.Checkbutton(top_frame, text="Filter aktiv", variable=self.filter_active, command=self.populate_table).pack(
|
top_frame, text="Delete", command=self.delete_record, width=button_width
|
||||||
side=tk.LEFT)
|
).pack(side=tk.LEFT)
|
||||||
tk.Button(top_frame, text="Quit", command=self.on_close, width=button_width).pack(side=tk.RIGHT)
|
tk.Button(
|
||||||
tk.Button(top_frame, text="Settings", command=self.show_settings, width=button_width).pack(side=tk.RIGHT)
|
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 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)
|
||||||
|
|
||||||
# table content
|
# table content
|
||||||
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", "5"),
|
self.table = ttk.Treeview(
|
||||||
show="headings")
|
data_frame,
|
||||||
|
yscrollcommand=scrollbar.set,
|
||||||
|
columns=("0", "1", "2", "3", "4", "5"),
|
||||||
|
show="headings",
|
||||||
|
)
|
||||||
scrollbar.config(command=self.table.yview)
|
scrollbar.config(command=self.table.yview)
|
||||||
self.table.heading('0', text="Aktiv")
|
self.table.heading("0", text="Aktiv")
|
||||||
self.table.column('0', anchor=tk.CENTER, width=0)
|
self.table.column("0", anchor=tk.CENTER, width=0)
|
||||||
self.table.heading('1', text="Firma")
|
self.table.heading("1", text="Firma")
|
||||||
self.table.heading('2', text="Name")
|
self.table.heading("2", text="Name")
|
||||||
self.table.heading('3', text="Strasse")
|
self.table.heading("3", text="Strasse")
|
||||||
self.table.heading('4', text="Plz/Ort")
|
self.table.heading("4", text="Plz/Ort")
|
||||||
self.table.heading('5', text="Anzahl")
|
self.table.heading("5", text="Anzahl")
|
||||||
self.table.pack(side=tk.LEFT, fill=tk.BOTH, expand=True)
|
self.table.pack(side=tk.LEFT, fill=tk.BOTH, expand=True)
|
||||||
scrollbar.pack(side=tk.LEFT, fill=tk.Y)
|
scrollbar.pack(side=tk.LEFT, fill=tk.Y)
|
||||||
|
|
||||||
@@ -124,9 +150,11 @@ class Application:
|
|||||||
self.show_settings()
|
self.show_settings()
|
||||||
|
|
||||||
def show_config_error(self):
|
def show_config_error(self):
|
||||||
show_error(message_title="Fehlerhafte Konfiguration",
|
show_error(
|
||||||
message="Konnte benötigte Parameter in config.ini nicht finden",
|
message_title="Fehlerhafte Konfiguration",
|
||||||
parent=self.root)
|
message="Konnte benötigte Parameter in config.ini nicht finden",
|
||||||
|
parent=self.root,
|
||||||
|
)
|
||||||
|
|
||||||
def on_close(self):
|
def on_close(self):
|
||||||
self.root.destroy()
|
self.root.destroy()
|
||||||
@@ -142,7 +170,7 @@ class Application:
|
|||||||
"name": "Name",
|
"name": "Name",
|
||||||
"strasse": "Strasse",
|
"strasse": "Strasse",
|
||||||
"plzort": "Plz/Ort",
|
"plzort": "Plz/Ort",
|
||||||
"anzahl": "Anzahl"
|
"anzahl": "1",
|
||||||
}
|
}
|
||||||
self.model.create_new(values)
|
self.model.create_new(values)
|
||||||
self.populate_table()
|
self.populate_table()
|
||||||
@@ -153,14 +181,17 @@ class Application:
|
|||||||
return
|
return
|
||||||
|
|
||||||
if len(self.table.selection()) > 1:
|
if len(self.table.selection()) > 1:
|
||||||
show_error(message_title="Mehrere Adressen ausgewählt",
|
show_error(
|
||||||
message="Es können nur einzelne Adressen gelöscht werden",
|
message_title="Mehrere Adressen ausgewählt",
|
||||||
parent=self.root)
|
message="Es können nur einzelne Adressen gelöscht werden",
|
||||||
|
parent=self.root,
|
||||||
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
if messagebox.askyesno(
|
if messagebox.askyesno(
|
||||||
"Eintrag löschen?",
|
"Eintrag löschen?",
|
||||||
"Willst du diesen Eintrag wirklich löschen?\nDies kann nicht rückgängig gemacht werden"):
|
"Willst du diesen Eintrag wirklich löschen?\nDies kann nicht rückgängig gemacht werden",
|
||||||
|
):
|
||||||
self.model.delete_by_id(self.current_record)
|
self.model.delete_by_id(self.current_record)
|
||||||
|
|
||||||
self.deselect_tree()
|
self.deselect_tree()
|
||||||
@@ -210,7 +241,7 @@ class Application:
|
|||||||
self.edit_selected_record()
|
self.edit_selected_record()
|
||||||
|
|
||||||
def enter_button(self, event):
|
def enter_button(self, event):
|
||||||
self.edit_selected_record()
|
self.edit_selected_record()
|
||||||
|
|
||||||
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)
|
||||||
@@ -245,7 +276,6 @@ class Application:
|
|||||||
self.current_record = int(self.table.focus())
|
self.current_record = int(self.table.focus())
|
||||||
self.open_window_edit_records(self.current_record)
|
self.open_window_edit_records(self.current_record)
|
||||||
|
|
||||||
|
|
||||||
def export_csv(self):
|
def export_csv(self):
|
||||||
try:
|
try:
|
||||||
with open(self.csv_file, "w", encoding="utf-8") as f:
|
with open(self.csv_file, "w", encoding="utf-8") as f:
|
||||||
@@ -254,23 +284,29 @@ class Application:
|
|||||||
if address["aktiv"] != "x":
|
if address["aktiv"] != "x":
|
||||||
continue
|
continue
|
||||||
for index in range(int(address["anzahl"])):
|
for index in range(int(address["anzahl"])):
|
||||||
line = []
|
self.write_sender_to_csv(address, writer)
|
||||||
if address["firma"] != "":
|
self.write_receiver_to_csv(address, writer)
|
||||||
line.append(address["firma"])
|
|
||||||
line.append(address["name"])
|
|
||||||
line.append(address["strasse"])
|
|
||||||
line.append(address["plzort"])
|
|
||||||
writer.writerow(line)
|
|
||||||
# todo: add "absender" to config parameters
|
|
||||||
line = []
|
|
||||||
for idx in range(4):
|
|
||||||
line.append(self.config.get("absender", f"{idx}"))
|
|
||||||
writer.writerow(line)
|
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
show_error(message_title="Unexpected error",
|
show_error(
|
||||||
message=f"Could not write file {self.csv_file}",
|
message_title="Unexpected error",
|
||||||
parent=self.root
|
message=f"Could not write file {self.csv_file}",
|
||||||
)
|
parent=self.root,
|
||||||
|
)
|
||||||
|
|
||||||
|
def write_receiver_to_csv(self, address: dict, csv_writer: _csv.writer):
|
||||||
|
receiver_line = []
|
||||||
|
if address["firma"] != "":
|
||||||
|
receiver_line.append(address["firma"])
|
||||||
|
receiver_line.append(address["name"])
|
||||||
|
receiver_line.append(address["strasse"])
|
||||||
|
receiver_line.append(address["plzort"])
|
||||||
|
csv_writer.writerow(receiver_line)
|
||||||
|
|
||||||
|
def write_sender_to_csv(self, address: dict, csv_writer: _csv.writer):
|
||||||
|
sender_line = []
|
||||||
|
for idx in range(4):
|
||||||
|
sender_line.append(self.config.get("absender", f"{idx}"))
|
||||||
|
csv_writer.writerow(sender_line)
|
||||||
|
|
||||||
def populate_table(self, reload=True):
|
def populate_table(self, reload=True):
|
||||||
if reload:
|
if reload:
|
||||||
@@ -283,17 +319,26 @@ class Application:
|
|||||||
# skip inactive records if filter is true
|
# skip inactive records if filter is true
|
||||||
if self.filter_active.get() and address["aktiv"] != "x":
|
if self.filter_active.get() and address["aktiv"] != "x":
|
||||||
continue
|
continue
|
||||||
self.table.insert('', 'end', iid=address["record_id"],
|
self.table.insert(
|
||||||
values=(address["aktiv"], address["firma"], address["name"], address["strasse"],
|
"",
|
||||||
address["plzort"], address["anzahl"])
|
"end",
|
||||||
)
|
iid=address["record_id"],
|
||||||
|
values=(
|
||||||
|
address["aktiv"],
|
||||||
|
address["firma"],
|
||||||
|
address["name"],
|
||||||
|
address["strasse"],
|
||||||
|
address["plzort"],
|
||||||
|
address["anzahl"],
|
||||||
|
),
|
||||||
|
)
|
||||||
self.update_status_bar()
|
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()
|
||||||
for child in self.table.get_children():
|
for child in self.table.get_children():
|
||||||
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()
|
self.update_status_bar()
|
||||||
|
|
||||||
@@ -316,15 +361,22 @@ class Application:
|
|||||||
|
|
||||||
def update_status_bar(self):
|
def update_status_bar(self):
|
||||||
self._count_address_records()
|
self._count_address_records()
|
||||||
self.statusbar.set(f"Adressen: {self.length_address_list} | Aktive Adressen: {self.length_address_list_active}")
|
self.statusbar.set(
|
||||||
|
f"Adressen: {self.length_address_list} | "
|
||||||
|
f"Aktive Adressen: {self.length_address_list_active} | "
|
||||||
|
f"Total Kaffee: {self.count_coffee}"
|
||||||
|
)
|
||||||
|
|
||||||
def _count_address_records(self):
|
def _count_address_records(self):
|
||||||
self.length_address_list = len(self.address_list)
|
self.length_address_list = len(self.address_list)
|
||||||
count = 0
|
count = 0
|
||||||
|
count_coffee = 0
|
||||||
for address in self.address_list:
|
for address in self.address_list:
|
||||||
if address["aktiv"] == "x":
|
if address["aktiv"] == "x":
|
||||||
count += 1
|
count += 1
|
||||||
|
count_coffee += int(address["anzahl"])
|
||||||
self.length_address_list_active = count
|
self.length_address_list_active = count
|
||||||
|
self.count_coffee = count_coffee
|
||||||
|
|
||||||
def first_sort_after_start(self):
|
def first_sort_after_start(self):
|
||||||
self.address_list.sort(key=lambda x: (x["firma"], x["name"]))
|
self.address_list.sort(key=lambda x: (x["firma"], x["name"]))
|
||||||
@@ -341,5 +393,5 @@ class Application:
|
|||||||
self.table.focus_force()
|
self.table.focus_force()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == "__main__":
|
||||||
Application()
|
Application()
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
0.2.1b
|
0.2.4b
|
||||||
|
|||||||
Reference in New Issue
Block a user