def logout():
# Çıkışta JSON dosyalarını kaydet
save_table_data()
for row in history_frame.winfo_children():
labels = row.winfo_children()
if len(labels) > 0:
message = labels[0].cget("text")
save_history_log(message)
save_table_data()
# Pencereyi kapatma işlemi
try:
if window.winfo_exists(): # Pencere hâlâ mevcut mu kontrol et
window.destroy() # Mevcut uygulamayı kapat
except Exception as e:
print(f"Pencere kapatma sırasında hata oluştu: {e}")
# Dinamik exe_path tanımı
current_dir = os.path.dirname(sys.executable) if getattr(sys, 'frozen', False) else os.path.dirname(__file__)
# Önce "output" klasöründe arayın, bulamazsa ana dizinde arayın
exe_path = os.path.join(current_dir, "output", "login.exe") if os.name == 'nt' else os.path.join(current_dir, "output", "login.py")
if not os.path.exists(exe_path):
exe_path = os.path.join(current_dir, "login.exe") if os.name == 'nt' else os.path.join(current_dir, "login.py")
# Dosyanın mevcut olup olmadığını kontrol edin
if os.path.exists(exe_path):
try:
if os.name == 'nt': # Windows
subprocess.call([exe_path], creationflags=subprocess.CREATE_NEW_CONSOLE)
else: # MacOS veya Linux
subprocess.call(["python3", exe_path]) # Yeni bir terminalde başlat
except Exception as e:
print(f"Yeniden başlatma sırasında hata oluştu: {e}")
else:
print(f"Yeniden başlatma sırasında hata oluştu: {exe_path} dosyası bulunamadı.")
sys.exit(0)