Compare commits
12 Commits
6407cf4229
...
beta-0.2.1
| Author | SHA1 | Date | |
|---|---|---|---|
| 3299584924 | |||
| 0869bb96f8 | |||
| 89a86ca271 | |||
| 6410853d3c | |||
| f993220ad6 | |||
| dac342f3ec | |||
| 61ab5a9deb | |||
| b61c52972d | |||
| c80a587cbd | |||
| 0d114a325d | |||
| 9532eb7247 | |||
| 7e9d5bec9b |
@@ -1,4 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
if [ "$VIRTUAL_ENV" == "" ]
|
||||
then
|
||||
source venv/bin/activate
|
||||
@@ -11,10 +14,11 @@ 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
|
||||
sed -i "s/VERSION = '[0-9]\.[0-9].[0-9]\w'/VERSION = '$(cat version.txt)'/g" src/brovski-adress-etiketten-verwaltung.py
|
||||
sed -i "s/Version: [0-9]\.[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
|
||||
mkdir -p deb-package/brovski-adressetiketten/usr/local/bin
|
||||
cp dist/brovski-adress-etiketten-verwaltung deb-package/brovski-adressetiketten/usr/local/bin/brovski-adressetiketten
|
||||
dpkg-deb --build deb-package/brovski-adressetiketten
|
||||
mv deb-package/brovski-adressetiketten.deb ./
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
Package: brovski-adressetiketten
|
||||
Version: 0.1.0b
|
||||
Version: 0.2.1b
|
||||
Maintainer: Ovski
|
||||
Architecture: all
|
||||
Description: manage csv files for glables address labels
|
||||
|
||||
@@ -8,17 +8,19 @@ from tkinter import ttk
|
||||
|
||||
from config import Config
|
||||
from model import Model
|
||||
from connector import JSONConnector
|
||||
from windows import SettingsWindow, EditRecord, show_error
|
||||
|
||||
|
||||
class Application:
|
||||
def __init__(self):
|
||||
os.chdir(os.getcwd())
|
||||
# tkinter settings
|
||||
x_offset = 700
|
||||
y_offset = 200
|
||||
width = 1050
|
||||
height = 700
|
||||
VERSION = '0.1.0b'
|
||||
VERSION = '0.2.1b'
|
||||
title = f"Brovski Adress-Etiketten Verwaltung {VERSION}"
|
||||
|
||||
self.root = tk.Tk(className="BrovskiAdressEtiketten")
|
||||
@@ -36,7 +38,7 @@ class Application:
|
||||
self.filter_active = tk.BooleanVar(value=False)
|
||||
|
||||
# model connector
|
||||
self.model = Model(self.config)
|
||||
self.model = Model(JSONConnector(self.config))
|
||||
|
||||
# init paths to json and csv file
|
||||
self.json_file_name = "brovski-adress-etiketten-verwaltung.json"
|
||||
@@ -79,7 +81,7 @@ class Application:
|
||||
|
||||
# table content
|
||||
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", "5"),
|
||||
show="headings")
|
||||
scrollbar.config(command=self.table.yview)
|
||||
self.table.heading('0', text="Aktiv")
|
||||
@@ -88,6 +90,7 @@ class Application:
|
||||
self.table.heading('2', text="Name")
|
||||
self.table.heading('3', text="Strasse")
|
||||
self.table.heading('4', text="Plz/Ort")
|
||||
self.table.heading('5', text="Anzahl")
|
||||
self.table.pack(side=tk.LEFT, fill=tk.BOTH, expand=True)
|
||||
scrollbar.pack(side=tk.LEFT, fill=tk.Y)
|
||||
|
||||
@@ -138,7 +141,8 @@ class Application:
|
||||
"firma": "Firma",
|
||||
"name": "Name",
|
||||
"strasse": "Strasse",
|
||||
"plzort": "Plz/Ort"
|
||||
"plzort": "Plz/Ort",
|
||||
"anzahl": "Anzahl"
|
||||
}
|
||||
self.model.create_new(values)
|
||||
self.populate_table()
|
||||
@@ -227,6 +231,8 @@ class Application:
|
||||
field = "strasse"
|
||||
case "#5":
|
||||
field = "plzort"
|
||||
case "#6":
|
||||
field = "anzahl"
|
||||
case _:
|
||||
field = "name"
|
||||
|
||||
@@ -247,6 +253,7 @@ class Application:
|
||||
for address in self.address_list:
|
||||
if address["aktiv"] != "x":
|
||||
continue
|
||||
for index in range(int(address["anzahl"])):
|
||||
line = []
|
||||
if address["firma"] != "":
|
||||
line.append(address["firma"])
|
||||
@@ -254,6 +261,11 @@ class Application:
|
||||
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:
|
||||
show_error(message_title="Unexpected error",
|
||||
message=f"Could not write file {self.csv_file}",
|
||||
@@ -273,7 +285,7 @@ class Application:
|
||||
continue
|
||||
self.table.insert('', 'end', iid=address["record_id"],
|
||||
values=(address["aktiv"], address["firma"], address["name"], address["strasse"],
|
||||
address["plzort"])
|
||||
address["plzort"], address["anzahl"])
|
||||
)
|
||||
self.update_status_bar()
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ import json
|
||||
import os
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
import config
|
||||
from config import Config
|
||||
|
||||
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
from config import Config
|
||||
from connector import JSONConnector
|
||||
from connector import Connector
|
||||
|
||||
|
||||
class Model:
|
||||
def __init__(self, config: Config):
|
||||
self.connector = JSONConnector(config)
|
||||
self.config = config
|
||||
def __init__(self, connector: Connector):
|
||||
self.connector = connector
|
||||
|
||||
def get_all(self):
|
||||
return self.connector.get_all()
|
||||
|
||||
@@ -48,6 +48,7 @@ class EditRecord(Window):
|
||||
self.name = tk.StringVar(value=record.get("name"))
|
||||
self.strasse = tk.StringVar(value=record.get("strasse"))
|
||||
self.plz_ort = tk.StringVar(value=record.get("plzort"))
|
||||
self.anzahl = tk.StringVar(value=record.get("anzahl"))
|
||||
|
||||
edit_frame = tk.Frame(self)
|
||||
edit_frame.pack(side=tk.TOP, fill=tk.X, pady=20, padx=20)
|
||||
@@ -56,6 +57,7 @@ class EditRecord(Window):
|
||||
tk.Label(edit_frame, text="Name").grid(row=0, column=2)
|
||||
tk.Label(edit_frame, text="Strasse").grid(row=0, column=3)
|
||||
tk.Label(edit_frame, text="Plz/Ort").grid(row=0, column=4)
|
||||
tk.Label(edit_frame, text="Anzahl").grid(row=0, column=5)
|
||||
edit_aktiv = tk.Checkbutton(edit_frame, variable=self.aktiv, onvalue="x", offvalue="")
|
||||
edit_aktiv.grid(row=1, column=0)
|
||||
edit_firma = tk.Entry(edit_frame, textvariable=self.firma)
|
||||
@@ -66,6 +68,8 @@ class EditRecord(Window):
|
||||
edit_strasse.grid(row=1, column=3)
|
||||
edit_plz_ort = tk.Entry(edit_frame, textvariable=self.plz_ort)
|
||||
edit_plz_ort.grid(row=1, column=4)
|
||||
edit_anzahl = tk.Entry(edit_frame, textvariable=self.anzahl)
|
||||
edit_anzahl.grid(row=1, column=5)
|
||||
|
||||
button_frame = tk.Frame(self)
|
||||
button_frame.pack(side=tk.TOP, pady=10)
|
||||
@@ -80,6 +84,7 @@ class EditRecord(Window):
|
||||
"name": self.name.get(),
|
||||
"strasse": self.strasse.get(),
|
||||
"plzort": self.plz_ort.get(),
|
||||
"anzahl": self.anzahl.get(),
|
||||
}
|
||||
self.model.update_record(new_record)
|
||||
self.close_window()
|
||||
@@ -88,18 +93,23 @@ class EditRecord(Window):
|
||||
class SettingsWindow(Window):
|
||||
def __init__(self, parent, root: tk.Tk, config: Config):
|
||||
super().__init__(parent, root)
|
||||
self.geometry(f"500x330+{self.root.winfo_x() + 20}+{self.root.winfo_y() + 20}")
|
||||
width = 500
|
||||
height = 630
|
||||
self.geometry(f"{width}x{height}+{self.root.winfo_x() + 20}+{self.root.winfo_y() + 20}")
|
||||
self.config = config
|
||||
self.json_file = tk.StringVar()
|
||||
self.csv_file = tk.StringVar()
|
||||
self.absender_line = [tk.StringVar() for idx in range(4)]
|
||||
|
||||
title = font.Font(family='Ubuntu Mono', size=20, weight=font.BOLD)
|
||||
tk.Label(self, text="Einstellungen", font=title).pack(pady=20)
|
||||
|
||||
path_frame = tk.Frame(self)
|
||||
path_frame.pack(pady=(10, 40))
|
||||
|
||||
tk.Label(path_frame, text="Datenpfad JSON Datei").grid(row=0, column=0)
|
||||
tk.Label(self, text="Datenpfad JSON Datei").pack()
|
||||
|
||||
path_frame = tk.Frame(self)
|
||||
path_frame.pack(pady=(10, 10))
|
||||
|
||||
tk.Entry(path_frame, textvariable=self.json_file, width=50).grid(row=1, column=0)
|
||||
tk.Button(path_frame, text="Pfad", command=lambda: self.set_json_path(self.json_file.get())).grid(row=1,
|
||||
column=1)
|
||||
@@ -108,6 +118,13 @@ class SettingsWindow(Window):
|
||||
tk.Entry(path_frame, textvariable=self.csv_file, width=50).grid(row=3, column=0)
|
||||
tk.Button(path_frame, text="Pfad", command=lambda: self.set_csv_path(self.csv_file.get())).grid(row=3, column=1)
|
||||
|
||||
absender_frame = tk.Frame(self)
|
||||
absender_frame.pack(pady=(10, 40))
|
||||
|
||||
tk.Label(absender_frame, text="Absender").pack(side=tk.TOP)
|
||||
for idx in range(4):
|
||||
tk.Entry(absender_frame, textvariable=self.absender_line[idx], width=50).pack(side=tk.TOP)
|
||||
|
||||
bottom_frame = tk.Frame(self)
|
||||
bottom_frame.pack()
|
||||
tk.Button(bottom_frame, text="Ok", command=self.ok).pack(side=tk.LEFT)
|
||||
@@ -144,6 +161,15 @@ class SettingsWindow(Window):
|
||||
except NoOptionError:
|
||||
self.config.set("csv", "path", "")
|
||||
|
||||
for idx in range(4):
|
||||
try:
|
||||
self.absender_line[idx].set(self.config.get(f"absender", f"{idx}"))
|
||||
except NoSectionError:
|
||||
self.config.add_section(f"line")
|
||||
self.config.set("line", f"{idx}", "")
|
||||
except NoOptionError:
|
||||
self.config.set("line", f"{idx}", "")
|
||||
|
||||
def ok(self):
|
||||
if self.json_file.get() == "" or self.csv_file.get() == "":
|
||||
show_error(message_title="Fehlerhafte Konfiguration",
|
||||
@@ -152,6 +178,8 @@ class SettingsWindow(Window):
|
||||
return
|
||||
self.config.set("json", "path", self.json_file.get())
|
||||
self.config.set("csv", "path", self.csv_file.get())
|
||||
for i in range(4):
|
||||
self.config.set("absender", f"{i}", f"{self.absender_line[i].get()}")
|
||||
self.close_window()
|
||||
|
||||
def cancel(self):
|
||||
|
||||
@@ -1 +1 @@
|
||||
0.1.0b
|
||||
0.2.1b
|
||||
|
||||
Reference in New Issue
Block a user