コード例 #1
0
ファイル: hdf5_browser.py プロジェクト: caizikun/nplab
    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)
コード例 #2
0
ファイル: __init__.py プロジェクト: ww334/nplab
 def SolsTiSupdatestatus(self):
     '''
     relevant_properties is a dictionary of labels to display (keys) and names of the properties to display as returned
     by the laser
     We then create a dictionary with the labels and the values of the properties (display_dicc)
     And display that dictionary as a table
     :return:
     '''
     relevant_properties = {
         'C. lock': 'cavity_lock',
         'E. lock': 'etalon_lock',
         'T': 'temperature',
         'R. volt.': 'resonator_voltage',
         'E. volt.': 'etalon_voltage',
         'wvl': 'wavelength',
         'Out': 'output_monitor'
     }
     display_dicc = {
         new_key: self.SolsTiS.laser_status[relevant_properties[new_key]]
         for new_key in relevant_properties.keys()
     }
     self.tableWidget.setRowCount(len(relevant_properties))
     row = 0
     for key in display_dicc.keys():
         item_key = QtWidgets.QTableWidgetItem(key)
         item_value = QtWidgets.QTableWidgetItem(str(display_dicc[key]))
         self.tableWidget.setItem(row, 0, item_key)
         self.tableWidget.setItem(row, 1, item_value)
         row = row + 1
     self.tableWidget.resizeColumnsToContents()
コード例 #3
0
    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)
コード例 #4
0
ファイル: __init__.py プロジェクト: ivanalam/nplab
    def _make_gui(self, hide_border=True):
        """Creates and sets the widget layout
        :param hide_border: bool. See __init__
        :return:
        """
        self._QLabel = QtWidgets.QLabel(self)

        layout = QtWidgets.QHBoxLayout(self)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.addWidget(self._QLabel)
        self.setLayout(layout)

        self.setWindowTitle('SLM Phase')
        if hide_border:
            self.setWindowFlags(QtCore.Qt.CustomizeWindowHint
                                | QtCore.Qt.FramelessWindowHint)
コード例 #5
0
 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)
コード例 #6
0
ファイル: ui_tools.py プロジェクト: caizikun/nplab
 def add_checkbox(self, name, title=None):
     if title is None:
         title = name.title()
     checkbox = QtWidgets.QCheckBox()
     self.controls[name] = checkbox
     checkbox.setObjectName(name + "_checkbox")
     checkbox.setText(title)
     self.layout().addRow("", checkbox)
コード例 #7
0
 def _addActionViewMenu(self, instr):
     if instr not in self.actions['Views']:
         action = QtWidgets.QAction(instr, self)
         self.menuView.addAction(action)
         action.setCheckable(True)
         action.setChecked(True)
         action.triggered.connect(lambda: self._toggleView(instr))
         self.actions['Views'][instr] = action
コード例 #8
0
 def _addActionInstrMenu(self, instr):
     if instr not in self.actions['Instruments']:
         action = QtWidgets.QAction(instr, self)
         self.menuInstr.addAction(action)
         action.setCheckable(True)
         action.setChecked(settings.addresses[instr]['use?'])
         action.triggered.connect(lambda: self._toggleInstr(instr))
         self.actions['Instruments'][instr] = action
コード例 #9
0
    def __init__(self,
                 spectrometer,
                 ui_file=os.path.join(os.path.dirname(__file__),
                                      'spectrometer_view.ui'),
                 parent=None):
        assert isinstance(spectrometer, Spectrometer) or isinstance(spectrometer, Spectrometers),\
            "instrument must be a Spectrometer or an instance of Spectrometers"
        super(SpectrometerDisplayUI, self).__init__()
        uic.loadUi(ui_file, self)
        if isinstance(spectrometer,
                      Spectrometers) and spectrometer.num_spectrometers == 1:
            spectrometer = spectrometer.spectrometers[0]
        if isinstance(spectrometer, Spectrometer):
            spectrometer.num_spectrometers = 1
        self.spectrometer = spectrometer
        print(self.spectrometer)

        pg.setConfigOption('background', 'w')
        pg.setConfigOption('foreground', 'k')
        self.plotbox = QtWidgets.QGroupBox()
        self.plotbox.setLayout(QtWidgets.QGridLayout())
        self.plotlayout = self.plotbox.layout()
        self.plots = []

        for spectrometer_nom in range(self.spectrometer.num_spectrometers):
            self.plots.append(
                pg.PlotWidget(labels={'bottom': 'Wavelength (nm)'}))
            self.plotlayout.addWidget(self.plots[spectrometer_nom])

        self.figure_widget = self.replace_widget(self.display_layout,
                                                 self.figure_widget,
                                                 self.plotbox)
        self.take_spectrum_button.clicked.connect(self.button_pressed)
        self.live_button.clicked.connect(self.button_pressed)
        self.save_button.clicked.connect(self.button_pressed)
        self.threshold.setValidator(QtGui.QDoubleValidator())
        self.threshold.textChanged.connect(self.check_state)
        self._display_thread = DisplayThread(self)
        self._display_thread.spectrum_ready.connect(self.update_display)
        self._display_thread.spectra_ready.connect(self.update_display)

        self.period = 0.2
        self.filename_lineEdit.textChanged.connect(self.filename_changed_ui)

        register_for_property_changes(self.spectrometer, 'filename',
                                      self.filename_changed)
