Files
shared_libs/mainwindow.py
2025-08-02 20:01:29 +02:00

62 lines
1.8 KiB
Python
Executable File

#!/usr/bin/python3
import tkinter as tk
import os
from tkinter import ttk
from custom_file_dialog import CustomFileDialog
class GlotzMol(tk.Tk):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.geometry('800x400')
self.title("Custom File Dialog Test")
container = ttk.Frame(self, padding=10)
container.pack(fill="x", anchor="n")
ttk.Label(container, text="Ausgewählte Datei:").grid(
row=0, column=0, sticky="w")
self.iso_path_entry = ttk.Entry(container)
self.iso_path_entry.grid(
row=1, column=0, columnspan=2, padx=(0, 10), pady=5, sticky="ew")
self.open_button = ttk.Button(
container, text="Datei auswählen...", command=self.open_custom_dialog)
self.open_button.grid(row=1, column=2, pady=5, sticky="e")
container.columnconfigure(0, weight=1)
def open_custom_dialog(self):
CustomFileDialog(self,
initial_dir=os.path.expanduser("~"),
filetypes=[("All Files", "*.*")
])
# This is the crucial part: wait for the dialog to be closed
# self.wait_window(dialog)
# Now, get the result
# selected_path = dialog.get_selected_file()
# if selected_path:
# self.iso_path_entry.delete(0, tk.END)
# self.iso_path_entry.insert(0, selected_path)
# print(f"Die ausgewählte Datei ist: {selected_path}")
# else:
# print("Keine Datei ausgewählt.")
if __name__ == "__main__":
root = GlotzMol()
theme_path = '/usr/share/TK-Themes'
style = ttk.Style(root)
root.tk.call('source', f"{theme_path}/water.tcl")
try:
root.tk.call('set_theme', 'light')
except tk.TclError:
pass
root.mainloop()