fork download
  1. print("");
  2. print("----- Checking Python -----");
  3.  
  4. import sys
  5.  
  6. def Running27():
  7. # Okay, we're running 2.7. Now check if PyQT is installed.
  8. try:
  9. from PyQt4 import Qt
  10. except:
  11. print("ERROR: failed to import PyQt4");
  12.  
  13.  
  14. major = sys.version_info.major;
  15. minor = sys.version_info.minor;
  16.  
  17. if major == 2 and minor == 7:
  18. Running27();
  19. else:
  20. print("ERROR: The interpreter for this script is not Python 2.7.X");
  21. print("\t The interpreter is " + str(sys.version_info));
  22.  
  23. print("");
  24. print("Hit enter to exit...");
  25. raw_input();
Success #stdin #stdout 0.01s 7304KB
stdin
import sys
import random
from PyQt5.QtWidgets import (
    QApplication, QMainWindow, QLabel, QVBoxLayout, QWidget,
    QPushButton, QProgressBar, QHBoxLayout, QFrame
)
from PyQt5.QtCore import QTimer, Qt

class IronDomeControlPanel(QMainWindow):
    def __init__(self):
        super().__init__()
        self.setWindowTitle("Iron Dome Control Panel Simulation")
        self.setGeometry(100, 100, 800, 600)

        # Ana widget ve layout
        self.central_widget = QWidget()
        self.setCentralWidget(self.central_widget)
        self.layout = QVBoxLayout(self.central_widget)

        # Başlık
        self.title_label = QLabel("Iron Dome Active Defense System", self)
        self.title_label.setAlignment(Qt.AlignCenter)
        self.title_label.setStyleSheet("font-size: 24px; font-weight: bold;")
        self.layout.addWidget(self.title_label)

        # Durum göstergesi
        self.status_label = QLabel("System Status: Initializing...", self)
        self.status_label.setAlignment(Qt.AlignCenter)
        self.status_label.setStyleSheet("font-size: 18px; color: blue;")
        self.layout.addWidget(self.status_label)

        # Tehdit ve imha sayaçları için yatay layout
        self.counter_layout = QHBoxLayout()
        self.layout.addLayout(self.counter_layout)

        # Tehdit sayacı
        self.threat_count_label = QLabel("Detected Threats: 0", self)
        self.threat_count_label.setAlignment(Qt.AlignCenter)
        self.threat_count_label.setStyleSheet("font-size: 18px;")
        self.counter_layout.addWidget(self.threat_count_label)

        # Dikey ayırıcı çizgi
        self.separator = QFrame()
        self.separator.setFrameShape(QFrame.VLine)
        self.separator.setFrameShadow(QFrame.Sunken)
        self.counter_layout.addWidget(self.separator)

        # İmha edilen tehdit sayacı
        self.neutralized_count_label = QLabel("Neutralized Threats: 0", self)
        self.neutralized_count_label.setAlignment(Qt.AlignCenter)
        self.neutralized_count_label.setStyleSheet("font-size: 18px;")
        self.counter_layout.addWidget(self.neutralized_count_label)

        # Başarı oranı göstergesi
        self.success_rate_label = QLabel("Success Rate: 0%", self)
        self.success_rate_label.setAlignment(Qt.AlignCenter)
        self.success_rate_label.setStyleSheet("font-size: 18px; color: green;")
        self.layout.addWidget(self.success_rate_label)

        # Tehdit algılama butonu
        self.detect_button = QPushButton("Simulate Threat Detection", self)
        self.detect_button.clicked.connect(self.simulate_threat_detection)
        self.layout.addWidget(self.detect_button)

        # İmha işlemi ilerleme çubuğu
        self.progress_bar = QProgressBar(self)
        self.progress_bar.setValue(0)
        self.layout.addWidget(self.progress_bar)

        # Zamanlayıcı
        self.timer = QTimer(self)
        self.timer.timeout.connect(self.update_progress)

        # Tehdit ve imha sayıları
        self.detected_threats = 0
        self.neutralized_threats = 0

    def simulate_threat_detection(self):
        self.detected_threats += 1
        self.threat_count_label.setText(f"Detected Threats: {self.detected_threats}")
        self.status_label.setText("System Status: Threat Detected!")
        self.status_label.setStyleSheet("font-size: 18px; color: red;")
        self.progress_bar.setValue(0)
        self.timer.start(100)  # 100 ms aralıklarla güncelle

    def update_progress(self):
        current_value = self.progress_bar.value()
        if current_value < 100:
            self.progress_bar.setValue(current_value + random.randint(5, 15))
        else:
            self.timer.stop()
            self.neutralized_threats += 1
            self.neutralized_count_label.setText(f"Neutralized Threats: {self.neutralized_threats}")
            success_rate = (self.neutralized_threats / self.detected_threats) * 100
            self.success_rate_label.setText(f"Success Rate: {success_rate:.2f}%")
            self.status_label.setText("System Status: Threat Neutralized")
            self.status_label.setStyleSheet("font-size: 18px; color: green;")

if __name__ == "__main__":
    app = QApplication(sys.argv)
    window = IronDomeControlPanel()
    window.show()
    sys.exit(app.exec_())
stdout
----- Checking Python -----
ERROR: failed to import PyQt4

Hit enter to exit...