コード例 #10
0
ファイル: ui_tools.py プロジェクト: caizikun/nplab
 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)
コード例 #11
0
 def _addActionViewMenu(self, instr):
     """Create the actions menu - such as enabled and disabling gui's on the fly """
     if instr not in self.actions['Views']:
         action = QtWidgets.QAction(instr, self)
         self.menuView.addAction(action)
         action.setCheckable(True)
         action.setChecked(True)
         action.triggered.connect(lambda: self._toggleView(instr))
         self.actions['Views'][instr] = action
コード例 #12
0
ファイル: ui_tools.py プロジェクト: caizikun/nplab
 def add_spinbox(self, name, vmin=-2**31, vmax=2**31 - 1):
     """Add a floating-point spin box control."""
     sb = QtWidgets.QSpinBox()
     self.controls[name] = sb
     sb.setObjectName(name + "_spinbox")
     sb.setMinimum(vmin)
     sb.setMaximum(vmax)
     sb.setKeyboardTracking(False)
     self.layout().addRow(name.title(), sb)
コード例 #13
0
ファイル: hdf5_browser.py プロジェクト: caizikun/nplab
 def renderer_selected(self, index):
     """Change the figure widget to use the selected renderer."""
     # The class of the renderer is stored as the combobox data
     RendererClass = self.renderer_combobox.itemData(index)
     try:
         self.renderer = RendererClass(self.data, self)
     except TypeError:
         # If the box is empty (e.g. it's just been cleared) use a blank widget
         self.renderer = QtWidgets.QWidget()
コード例 #14
0
    def __init__(self, experiment):
        """Create a widget to display an experiment's logs."""
        self.experiment = experiment
        super(LogWidget, self).__init__()

        self.text_edit = QtWidgets.QPlainTextEdit()
        self.text_edit.setReadOnly(True)
        self.layout().addRow(self.text_edit)
        self.add_button("clear", title="Clear Logs")
        self.auto_connect_by_name()
コード例 #15
0
ファイル: ui_tools.py プロジェクト: caizikun/nplab
 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)
コード例 #16
0
ファイル: hdf5_browser.py プロジェクト: caizikun/nplab
    def context_menu(self, treeview, position):
        """Generate a right-click menu for the items"""
        menu = QtWidgets.QMenu()
        actions = {}

        for operation in ['Refresh tree']:
            actions[operation] = menu.addAction(operation)
        action = menu.exec_(treeview.viewport().mapToGlobal(position))

        if action == actions['Refresh tree']:
            self.refresh_tree()
コード例 #17
0
ファイル: __init__.py プロジェクト: ww334/nplab
    def SolsTiSReLock(self):
        progress = QtWidgets.QProgressDialog("Re-locking etalon", "Abort", 0,
                                             5, self)
        progress.show()
        i = 0
        self.SolsTiS.system_status()

        while self.SolsTiS.laser_status['etalon_lock'] != 'on' and i < 5:
            progress.setValue(i)
            self.SolsTiS.etalon_lock('on')
            time.sleep(0.5)
            self.SolsTiS.system_status()
            time.sleep(0.1)
            i += 1
        progress.close()
        if i < 5:
            self.SolsTiSLockMonitor()
        else:
            popup = QtWidgets.QMessageBox()
            popup.setText("Re-locking the etalon failed")
            popup.exec_()
コード例 #18
0
    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)
コード例 #19
0
ファイル: FrequencyCounter.py プロジェクト: ivanalam/nplab
    def __init__(self, counter):
        super(CounterPreviewWidget, self).__init__()

        #   self.plot_item = pg.pl

        self.plot_widget = pg.PlotWidget(labels={'bottom': 'Time'})
        self.plot = self.plot_widget.getPlotItem()
        self.setLayout(QtWidgets.QGridLayout())
        self.layout().addWidget(self.plot_widget)
        self.counter = counter
        # We want to make sure we always update the data in the GUI thread.
        # This is done using the signal/slot mechanism
        self.update_data_signal.connect(self.update_widget,
                                        type=QtCore.Qt.QueuedConnection)
コード例 #20
0
 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)
