|
|
|
|
@ -10,19 +10,17 @@ import winreg
|
|
|
|
|
if getattr(sys, 'frozen', False):
|
|
|
|
|
# Wenn das Skript in einer exe läuft, sind die Dateien im temporären Ordner
|
|
|
|
|
bundle_dir = sys._MEIPASS
|
|
|
|
|
pdf_export_path = os.path.join('./export.exe')
|
|
|
|
|
pdf_export_path = os.path.join('export.exe')
|
|
|
|
|
else:
|
|
|
|
|
# Wenn das Skript nicht in einer exe läuft, benutze das aktuelle Arbeitsverzeichnis
|
|
|
|
|
bundle_dir = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
|
pdf_export_path = os.path.join('./export.exe')
|
|
|
|
|
pdf_export_path = os.path.join('dist/export.exe')
|
|
|
|
|
|
|
|
|
|
print(pdf_export_path)
|
|
|
|
|
# Pfade für eingebundene Ressourcen
|
|
|
|
|
logo_path = os.path.join(bundle_dir, 'logo.png')
|
|
|
|
|
gif_path = os.path.join(bundle_dir, 'printer.gif')
|
|
|
|
|
reg_check_path = os.path.join(bundle_dir, 'reg_check.py')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
icon_path = os.path.join(bundle_dir, 'printer.ico')
|
|
|
|
|
|
|
|
|
|
class CustomerThinkerApp(ctk.CTk):
|
|
|
|
|
@ -58,26 +56,49 @@ class CustomerThinkerApp(ctk.CTk):
|
|
|
|
|
|
|
|
|
|
self.build_gui()
|
|
|
|
|
self.load_gif()
|
|
|
|
|
self.update_file_dropdown()
|
|
|
|
|
# self.update_file_dropdown()
|
|
|
|
|
|
|
|
|
|
def build_gui(self):
|
|
|
|
|
# Titel
|
|
|
|
|
self.title_label = ctk.CTkLabel(self, text="PDF Export Tool", font=ctk.CTkFont(size=24, weight="bold"))
|
|
|
|
|
self.title_label.pack(pady=20)
|
|
|
|
|
|
|
|
|
|
# Button
|
|
|
|
|
self.run_button = ctk.CTkButton(self, text="Alle Aufträge drucken", command=self.run_script)
|
|
|
|
|
self.run_button.pack(pady=10)
|
|
|
|
|
# Button Aufträge drucken
|
|
|
|
|
self.run_button = ctk.CTkButton(self, text="Alle Aufträge drucken", command=self.run_script,width=200,height=60,font=ctk.CTkFont(size=18) )
|
|
|
|
|
self.run_button.pack(pady=50)
|
|
|
|
|
|
|
|
|
|
# Auswahl: Letzte Labels oder Orders
|
|
|
|
|
self.dropdown_select = ctk.CTkComboBox(self, values=["Letzte Labels", "Letzte Orders"],
|
|
|
|
|
command=self.update_file_dropdown, width=200)
|
|
|
|
|
self.dropdown_select.set("Auswählen")
|
|
|
|
|
self.dropdown_select.pack(pady=10)
|
|
|
|
|
# self.dropdown_select = ctk.CTkComboBox(self, values=["Letzte Labels", "Letzte Orders"],
|
|
|
|
|
# command=self.update_file_dropdown, width=200)
|
|
|
|
|
# self.dropdown_select.set("Auswählen")
|
|
|
|
|
# self.dropdown_select.pack(pady=10)
|
|
|
|
|
|
|
|
|
|
# Werte-Dropdown
|
|
|
|
|
self.dropdown_values = ctk.CTkComboBox(self, values=[], command=self.file_selected, width=200)
|
|
|
|
|
self.dropdown_values.pack(pady=10)
|
|
|
|
|
# self.dropdown_values = ctk.CTkComboBox(self, values=[], command=self.file_selected, width=200)
|
|
|
|
|
# self.dropdown_values.pack(pady=10)
|
|
|
|
|
|
|
|
|
|
# Archiv Buttons
|
|
|
|
|
button_frame = ctk.CTkFrame(self, fg_color="transparent")
|
|
|
|
|
button_frame.pack(pady=0)
|
|
|
|
|
|
|
|
|
|
## Archive Label
|
|
|
|
|
self.labels_button = ctk.CTkButton(
|
|
|
|
|
button_frame,
|
|
|
|
|
text="Archiv Labels",
|
|
|
|
|
command=self.open_labels_folder,
|
|
|
|
|
width=100,
|
|
|
|
|
height=50
|
|
|
|
|
)
|
|
|
|
|
self.labels_button.pack(side="left",padx=10, pady=0)
|
|
|
|
|
|
|
|
|
|
self.paketlist_button = ctk.CTkButton(
|
|
|
|
|
button_frame,
|
|
|
|
|
text="Archiv Paketlisten",
|
|
|
|
|
command=self.open_paketlist_folder,
|
|
|
|
|
width=100,
|
|
|
|
|
height=50
|
|
|
|
|
)
|
|
|
|
|
self.paketlist_button.pack(side="right",padx=10, pady=0)
|
|
|
|
|
|
|
|
|
|
# Status
|
|
|
|
|
self.status_label = ctk.CTkLabel(self, text="", font=ctk.CTkFont(size=16))
|
|
|
|
|
@ -87,6 +108,7 @@ class CustomerThinkerApp(ctk.CTk):
|
|
|
|
|
self.status_label_logo = ctk.CTkLabel(self, text="")
|
|
|
|
|
self.status_label_logo.pack(pady=10)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Logo unten rechts
|
|
|
|
|
self.logo_image = ctk.CTkImage(Image.open(logo_path), size=(50, 50)) # Hier dein Logo
|
|
|
|
|
self.logo_label = ctk.CTkLabel(self, image=self.logo_image, text="", fg_color="transparent")
|
|
|
|
|
@ -95,6 +117,8 @@ class CustomerThinkerApp(ctk.CTk):
|
|
|
|
|
self.logo_label.bind("<Leave>", self.on_logo_leave) # Wenn die Maus das Logo verlässt
|
|
|
|
|
self.logo_label.place(x=0, y=0, anchor="se") # Vorläufige Position setzen
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Konfigurations-Button unten links
|
|
|
|
|
self.config_button = ctk.CTkButton(self, text="Konfiguration", width=100, command=self.run_reg_check)
|
|
|
|
|
self.config_button.place(x=10, y=self.winfo_height() - 10, anchor="sw")
|
|
|
|
|
@ -111,6 +135,15 @@ class CustomerThinkerApp(ctk.CTk):
|
|
|
|
|
# Konfig-Button links unten
|
|
|
|
|
self.config_button.place(x=10, y=self.winfo_height() - 10, anchor="sw")
|
|
|
|
|
|
|
|
|
|
def open_labels_folder(self):
|
|
|
|
|
folder_path = os.path.abspath("label")
|
|
|
|
|
if sys.platform == "win32":
|
|
|
|
|
os.startfile(folder_path)
|
|
|
|
|
|
|
|
|
|
def open_paketlist_folder(self):
|
|
|
|
|
folder_path = os.path.abspath("orders")
|
|
|
|
|
if sys.platform == "win32":
|
|
|
|
|
os.startfile(folder_path)
|
|
|
|
|
|
|
|
|
|
def open_link(self, event=None):
|
|
|
|
|
webbrowser.open("https://www.itdata-gera.de") # Ändere dies auf die gewünschte URL
|
|
|
|
|
@ -140,28 +173,28 @@ class CustomerThinkerApp(ctk.CTk):
|
|
|
|
|
except FileNotFoundError:
|
|
|
|
|
return []
|
|
|
|
|
|
|
|
|
|
def update_file_dropdown(self, event=None):
|
|
|
|
|
selected_option = self.dropdown_select.get()
|
|
|
|
|
directory = self.labels_dir if selected_option == "Letzte Labels" else self.orders_dir
|
|
|
|
|
files = self.load_files(directory)
|
|
|
|
|
# def update_file_dropdown(self, event=None):
|
|
|
|
|
# selected_option = self.dropdown_select.get()
|
|
|
|
|
# directory = self.labels_dir if selected_option == "Letzte Labels" else self.orders_dir
|
|
|
|
|
# files = self.load_files(directory)
|
|
|
|
|
#
|
|
|
|
|
# if files:
|
|
|
|
|
# self.dropdown_values.configure(values=files)
|
|
|
|
|
# self.dropdown_values.set(files[0])
|
|
|
|
|
# else:
|
|
|
|
|
# self.dropdown_values.configure(values=[])
|
|
|
|
|
# self.dropdown_values.set("")
|
|
|
|
|
#
|
|
|
|
|
# self.run_button.configure(text="Alle Aufträge drucken", command=self.run_script)
|
|
|
|
|
|
|
|
|
|
if files:
|
|
|
|
|
self.dropdown_values.configure(values=files)
|
|
|
|
|
self.dropdown_values.set(files[0])
|
|
|
|
|
else:
|
|
|
|
|
self.dropdown_values.configure(values=[])
|
|
|
|
|
self.dropdown_values.set("")
|
|
|
|
|
|
|
|
|
|
self.run_button.configure(text="Alle Aufträge drucken", command=self.run_script)
|
|
|
|
|
|
|
|
|
|
def file_selected(self, event=None):
|
|
|
|
|
selected_file = self.dropdown_values.get()
|
|
|
|
|
if not selected_file:
|
|
|
|
|
return
|
|
|
|
|
selected_folder = self.labels_dir if self.dropdown_select.get() == "Letzte Labels" else self.orders_dir
|
|
|
|
|
full_path = os.path.join(selected_folder, selected_file)
|
|
|
|
|
|
|
|
|
|
self.run_button.configure(text=f"{selected_file} drucken", command=lambda: self.run_single_file(full_path))
|
|
|
|
|
# def file_selected(self, event=None):
|
|
|
|
|
# selected_file = self.dropdown_values.get()
|
|
|
|
|
# if not selected_file:
|
|
|
|
|
# return
|
|
|
|
|
# selected_folder = self.labels_dir if self.dropdown_select.get() == "Letzte Labels" else self.orders_dir
|
|
|
|
|
# full_path = os.path.join(selected_folder, selected_file)
|
|
|
|
|
#
|
|
|
|
|
# self.run_button.configure(text=f"{selected_file} drucken", command=lambda: self.run_single_file(full_path))
|
|
|
|
|
|
|
|
|
|
def run_script(self):
|
|
|
|
|
print("run_script")
|
|
|
|
|
@ -182,6 +215,7 @@ class CustomerThinkerApp(ctk.CTk):
|
|
|
|
|
result = subprocess.run([self.script_path], capture_output=True, text=True)
|
|
|
|
|
if result.returncode == 0:
|
|
|
|
|
self.set_status("✅ Alle Aufträge wurden gedruckt!", "green")
|
|
|
|
|
self.stop_animation()
|
|
|
|
|
else:
|
|
|
|
|
self.set_status("❌ Fehler beim Ausführen des Skripts.", "red")
|
|
|
|
|
self.show_error(result.stderr)
|
|
|
|
|
@ -211,11 +245,13 @@ class CustomerThinkerApp(ctk.CTk):
|
|
|
|
|
self.status_label.configure(text=text, text_color=color)
|
|
|
|
|
|
|
|
|
|
def start_animation(self):
|
|
|
|
|
self.status_label_logo.pack(pady=10)
|
|
|
|
|
self.animation_running = True
|
|
|
|
|
self.animate()
|
|
|
|
|
|
|
|
|
|
def stop_animation(self):
|
|
|
|
|
self.animation_running = False
|
|
|
|
|
self.status_label_logo.pack_forget()
|
|
|
|
|
|
|
|
|
|
def animate(self):
|
|
|
|
|
if self.animation_running and self.frames:
|
|
|
|
|
|