Exemplo n.º 1
0
    def __init__(self, data_file, parent=None):
        super(HDF5Browser, self).__init__(parent)
        self.data_file = data_file

        self.treeWidget = HDF5TreeWidget(
            data_file,
            parent=self,
        )
        self.treeWidget.selectionModel().selectionChanged.connect(
            self.selection_changed)
        self.viewer = HDF5ItemViewer(
            parent=self,
            show_controls=True,
        )
        self.refresh_tree_button = QtWidgets.QPushButton(
        )  #Create a refresh button
        self.refresh_tree_button.setText("Refresh Tree")

        #adding the refresh button
        self.treelayoutwidget = QtWidgets.QWidget(
        )  #construct a widget which can then contain the refresh button and the tree
        self.treelayoutwidget.setLayout(QtWidgets.QVBoxLayout())
        self.treelayoutwidget.layout().addWidget(self.treeWidget)
        self.treelayoutwidget.layout().addWidget(self.refresh_tree_button)

        self.refresh_tree_button.clicked.connect(
            self.treeWidget.model.refresh_tree)

        splitter = QtWidgets.QSplitter()
        splitter.addWidget(
            self.treelayoutwidget
        )  #Add newly constructed widget (treeview and button) to the splitter
        splitter.addWidget(self.viewer)
        self.setLayout(QtWidgets.QHBoxLayout())
        self.layout().addWidget(splitter)
Exemplo n.º 2
0
 def add_button(self, name, title=None):
     """Add a button."""
     if title is None:
         title = name.title()
     button = QtWidgets.QPushButton()
     self.controls[name] = button
     button.setObjectName(name + "_button")
     button.setText(title)
     self.layout().addRow(button)
Exemplo n.º 3
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)