示例#1
0
 def add_combobox(self, name, options, title=None):
     if title is None:
         title = name.title()
     combobox = QtWidgets.QComboBox()
     for option in options:
         combobox.addItem(option)
     self.controls[name] = combobox
     combobox.setObjectName(name + "_combobox")
     #      combobox.setText(title)
     self.layout().addRow("", combobox)
示例#2
0
    def __init__(
        self,
        item=None,
        parent=None,
        figure_widget=None,
        show_controls=True,
        show_refresh=True,
        show_default_button=True,
        show_copy=True,
        renderer_combobox=None,
        refresh_button=None,
        copy_button=None,
        default_button=None,
    ):
        """Create a viewer widget for any dataset or datagroup object
        
        Arguments:
        item : HDF5 group or dataset (optional)
            The dataset (or group) to display
        parent : QWidget (optional)
            The Qt parent of the widget.
        show_controls : bool (optional)
            If True (default), show the refresh button and combobox.  If False,
            just show the renderer.
        show_refresh : bool (optional)
            If show_controls is True, this sets whether the refresh button is
            visible.
        renderer_combobox : QComboBox (optional)
            If this is specified, use the supplied combobox instead of creating
            a new one.  You probably want to specify show_controls=False.
        refresh_button : QPushButton (optional)
            If specified, use the supplied button instead of creating one.
        copy_button : QPushButton (optional)
            If specified, use the supplied button instead of creating one.
        default_button : QPushButton (optional)
            If specified, use the supplied button to select the default 
            rendererinstead of creating one.
        """
        super(HDF5ItemViewer, self).__init__(parent)

        if figure_widget is None:
            self.figure_widget = QtWidgets.QWidget()
        else:
            self.figure_widget = figure_widget

        if renderer_combobox is None:
            self.renderer_combobox = QtWidgets.QComboBox()
        else:
            self.renderer_combobox = renderer_combobox
        self.renderer_combobox.activated[int].connect(self.renderer_selected)

        if refresh_button is None:
            self.refresh_button = QtWidgets.QPushButton()
            self.refresh_button.setText("Refresh Figure")
        else:
            self.refresh_button = refresh_button
        self.refresh_button.clicked.connect(self.refresh)

        if default_button is None:
            self.default_button = QtWidgets.QPushButton()
            self.default_button.setText("Default Renderer")
        else:
            self.default_button = default_button
        self.default_button.clicked.connect(self.default_renderer)

        if copy_button is None:
            self.copy_button = QtWidgets.QPushButton()
            self.copy_button.setText("Copy Figure")
        else:
            self.copy_button = copy_button
        self.copy_button.clicked.connect(self.CopyActivated)
        self.clipboard = QtWidgets.QApplication.clipboard()

        self.setLayout(QtWidgets.QVBoxLayout())
        self.layout().addWidget(self.figure_widget, stretch=1)
        self.layout().setContentsMargins(0, 0, 0, 0)

        self.renderers = list()

        if show_controls:  # this part may be broken
            hb = QtWidgets.QHBoxLayout()
            hb.addWidget(self.renderer_combobox, stretch=1)
            if show_refresh:
                hb.addWidget(self.refresh_button, stretch=0)
            if show_copy:
                hb.addWidget(self.copy_button, stretch=0)
            if show_default_button:
                hb.addWidget(self.default_button, stretch=0)
            self.layout().addLayout(hb, stretch=0)