Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
cable / usr / lib / python3 / dist-packages / cables / utils / helpers.py
Size: Mime:
"""
Helper functions for the Cables application
"""

from PyQt6.QtWidgets import QMessageBox, QWidget
from PyQt6.QtCore import QTimer


def show_timed_messagebox(parent: QWidget, icon: QMessageBox.Icon, title: str, text: str, duration: int = 1000) -> None:
    """
    Shows a message box that automatically closes after a specified duration.
    
    Args:
        parent: The parent widget
        icon: The message box icon (e.g., QMessageBox.Icon.Information)
        title: The title of the message box
        text: The text to display in the message box
        duration: The duration in milliseconds before the message box closes (default: 1000ms)
    """
    msgBox = QMessageBox(parent)
    msgBox.setIcon(icon)
    msgBox.setWindowTitle(title)
    msgBox.setText(text)
    msgBox.setStandardButtons(QMessageBox.StandardButton.NoButton)  # No buttons needed
    QTimer.singleShot(duration, msgBox.accept)  # Close after duration
    msgBox.exec()