コード例 #21
0
ファイル: thread_box.py プロジェクト: ww334/nplab
        def payload(save_group=df._current_group):
            import numpy as np
            input_variables = {}
            for variable in self.controls.keys():
                if variable == 'save_returned' or variable == 'start' or variable == 'function name':
                    continue

                variable_control = self.controls[variable]
                if type(variable_control) == type(QtWidgets.QLineEdit(
                )) and variable_control.isReadOnly() == True:
                    fullargs = inspect.getargspec(self.function)
                    args = fullargs.args
                    try:
                        args.remove('self')
                    except ValueError:
                        pass
                    args = np.array(args)
                    defaults = np.array(fullargs.defaults)
                    default_value = defaults[args == variable]
                    input_variables[variable] = default_value[0]
                    print variable, default_value
                elif (type(variable_control) == QtWidgets.QSpinBox
                      or type(variable_control) == QtWidgets.QDoubleSpinBox):
                    input_variables[variable] = variable_control.value()
                elif type(variable_control) == QtWidgets.QLineEdit:
                    try:
                        exec 'temp_var = ' + variable_control.text() in locals(
                        )
                        input_variables[variable] = temp_var

                    except Exception as e:
                        print e
                        print 'Qlineedit input error for ', variable
                elif type(variable_control) == QtWidgets.QCheckBox:
                    input_variables[variable] = variable_control.isChecked()
            try:
                function_returns = self.function(**input_variables)
            except TypeError:
                print input_variables
                print 'function: ', task
                print 'Did not recieve the correct inputs!'
                print 'did you make an error in your lineedit inputs?'
            if self.controls['save_returned'].isChecked() == True:
                save_group.create_dataset(task,
                                          data=function_returns,
                                          attrs=input_variables)
コード例 #22
0
ファイル: FrequencyCounter.py プロジェクト: ivanalam/nplab
    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)
コード例 #23
0
    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)
コード例 #24
0
ファイル: camera_scaled_roi.py プロジェクト: ivanalam/nplab
    def __init__(self, scale=(1, 1), offset=(0, 0)):
        super(DisplayWidgetRoiScale, self).__init__()

        self._pxl_scale = scale
        self._pxl_offset = offset

        self.LineDisplay = self.ui.roiPlot
        self.LineDisplay.showGrid(x=True, y=True)
        self.ui.splitter.setHandleWidth(10)
        self.getHistogramWidget().gradient.restoreState(
            list(Gradients.values())[1])
        self.imageItem.setTransform(QtGui.QTransform())
        self.LineDisplay.show()

        self.plot = ()
        for ii in range(self._max_num_line_plots):
            self.plot += (self.LineDisplay.plot(
                pen=pyqtgraph.intColor(ii, self._max_num_line_plots)), )

        self.toggle_displays()

        self.checkbox_autorange = QtWidgets.QCheckBox('Autorange')
        self.tools.gridLayout.addWidget(self.checkbox_autorange, 0, 3, 1, 1)
コード例 #25
0
    def __init__(self, cwl):
        super(CameraWithLocationControlUI, self).__init__()
        self.cwl = cwl
        cc = QuickControlBox("Settings")
        cc.add_doublespinbox("calibration_distance")
        cc.add_button("calibrate_xy_gui", "Calibrate XY")
        cc.auto_connect_by_name(self)
        self.calibration_controls = cc

        fc = QuickControlBox("Autofocus")
        fc.add_doublespinbox("af_step_size")
        fc.add_spinbox("af_steps")
        fc.add_button("autofocus_gui", "Autofocus")
        fc.add_button("quick_autofocus_gui", "Quick Autofocus")
        fc.auto_connect_by_name(self.cwl)
        self.focus_controls = fc

#        sc = 

        l = QtWidgets.QHBoxLayout()
        l.addWidget(cc)
        l.addWidget(fc)
        self.setLayout(l)
コード例 #26
0
ファイル: ui_tools.py プロジェクト: caizikun/nplab
 def __init__(self, title="Quick Settings", *args, **kwargs):
     super(QuickControlBox, self).__init__(*args, **kwargs)
     self.setTitle(title)
     self.setLayout(QtWidgets.QFormLayout())
     self.controls = dict()
