Skip to content
Snippets Groups Projects
select_sfg_window.py 1.03 KiB
Newer Older
  • Learn to ignore specific revisions
  • Oscar Gustafsson's avatar
    Oscar Gustafsson committed
    """
    B-ASIC select SFG window.
    """
    
    
    from qtpy.QtCore import Qt, Signal
    
    Oscar Gustafsson's avatar
    Oscar Gustafsson committed
    from qtpy.QtWidgets import QComboBox, QDialog, QPushButton, QVBoxLayout
    
    
    
    class SelectSFGWindow(QDialog):
        ok = Signal()
    
        def __init__(self, window):
    
            self._window = window
            self.setWindowFlags(Qt.WindowTitleHint | Qt.WindowCloseButtonHint)
            self.setWindowTitle("Select SFG")
    
            self.dialog_layout = QVBoxLayout()
            self.ok_btn = QPushButton("Ok")
            self.ok_btn.clicked.connect(self.save_properties)
            self.dialog_layout.addWidget(self.ok_btn)
            self.combo_box = QComboBox()
    
            self.sfg = None
            self.setLayout(self.dialog_layout)
            self.add_sfgs_to_layout()
    
        def add_sfgs_to_layout(self):
            for sfg in self._window.sfg_dict:
                self.combo_box.addItem(sfg)
    
            self.dialog_layout.addWidget(self.combo_box)
    
        def save_properties(self):
            self.sfg = self._window.sfg_dict[self.combo_box.currentText()]
            self.accept()
            self.ok.emit()