Skip to content
Snippets Groups Projects
select_sfg_window.py 1.1 KiB
Newer Older
  • Learn to ignore specific revisions
  • Oscar Gustafsson's avatar
    Oscar Gustafsson committed
    """
    B-ASIC select SFG window.
    """
    
    Oscar Gustafsson's avatar
    Oscar Gustafsson committed
    from typing import TYPE_CHECKING
    
    Oscar Gustafsson's avatar
    Oscar Gustafsson committed
    
    
    from qtpy.QtCore import Qt, Signal
    
    Oscar Gustafsson's avatar
    Oscar Gustafsson committed
    from qtpy.QtWidgets import QComboBox, QDialog, QPushButton, QVBoxLayout
    
    Oscar Gustafsson's avatar
    Oscar Gustafsson committed
    if TYPE_CHECKING:
        from b_asic.GUI.main_window import MainWindow
    
    
    Oscar Gustafsson's avatar
    Oscar Gustafsson committed
        def __init__(self, window: "MainWindow"):
    
            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)
    
    
    Oscar Gustafsson's avatar
    Oscar Gustafsson committed
            # Add SFGs to layout
    
            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()