コード例 #27
0
    def __init__(self,
                 instrument_dict,
                 parent=None,
                 dock_settings_path=None,
                 scripts_path=None,
                 working_directory=None):  #
        """Args:
            instrument_dict(dict) :     This is a dictionary containg the 
                                        instruments objects where the key is the 
                                        objects new name in the generated new Ipython 
                                        console
            dock_settings_path(str):    A path for loading a previous dock widget
                                        configuration
            script_path(str):           The path of any scripts the user may want to
                                        run using the drop down menu at the top
                                        of the gui
            working_directory(str):     A path to the requested working directory - 
                                        handy if you always wish to save data to 
                                        the same directorys
                                """
        super(GuiGenerator, self).__init__(parent)
        self._logger = LOGGER
        self.instr_dict = instrument_dict
        if working_directory == None:
            self.working_directory = os.path.join(os.getcwd())
        else:
            self.working_directory = working_directory
        self.data_file = df.current(working_directory=working_directory)
        self.instr_dict['HDF5'] = self.data_file
        self.setDockNestingEnabled(1)

        uic.loadUi(os.path.join(os.path.dirname(__file__), 'guigenerator.ui'),
                   self)

        self.allDocks = {}
        self.allWidgets = {}
        self.actions = dict(Views={}, Instruments={})

        self.dockwidgetArea = pyqtgraph.dockarea.DockArea()
        self.dockWidgetArea = self.replace_widget(self.verticalLayout,
                                                  self.centralWidget(),
                                                  self.dockwidgetArea)
        self.dockWidgetAllInstruments.setWidget(self.dockwidgetArea)
        self.dockWidgetAllInstruments.setTitleBarWidget(
            QtWidgets.QWidget())  # This trick makes the title bar disappear

        # Iterate over all the opened instruments. If the instrument has a GUI (i.e. if they have the get_qt_ui function
        # defined inside them), then create a pyqtgraph.Dock for it and add its widget to the Dock. Also prints out any
        # instruments that do not have GUIs
        self._logger.info('Opening all GUIs')

        for instr in self.instr_dict:
            self._open_one_gui(instr)

        self.terminalWindow = None
        self.menuTerminal()
        self._addActionViewMenu('Terminal')

        self.script_menu = None
        if scripts_path is not None:
            self.scripts_path = scripts_path
        else:
            self.scripts_path = 'scripts'
        self.makeScriptMenu()

        self.NightMode = 1

        # address of h5 file
        self.filename = df.current().filename

        #        self._tabifyAll()
        self._setupSignals()
        if dock_settings_path is not None:
            self.dock_settings_path = dock_settings_path
            self.menuLoadSettings()
        else:
            self.dock_settings_path = None
        self.showMaximized()
コード例 #28
0
    def __init__(self,
                 instrument_dict,
                 parent=None,
                 dock_settings_path=None,
                 scripts_path=None,
                 working_directory=None):
        super(GuiGenerator, self).__init__(parent)
        self._logger = LOGGER
        self.instr_dict = instrument_dict
        if working_directory == None:
            self.working_directory = os.path.join(os.getcwd())
        else:
            self.working_directory = working_directory
        self.data_file = df.current(working_directory=working_directory)
        self.instr_dict['HDF5'] = self.data_file
        self.setDockNestingEnabled(1)

        uic.loadUi(os.path.join(os.path.dirname(__file__), 'guigenerator.ui'),
                   self)

        self.allDocks = {}
        self.allWidgets = {}
        self.actions = dict(Views={}, Instruments={})

        self.dockwidgetArea = pyqtgraph.dockarea.DockArea()
        self.dockWidgetArea = self.replace_widget(self.verticalLayout,
                                                  self.centralWidget(),
                                                  self.dockwidgetArea)
        self.dockWidgetAllInstruments.setWidget(self.dockwidgetArea)
        self.dockWidgetAllInstruments.setTitleBarWidget(
            QtWidgets.QWidget())  # This trick makes the title bar disappear

        # Iterate over all the opened instruments. If the instrument has a GUI (i.e. if they have the get_qt_ui function
        # defined inside them), then create a pyqtgraph.Dock for it and add its widget to the Dock. Also prints out any
        # instruments that do not have GUIs
        self._logger.info('Opening all GUIs')

        for instr in self.instr_dict:
            self._open_one_gui(instr)

        self.terminalWindow = None
        self.menuTerminal()
        self._addActionViewMenu('Terminal')

        self.script_menu = None
        if scripts_path is not None:
            self.scripts_path = scripts_path
        else:
            self.scripts_path = 'scripts'
        self.makeScriptMenu()

        self.NightMode = 1

        # address of h5 file
        self.filename = df.current().filename

        #        self._tabifyAll()
        self._setupSignals()
        if dock_settings_path is not None:
            self.dock_settings_path = dock_settings_path
            self.menuLoadSettings()
        else:
            self.dock_settings_path = None
        self.showMaximized()
コード例 #29
0
ファイル: hdf5_browser.py プロジェクト: caizikun/nplab
    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)
コード例 #30
0
ファイル: ui_tools.py プロジェクト: caizikun/nplab
 def add_lineedit(self, name):
     """Add a single-line text box control."""
     le = QtWidgets.QLineEdit()
     self.controls[name] = le
     le.setObjectName(name + "_lineedit")
     self.layout().addRow(name.title(), le)