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)
def __init__(self, cwl): assert isinstance(cwl, CameraWithLocation), "instrument must be a CameraWithLocation" super(CameraWithLocationUI, self).__init__() self.cwl = cwl # Set up the UI self.setWindowTitle(self.cwl.camera.__class__.__name__ + " (location-aware)") layout = QtWidgets.QVBoxLayout() # We use a tabbed control section below an image. self.tabs = QtWidgets.QTabWidget() self.microscope_controls = self.cwl.get_control_widget() self.camera_controls = self.cwl.camera.get_control_widget() self.tabs.addTab(self.microscope_controls, "Camera with Location controls") self.tabs.addTab(self.camera_controls, "Camera") # The camera viewer widget is provided by the camera... self.camera_preview = self.cwl.camera.get_preview_widget() # The overall layout puts the image at the top and the controls below l = QtWidgets.QVBoxLayout() l.addWidget(self.camera_preview) l.addWidget(self.tabs) self.setLayout(l)
def __init__(self, camera, *args, **kwargs): super(CameraParametersWidget, self).__init__(*args, **kwargs) self.camera = camera self.table_model = CameraParametersTableModel(camera) self.table_view = QtWidgets.QTableView() self.table_view.setModel(self.table_model) self.table_view.setCornerButtonEnabled(False) self.table_view.resizeColumnsToContents() self.table_view.horizontalHeader().setStretchLastSection(True) layout = QtWidgets.QVBoxLayout(self) layout.addWidget(self.table_view) self.setLayout(layout)
def _init_ui(self): self.setWindowTitle('Spectrometers') self.controls_layout = QtWidgets.QHBoxLayout() controls_group = QtWidgets.QGroupBox() controls_group.setTitle('Spectrometers') controls_group.setLayout(self.controls_layout) self.controls = [] for spectrometer in self.spectrometers.spectrometers: control = spectrometer.get_qt_ui(control_only=True) self.controls_layout.addWidget(control) self.controls.append(control) self.display = SpectrometerDisplayUI(self.spectrometers) layout = QtWidgets.QVBoxLayout() layout.addWidget(controls_group) layout.addWidget(self.display) self.setLayout(layout)
def _init_ui(self): self.setWindowTitle(self.spectrometer.__class__.__name__) self.controls = self.spectrometer.get_qt_ui(control_only=True) self.display = SpectrometerDisplayUI(self.spectrometer) layout = QtWidgets.QVBoxLayout() # controls_layout = QtWidgets.QVBoxLayout() # controls_layout.addWidget(self.controls) # controls_layout.setContentsMargins(0,0,0,0) # controls_group = QtWidgets.QGroupBox() # controls_group.setTitle('Spectrometer') # controls_group.setLayout(controls_layout) layout.addWidget(self.controls) layout.addWidget(self.display) layout.setContentsMargins(5, 5, 5, 5) layout.setSpacing(5) self.setLayout(layout)
def __init__(self, counter): #TODO: better checking (e.g. assert camera has color_image, gray_image methods) super(CounterUI, self).__init__() self.counter = counter # Set up the UI self.setWindowTitle(self.counter.__class__.__name__) layout = QtWidgets.QVBoxLayout() # The image display goes at the top of the window self.preview_widget = self.counter.get_preview_widget() layout.addWidget(self.preview_widget) # The controls go in a layout, inside a group box. self.control_widget = self.counter.get_control_widget() layout.addWidget(self.control_widget) #layout.setContentsMargins(5,5,5,5) layout.setSpacing(5) self.setLayout(layout)
def __init__(self, camera): assert isinstance(camera, Camera), "instrument must be a Camera" #TODO: better checking (e.g. assert camera has color_image, gray_image methods) super(CameraUI, self).__init__() self.camera = camera # Set up the UI self.setWindowTitle(self.camera.__class__.__name__) layout = QtWidgets.QVBoxLayout() # The image display goes at the top of the window self.preview_widget = self.camera.get_preview_widget() layout.addWidget(self.preview_widget) # The controls go in a layout, inside a group box. self.controls = self.camera.get_control_widget() layout.addWidget(self.controls) #layout.setContentsMargins(5,5,5,5) layout.setSpacing(5) self.setLayout(layout)
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)