Skip to content
Snippets Groups Projects
show_pc_window.py 1.6 KiB
Newer Older
  • Learn to ignore specific revisions
  • from PySide2.QtWidgets import QDialog, QPushButton, QVBoxLayout, QCheckBox,\
    QFrame, QFormLayout
    from PySide2.QtCore import Qt, Signal
    
    from b_asic import SFG
    
    class ShowPCWindow(QDialog):
        pc = Signal()
    
        def __init__(self, window):
            super(ShowPCWindow, self).__init__()
            self._window = window
            self.check_box_list = []
            self.setWindowFlags(Qt.WindowTitleHint | Qt.WindowCloseButtonHint)
            self.setWindowTitle("Show PC")
    
            self.dialog_layout = QVBoxLayout()
            self.pc_btn = QPushButton("Show PC")
            self.pc_btn.clicked.connect(self.show_precedence_graph)
            self.dialog_layout.addWidget(self.pc_btn)
            self.setLayout(self.dialog_layout)
    
        def add_sfg_to_dialog(self):
            sfg_layout = QVBoxLayout()
            options_layout = QFormLayout()
    
            for sfg in self._window.sfg_list:
                check_box = QCheckBox()
                options_layout.addRow(sfg.name, check_box)
                self.check_box_list.append(check_box)
    
            sfg_layout.addLayout(options_layout)
    
            frame = QFrame()
            frame.setFrameShape(QFrame.HLine)
            frame.setFrameShadow(QFrame.Sunken)
            self.dialog_layout.addWidget(frame)
    
            self.dialog_layout.addLayout(sfg_layout)
    
        def show_precedence_graph(self):
            for i, check_box in enumerate(self.check_box_list):
                if check_box.isChecked():
                    self._window.logger.info("Creating a precedence chart from " + self._window.sfg_list[i].name)
                    self._window.sfg_list[i].show_precedence_graph()
                    break
            
            self.accept()
            self.pc.emit()