39 lines
1.1 KiB
Python
39 lines
1.1 KiB
Python
import subprocess
|
|
import threading
|
|
import time
|
|
import pygetwindow as gw
|
|
import sys
|
|
|
|
# Fonction pour générer des sorties normales dans le terminal actuel
|
|
def normal_output():
|
|
count = 0
|
|
while True:
|
|
print(f"Normal output line {count}")
|
|
count += 1
|
|
time.sleep(1)
|
|
|
|
if __name__ == "__main__":
|
|
# Vérifier si la sortie est bien un terminal
|
|
if not sys.stdout.isatty():
|
|
print("This script must be run in a terminal.")
|
|
sys.exit(1)
|
|
|
|
try:
|
|
# Ouvrir un nouveau terminal pour afficher la barre de statut
|
|
status_bar_process = subprocess.Popen(
|
|
["start", "cmd", "/k", "python", "status_bar.py"], shell=True
|
|
) # Utilise "start cmd /k" pour Windows
|
|
|
|
# Attendre un instant pour que la fenêtre apparaisse
|
|
time.sleep(1)
|
|
|
|
# Trouver la fenêtre de la barre de statut
|
|
for window in gw.getWindowsWithTitle("status_bar.py"):
|
|
window.alwaysOnTop = True # Mettre la fenêtre toujours au-dessus
|
|
|
|
# Démarrer les sorties normales dans le terminal principal
|
|
normal_output()
|
|
|
|
except KeyboardInterrupt:
|
|
print("\nExiting...")
|