158 lines
5.0 KiB
Python
158 lines
5.0 KiB
Python
"""
|
|
Exemple d'intégration du tableau de bord résumé avec MinimalGUI
|
|
"""
|
|
|
|
from PyQt5.QtWidgets import QMainWindow, QPushButton, QVBoxLayout, QWidget
|
|
from PyQt5.QtCore import Qt
|
|
from PyQt5.QtGui import QFont
|
|
|
|
from .summary_dashboard import SummaryDashboard
|
|
|
|
|
|
class EnhancedMinimalGUI(QMainWindow):
|
|
"""
|
|
Exemple d'extension de MinimalGUI avec bouton tableau de bord
|
|
"""
|
|
|
|
def __init__(self, orchestrator=None):
|
|
super().__init__()
|
|
self.orchestrator = orchestrator
|
|
self.dashboard = None
|
|
|
|
self.init_ui()
|
|
|
|
def init_ui(self):
|
|
"""Initialiser l'interface avec bouton tableau de bord"""
|
|
self.setWindowTitle("RPA Vision V2 - Enhanced")
|
|
self.setGeometry(100, 100, 400, 250)
|
|
|
|
central_widget = QWidget()
|
|
self.setCentralWidget(central_widget)
|
|
|
|
layout = QVBoxLayout()
|
|
central_widget.setLayout(layout)
|
|
|
|
# Bouton pour ouvrir le tableau de bord
|
|
dashboard_button = QPushButton("📊 Ouvrir Tableau de Bord")
|
|
dashboard_button.setFont(QFont("Arial", 12))
|
|
dashboard_button.setStyleSheet("""
|
|
QPushButton {
|
|
background-color: #2196F3;
|
|
color: white;
|
|
border: none;
|
|
padding: 15px 30px;
|
|
border-radius: 5px;
|
|
}
|
|
QPushButton:hover {
|
|
background-color: #1976D2;
|
|
}
|
|
""")
|
|
dashboard_button.clicked.connect(self.show_dashboard)
|
|
layout.addWidget(dashboard_button)
|
|
|
|
# Autres contrôles...
|
|
layout.addStretch()
|
|
|
|
def show_dashboard(self):
|
|
"""Afficher le tableau de bord"""
|
|
if not self.orchestrator:
|
|
print("Aucun orchestrateur disponible")
|
|
return
|
|
|
|
# Créer le tableau de bord si nécessaire
|
|
if not self.dashboard:
|
|
learning_manager = self.orchestrator.learning_manager
|
|
self.dashboard = SummaryDashboard(learning_manager, parent=self)
|
|
|
|
# Connecter au signal de sélection de tâche
|
|
self.dashboard.task_selected.connect(self.on_task_selected)
|
|
|
|
# Afficher le tableau de bord
|
|
self.dashboard.show()
|
|
self.dashboard.raise_()
|
|
self.dashboard.activateWindow()
|
|
|
|
def on_task_selected(self, task_id: str):
|
|
"""
|
|
Gestionnaire de sélection de tâche depuis le tableau de bord
|
|
|
|
Args:
|
|
task_id: ID de la tâche sélectionnée
|
|
"""
|
|
print(f"Tâche sélectionnée: {task_id}")
|
|
|
|
# Ici, on pourrait:
|
|
# - Charger la tâche dans l'orchestrateur
|
|
# - Afficher plus de détails
|
|
# - Permettre la modification de la tâche
|
|
# etc.
|
|
|
|
|
|
# Exemple d'utilisation avec l'orchestrateur
|
|
def example_usage():
|
|
"""Exemple d'utilisation du tableau de bord"""
|
|
from PyQt5.QtWidgets import QApplication
|
|
import sys
|
|
|
|
# Créer l'application
|
|
app = QApplication(sys.argv)
|
|
|
|
# Créer l'orchestrateur (simulé ici)
|
|
class MockOrchestrator:
|
|
def __init__(self):
|
|
# Simuler un learning_manager
|
|
from datetime import datetime
|
|
|
|
class MockLearningManager:
|
|
def get_all_tasks(self):
|
|
return [
|
|
{
|
|
"task_id": "task_001",
|
|
"task_name": "Ouvrir Facture",
|
|
"mode": "auto",
|
|
"confidence_score": 0.97,
|
|
"observation_count": 45,
|
|
"concordance_rate": 0.98,
|
|
"correction_count": 1,
|
|
"correction_rate": 0.022,
|
|
"last_execution": datetime.now().isoformat()
|
|
},
|
|
{
|
|
"task_id": "task_002",
|
|
"task_name": "Valider Commande",
|
|
"mode": "assist",
|
|
"confidence_score": 0.89,
|
|
"observation_count": 12,
|
|
"concordance_rate": 0.92,
|
|
"correction_count": 2,
|
|
"correction_rate": 0.167,
|
|
"last_execution": datetime.now().isoformat()
|
|
}
|
|
]
|
|
|
|
def get_task_stats(self):
|
|
return {
|
|
"total_tasks": 2,
|
|
"shadow_tasks": 0,
|
|
"assist_tasks": 1,
|
|
"auto_tasks": 1,
|
|
"current_mode": "assist"
|
|
}
|
|
|
|
self.learning_manager = MockLearningManager()
|
|
|
|
orchestrator = MockOrchestrator()
|
|
|
|
# Créer l'interface
|
|
gui = EnhancedMinimalGUI(orchestrator)
|
|
gui.show()
|
|
|
|
# Afficher automatiquement le tableau de bord
|
|
gui.show_dashboard()
|
|
|
|
sys.exit(app.exec_())
|
|
|
|
|
|
if __name__ == "__main__":
|
|
example_usage()
|