Boromir
Uzman
- Katılım
- 27 Ağustos 2024
- Mesajlar
- 279
- Çözümler
- 6
- Beğeniler
- 136
Simdi login olduktan sonra iki tane pencere aciliyor cozemedim bunu.
Customtkinter kullaniyorum.
Customtkinter kullaniyorum.
Python:
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)
Python:
def successful_login():
try:
print("SONCALISANDIKKAT.py başlatılıyor...")
# Sabit bir yol tanımlıyoruz, DENEME dosyasının içindeki yeri belirtiyoruz
script_path = os.path.join(os.path.dirname(__file__), 'SONCALISANDIKKAT.py')
print(f"Tam dosya yolu: {script_path}")
logging.info(f"Tam dosya yolu: {script_path}")
# Dosya mevcut mu kontrol et
if os.path.exists(script_path):
print(f"{script_path} bulundu, çalıştırılıyor...")
logging.info(f"{script_path} bulundu, çalıştırılıyor...")
# Login penceresini kapatalım
window.destroy()
import SONCALISANDIKKAT
else:
raise FileNotFoundError(f"{script_path} dosyası bulunamadı!")
except Exception as e:
error_message = f"SONCALISANDIKKAT.py başlatılırken bir hata oluştu:\n{traceback.format_exc()}"
log_error(error_message) # Hata mesajını hem loga hem terminale yazdır