| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- """
- Print Options Dialog
- Dialog for selecting print options before printing a report.
- """
- from PyQt5.QtWidgets import (QDialog, QVBoxLayout, QHBoxLayout, QLabel,
- QPushButton, QRadioButton, QButtonGroup, QGroupBox)
- from PyQt5.QtCore import Qt
- from PyQt5.QtGui import QFont
- class PrintOptionsDialog(QDialog):
- """
- Dialog for selecting print options.
-
- Allows user to choose whether to include visualizations in print.
- """
-
- def __init__(self, parent=None):
- """Initialize the print options dialog."""
- super().__init__(parent)
- self.setWindowTitle("Print Options")
- self.setModal(True)
- self.setMinimumWidth(400)
- self.setMinimumHeight(250)
-
- self.include_visualizations = True # Default: include visualizations
- self.init_ui()
-
- def init_ui(self):
- """Initialize the UI components."""
- layout = QVBoxLayout(self)
- layout.setContentsMargins(20, 20, 20, 20)
- layout.setSpacing(15)
-
- # Title
- title = QLabel("Print Report")
- title_font = QFont("Arial", 14, QFont.Bold)
- title.setFont(title_font)
- layout.addWidget(title)
-
- # Description
- description = QLabel("How would you like to print this report?")
- description.setStyleSheet("color: #555; font-size: 12px;")
- layout.addWidget(description)
-
- # Options group
- options_group = QGroupBox("Print Options")
- options_layout = QVBoxLayout()
-
- # Button group for radio buttons
- self.button_group = QButtonGroup()
-
- # Option 1: Include visualizations
- self.include_viz_radio = QRadioButton("Include All Visualizations (Recommended)")
- self.include_viz_radio.setChecked(True)
- self.include_viz_radio.setStyleSheet("font-size: 12px; padding: 8px;")
- self.button_group.addButton(self.include_viz_radio, 0)
- options_layout.addWidget(self.include_viz_radio)
-
- # Description for option 1
- desc1 = QLabel(" • Prints all analysis results and visualizations\n"
- " • Best for comprehensive reports\n"
- " • May span multiple pages")
- desc1.setStyleSheet("color: #777; font-size: 11px; margin-left: 25px; margin-bottom: 10px;")
- options_layout.addWidget(desc1)
-
- # Option 2: Text only
- self.text_only_radio = QRadioButton("Text Only (Compact)")
- self.text_only_radio.setStyleSheet("font-size: 12px; padding: 8px;")
- self.button_group.addButton(self.text_only_radio, 1)
- options_layout.addWidget(self.text_only_radio)
-
- # Description for option 2
- desc2 = QLabel(" • Prints analysis results and text data only\n"
- " • More compact format\n"
- " • Faster to print")
- desc2.setStyleSheet("color: #777; font-size: 11px; margin-left: 25px; margin-bottom: 15px;")
- options_layout.addWidget(desc2)
-
- options_group.setLayout(options_layout)
- layout.addWidget(options_group)
-
- layout.addStretch()
-
- # Button layout
- button_layout = QHBoxLayout()
- button_layout.addStretch()
-
- # Cancel button
- cancel_btn = QPushButton("Cancel")
- cancel_btn.setMinimumWidth(100)
- cancel_btn.setStyleSheet("""
- QPushButton {
- padding: 8px 16px;
- background-color: #95a5a6;
- color: white;
- font-weight: bold;
- border-radius: 4px;
- border: none;
- }
- QPushButton:hover {
- background-color: #7f8c8d;
- }
- """)
- cancel_btn.clicked.connect(self.reject)
- button_layout.addWidget(cancel_btn)
-
- # Print button
- print_btn = QPushButton("Print")
- print_btn.setMinimumWidth(100)
- print_btn.setStyleSheet("""
- QPushButton {
- padding: 8px 16px;
- background-color: #27ae60;
- color: white;
- font-weight: bold;
- border-radius: 4px;
- border: none;
- }
- QPushButton:hover {
- background-color: #229954;
- }
- """)
- print_btn.clicked.connect(self.accept)
- button_layout.addWidget(print_btn)
-
- layout.addLayout(button_layout)
-
- def get_include_visualizations(self) -> bool:
- """
- Get whether visualizations should be included.
-
- Returns:
- bool: True if visualizations should be included, False for text only
- """
- return self.include_viz_radio.isChecked()
|