Skip to content
Snippets Groups Projects
select_sfg_window.py 1.36 KiB
Newer Older
  • Learn to ignore specific revisions
  • Oscar Gustafsson's avatar
    Oscar Gustafsson committed
    """
    B-ASIC select SFG window.
    """
    
    Samuel Fagerlund's avatar
    Samuel Fagerlund committed
    
    
    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 SFGMainWindow
    
    Oscar Gustafsson's avatar
    Oscar Gustafsson committed
    
    
        def __init__(self, window: "SFGMainWindow"):
    
            self._window = window
            self.setWindowFlags(Qt.WindowTitleHint | Qt.WindowCloseButtonHint)
            self.setWindowTitle("Select SFG")
    
    
            self._dialog_layout = QVBoxLayout()
            self._ok_button = QPushButton("Ok")
            self._ok_button.clicked.connect(self.save_properties)
            self._dialog_layout.addWidget(self._ok_button)
            self._sfg_combo_box = QComboBox()
    
            self.setLayout(self._dialog_layout)
    
    Oscar Gustafsson's avatar
    Oscar Gustafsson committed
            # Add SFGs to layout
    
            for sfg in self._window._sfg_dict:
                self._sfg_combo_box.addItem(sfg)
    
            self._dialog_layout.addWidget(self._sfg_combo_box)
    
    Oscar Gustafsson's avatar
    Oscar Gustafsson committed
            if len(self._window._sfg_dict) == 1:
                self._sfg_combo_box.setCurrentIndex(0)
                self.save_properties()
            if not self._window._sfg_dict:
                self.accept()
                self.ok.emit()
    
            self.sfg = self._window._sfg_dict[self._sfg_combo_box.currentText()]