コード例 #1
0
    def auto_place_widgets(self, *args):
        widget = QWidget()
        toolpalettegroup = ToolPaletteGroup(widget)
        for arg in args:
            # A default sort algorithm that just returns the object (this is equivalent to not specifying the sort gorithm)
            sort_algorithm = lambda x: x
            if type(arg) == type(()) and len(arg) > 1 and type(arg[1]) == type(
                {}) and len(arg[1].keys()) > 0:
                # we have a name, use it!
                name = arg[0]
                widget_dict = arg[1]
                if len(arg) > 2:
                    sort_algorithm = arg[2]
            else:
                # ignore things that are not dictionaries or empty dictionaries
                if type(arg) != type({}) or len(arg.keys()) < 1:
                    continue
                if isinstance(self.get_channel(list(arg.keys())[0]), AO):
                    name = 'Analog Outputs'
                elif isinstance(self.get_channel(list(arg.keys())[0]), DO):
                    name = 'Digital Outputs'
                elif isinstance(self.get_channel(list(arg.keys())[0]), Image):
                    name = 'Image Outputs'
                elif isinstance(self.get_channel(list(arg.keys())[0]), DDS):
                    name = 'DDS Outputs'
                elif isinstance(self.get_channel(arg.keys()[0]), AI):
                    name = 'Analog Inputs'
                else:
                    # If it isn't DO, DDS or AO, we should forget about them and move on to the next argument
                    continue
                widget_dict = arg
            # Create tool palette
            if toolpalettegroup.has_palette(name):
                toolpalette = toolpalettegroup.get_palette(name)
            else:
                toolpalette = toolpalettegroup.append_new_palette(name)

            for channel in sorted(widget_dict.keys(), key=sort_algorithm):
                toolpalette.addWidget(widget_dict[channel], True)

        # Add the widget containing the toolpalettegroup to the tab layout
        self.get_tab_layout().addWidget(widget)
        self.get_tab_layout().addItem(
            QSpacerItem(0, 0, QSizePolicy.Minimum,
                        QSizePolicy.MinimumExpanding))
コード例 #2
0
 def auto_place_widgets(self,*args):
     widget = QWidget()
     toolpalettegroup = ToolPaletteGroup(widget)
     for arg in args:
         # A default sort algorithm that just returns the object (this is equivalent to not specifying the sort gorithm)
         sort_algorithm = lambda x: x
         if type(arg) == type(()) and len(arg) > 1 and type(arg[1]) == type({}) and len(arg[1].keys()) > 0:
             # we have a name, use it!
             name = arg[0]
             widget_dict = arg[1]
             if len(arg) > 2:
                 sort_algorithm = arg[2]
         else:
             # ignore things that are not dictionaries or empty dictionaries
             if type(arg) != type({}) or len(arg.keys()) < 1:
                 continue
             if isinstance(self.get_channel(arg.keys()[0]),AO):
                 name = 'Analog Outputs'
             elif isinstance(self.get_channel(arg.keys()[0]),DO):
                 name = 'Digital Outputs'
             elif isinstance(self.get_channel(arg.keys()[0]),DDS):
                 name = 'DDS Outputs'
             else:
                 # If it isn't DO, DDS or AO, we should forget about them and move on to the next argument
                 continue
             widget_dict = arg
         # Create tool palette
         if toolpalettegroup.has_palette(name):
             toolpalette = toolpalettegroup.get_palette(name)
         else:
             toolpalette = toolpalettegroup.append_new_palette(name)
             
         for channel in sorted(widget_dict.keys(),key=sort_algorithm):
             toolpalette.addWidget(widget_dict[channel],True)
      
     # Add the widget containing the toolpalettegroup to the tab layout
     self.get_tab_layout().addWidget(widget)
     self.get_tab_layout().addItem(QSpacerItem(0,0,QSizePolicy.Minimum,QSizePolicy.MinimumExpanding))
コード例 #3
0
ファイル: output_classes.py プロジェクト: synqs/blacs
    @property
    def name(self):
        return self._hardware_name + ' - ' + self._connection_name


if __name__ == '__main__':
    from labscript_utils.qtwidgets.toolpalette import ToolPaletteGroup
    import sys

    qapplication = QApplication(sys.argv)

    window = QWidget()
    layout = QVBoxLayout(window)
    widget = QWidget()
    layout.addWidget(widget)
    tpg = ToolPaletteGroup(widget)
    toolpalette = tpg.append_new_palette('Digital Outputs')
    toolpalette2 = tpg.append_new_palette('Analog Outputs')
    layout.addItem(
        QSpacerItem(0, 0, QSizePolicy.Minimum, QSizePolicy.MinimumExpanding))

    # create settings dictionary
    settings = {
        'front_panel_settings': {
            'do0': {
                'base_value': False,
                'locked': False,
            },
            'ao0': {
                'base_value': 3.0,
                'locked': False,
コード例 #4
0
                    
    @property
    def name(self):
        return self._hardware_name + ' - ' + self._connection_name
        
if __name__ == '__main__':
    from labscript_utils.qtwidgets.toolpalette import ToolPaletteGroup
    import sys
    
    qapplication = QApplication(sys.argv)
    
    window = QWidget()
    layout = QVBoxLayout(window)
    widget = QWidget()
    layout.addWidget(widget)
    tpg = ToolPaletteGroup(widget)
    toolpalette = tpg.append_new_palette('Digital Outputs')    
    toolpalette2 = tpg.append_new_palette('Analog Outputs')    
    layout.addItem(QSpacerItem(0,0,QSizePolicy.Minimum,QSizePolicy.MinimumExpanding))
    
    # create settings dictionary
    settings = {'front_panel_settings':{
                    'do0':{
                        'base_value':False,
                        'locked':False,
                        },
                    'ao0':{
                        'base_value':3.0,
                        'locked':False,
                        'base_step_size':0.1,
                        'current_units':'V',