Compare commits
3 Commits
307057a387
...
3fd0147158
| Author | SHA1 | Date | |
|---|---|---|---|
| 3fd0147158 | |||
| aec7770e74 | |||
| d16aefe20f |
@@ -42,6 +42,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",
|
||||||
@@ -50,8 +55,15 @@ 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)
|
||||||
@@ -60,9 +72,7 @@ class Application:
|
|||||||
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")
|
||||||
@@ -80,6 +90,9 @@ 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.root.mainloop()
|
self.root.mainloop()
|
||||||
@@ -258,6 +271,7 @@ class Application:
|
|||||||
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):
|
||||||
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()
|
||||||
@@ -265,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():
|
||||||
@@ -283,6 +298,18 @@ 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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user