WIP: Add new field e-mail
This commit is contained in:
@@ -106,7 +106,7 @@ class Application:
|
||||
self.table = ttk.Treeview(
|
||||
data_frame,
|
||||
yscrollcommand=scrollbar.set,
|
||||
columns=("0", "1", "2", "3", "4", "5"),
|
||||
columns=("0", "1", "2", "3", "4", "5", "6"),
|
||||
show="headings",
|
||||
)
|
||||
scrollbar.config(command=self.table.yview)
|
||||
@@ -116,7 +116,8 @@ 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.heading("5", text="E-Mail")
|
||||
self.table.heading("6", text="Anzahl")
|
||||
self.table.pack(side=tk.LEFT, fill=tk.BOTH, expand=True)
|
||||
scrollbar.pack(side=tk.LEFT, fill=tk.Y)
|
||||
|
||||
@@ -170,6 +171,7 @@ class Application:
|
||||
"name": "Name",
|
||||
"strasse": "Strasse",
|
||||
"plzort": "Plz/Ort",
|
||||
"email": "E-Mail",
|
||||
"anzahl": "1",
|
||||
}
|
||||
self.model.create_new(values)
|
||||
@@ -263,6 +265,8 @@ class Application:
|
||||
case "#5":
|
||||
field = "plzort"
|
||||
case "#6":
|
||||
field = "email"
|
||||
case "#7":
|
||||
field = "anzahl"
|
||||
case _:
|
||||
field = "name"
|
||||
@@ -319,6 +323,7 @@ class Application:
|
||||
# skip inactive records if filter is true
|
||||
if self.filter_active.get() and address["aktiv"] != "x":
|
||||
continue
|
||||
|
||||
self.table.insert(
|
||||
"",
|
||||
"end",
|
||||
@@ -329,6 +334,7 @@ class Application:
|
||||
address["name"],
|
||||
address["strasse"],
|
||||
address["plzort"],
|
||||
address["email"],
|
||||
address["anzahl"],
|
||||
),
|
||||
)
|
||||
|
||||
@@ -43,7 +43,21 @@ class JSONConnector(Connector):
|
||||
def get_all(self) -> list:
|
||||
try:
|
||||
with open(self.json_file, "r") as f:
|
||||
return json.load(f)
|
||||
data = json.load(f)
|
||||
fields = [
|
||||
"aktiv",
|
||||
"firma",
|
||||
"name",
|
||||
"strasse",
|
||||
"plzort",
|
||||
"email",
|
||||
"anzahl",
|
||||
]
|
||||
for record in data:
|
||||
for field in fields:
|
||||
if field not in record.keys():
|
||||
record[field] = ""
|
||||
return data
|
||||
except FileNotFoundError:
|
||||
return []
|
||||
|
||||
|
||||
@@ -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.email = tk.StringVar(value=record.get("email"))
|
||||
self.anzahl = tk.StringVar(value=record.get("anzahl"))
|
||||
|
||||
edit_frame = tk.Frame(self)
|
||||
@@ -57,7 +58,8 @@ 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)
|
||||
tk.Label(edit_frame, text="E-Mail").grid(row=0, column=5)
|
||||
tk.Label(edit_frame, text="Anzahl").grid(row=0, column=6)
|
||||
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)
|
||||
@@ -68,8 +70,10 @@ 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_email= tk.Entry(edit_frame, textvariable=self.email)
|
||||
edit_email.grid(row=1, column=5)
|
||||
edit_anzahl = tk.Entry(edit_frame, textvariable=self.anzahl)
|
||||
edit_anzahl.grid(row=1, column=5)
|
||||
edit_anzahl.grid(row=1, column=6)
|
||||
|
||||
button_frame = tk.Frame(self)
|
||||
button_frame.pack(side=tk.TOP, pady=10)
|
||||
@@ -84,6 +88,7 @@ class EditRecord(Window):
|
||||
"name": self.name.get(),
|
||||
"strasse": self.strasse.get(),
|
||||
"plzort": self.plz_ort.get(),
|
||||
"email": self.email.get(),
|
||||
"anzahl": self.anzahl.get(),
|
||||
}
|
||||
self.model.update_record(new_record)
|
||||
|
||||
Reference in New Issue
Block a user