当前位置: 首页>>代码示例>>Python>>正文


Python tools.LayoutWidget类代码示例

本文整理汇总了Python中artiq.gui.tools.LayoutWidget的典型用法代码示例。如果您正苦于以下问题:Python LayoutWidget类的具体用法?Python LayoutWidget怎么用?Python LayoutWidget使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了LayoutWidget类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

    def __init__(self, argument):
        LayoutWidget.__init__(self)
        self.argument = argument

        self.stack = QtWidgets.QStackedWidget()
        self.addWidget(self.stack, 1, 0, colspan=4)

        procdesc = argument["desc"]
        state = argument["state"]
        self.widgets = OrderedDict()
        self.widgets["NoScan"] = _NoScan(procdesc, state["NoScan"])
        self.widgets["LinearScan"] = _RangeScan(procdesc, state["LinearScan"])
        self.widgets["RandomScan"] = _RangeScan(procdesc, state["RandomScan"])
        self.widgets["ExplicitScan"] = _ExplicitScan(state["ExplicitScan"])
        for widget in self.widgets.values():
            self.stack.addWidget(widget)

        self.radiobuttons = OrderedDict()
        self.radiobuttons["NoScan"] = QtWidgets.QRadioButton("No scan")
        self.radiobuttons["LinearScan"] = QtWidgets.QRadioButton("Linear")
        self.radiobuttons["RandomScan"] = QtWidgets.QRadioButton("Random")
        self.radiobuttons["ExplicitScan"] = QtWidgets.QRadioButton("Explicit")
        scan_type = QtWidgets.QButtonGroup()
        for n, b in enumerate(self.radiobuttons.values()):
            self.addWidget(b, 0, n)
            scan_type.addButton(b)
            b.toggled.connect(self._scan_type_toggled)

        selected = argument["state"]["selected"]
        self.radiobuttons[selected].setChecked(True)
开发者ID:amhankin,项目名称:artiq,代码行数:30,代码来源:entries.py

示例2: __init__

    def __init__(self, datasets_sub, dataset_ctl):
        QtWidgets.QDockWidget.__init__(self, "Datasets")
        self.setObjectName("Datasets")
        self.setFeatures(QtWidgets.QDockWidget.DockWidgetMovable |
                         QtWidgets.QDockWidget.DockWidgetFloatable)
        self.dataset_ctl = dataset_ctl

        grid = LayoutWidget()
        self.setWidget(grid)

        self.search = QtWidgets.QLineEdit()
        self.search.setPlaceholderText("search...")
        self.search.editingFinished.connect(self._search_datasets)
        grid.addWidget(self.search, 0, 0)

        self.table = QtWidgets.QTreeView()
        self.table.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows)
        self.table.setSelectionMode(
            QtWidgets.QAbstractItemView.SingleSelection)
        grid.addWidget(self.table, 1, 0)

        self.table.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
        delete_action = QtWidgets.QAction("Delete dataset", self.table)
        delete_action.triggered.connect(self.delete_clicked)
        delete_action.setShortcut("DELETE")
        delete_action.setShortcutContext(QtCore.Qt.WidgetShortcut)
        self.table.addAction(delete_action)

        self.table_model = Model(dict())
        datasets_sub.add_setmodel_callback(self.set_model)
开发者ID:amhankin,项目名称:artiq,代码行数:30,代码来源:datasets.py

示例3: __init__

    def __init__(self, state):
        LayoutWidget.__init__(self)

        self.value = QtWidgets.QLineEdit()
        self.addWidget(QtWidgets.QLabel("Sequence:"), 0, 0)
        self.addWidget(self.value, 0, 1)

        float_regexp = "[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?"
        regexp = "(float)?( +float)* *".replace("float", float_regexp)
        self.value.setValidator(QtGui.QRegExpValidator(QtCore.QRegExp(regexp),
                                                       self.value))

        self.value.setText(" ".join([str(x) for x in state["sequence"]]))
        def update(text):
            state["sequence"] = [float(x) for x in text.split()]
        self.value.textEdited.connect(update)
开发者ID:cntnly,项目名称:artiq,代码行数:16,代码来源:entries.py

示例4: __init__

    def __init__(self, procdesc, state):
        LayoutWidget.__init__(self)

        scale = procdesc["scale"]
        self.value = ScientificSpinBox()
        disable_scroll_wheel(self.value)
        self.value.setDecimals(procdesc["ndecimals"])
        self.value.setPrecision()
        if procdesc["global_min"] is not None:
            self.value.setMinimum(procdesc["global_min"] / scale)
        else:
            self.value.setMinimum(float("-inf"))
        if procdesc["global_max"] is not None:
            self.value.setMaximum(procdesc["global_max"] / scale)
        else:
            self.value.setMaximum(float("inf"))
        self.value.setSingleStep(procdesc["global_step"] / scale)
        self.value.setRelativeStep()
        if procdesc["unit"]:
            self.value.setSuffix(" " + procdesc["unit"])
        self.addWidget(QtWidgets.QLabel("Value:"), 0, 0)
        self.addWidget(self.value, 0, 1)

        self.value.setValue(state["value"] / scale)

        def update(value):
            state["value"] = value * scale

        self.value.valueChanged.connect(update)

        self.repetitions = QtWidgets.QSpinBox()
        self.repetitions.setMinimum(1)
        self.repetitions.setMaximum((1 << 31) - 1)
        disable_scroll_wheel(self.repetitions)
        self.addWidget(QtWidgets.QLabel("Repetitions:"), 1, 0)
        self.addWidget(self.repetitions, 1, 1)

        self.repetitions.setValue(state["repetitions"])

        def update_repetitions(value):
            state["repetitions"] = value

        self.repetitions.valueChanged.connect(update_repetitions)
开发者ID:cjbe,项目名称:artiq,代码行数:43,代码来源:entries.py

示例5: __init__

    def __init__(self, channel, send_to_device, force_out, title):
        self.channel = channel
        self.send_to_device = send_to_device
        self.force_out = force_out

        _MoninjWidget.__init__(self)

        grid = QtWidgets.QGridLayout()
        self.setLayout(grid)
        label = QtWidgets.QLabel(title)
        label.setAlignment(QtCore.Qt.AlignCenter)
        label.setWordWrap(True)
        grid.addWidget(label, 1, 1)

        self.stack = QtWidgets.QStackedWidget()
        grid.addWidget(self.stack, 2, 1)

        self.direction = QtWidgets.QLabel()
        self.direction.setAlignment(QtCore.Qt.AlignCenter)
        self.stack.addWidget(self.direction)

        grid_cb = LayoutWidget()
        self.override = QtWidgets.QCheckBox("Override")
        grid_cb.addWidget(self.override, 3, 1)
        self.level = QtWidgets.QCheckBox("Level")
        grid_cb.addWidget(self.level, 3, 2)
        self.stack.addWidget(grid_cb)

        self.value = QtWidgets.QLabel()
        self.value.setAlignment(QtCore.Qt.AlignCenter)
        grid.addWidget(self.value, 3, 1)

        grid.setRowStretch(1, 1)
        grid.setRowStretch(2, 0)
        grid.setRowStretch(3, 0)
        grid.setRowStretch(4, 1)

        self.programmatic_change = False
        self.override.stateChanged.connect(self.override_toggled)
        self.level.stateChanged.connect(self.level_toggled)

        self.set_value(0, False, False)
开发者ID:cntnly,项目名称:artiq,代码行数:42,代码来源:moninj.py

示例6: __init__

    def __init__(self, datasets_sub):
        QtWidgets.QDockWidget.__init__(self, "Datasets")
        self.setObjectName("Datasets")
        self.setFeatures(QtWidgets.QDockWidget.DockWidgetMovable |
                         QtWidgets.QDockWidget.DockWidgetFloatable)

        grid = LayoutWidget()
        self.setWidget(grid)

        self.search = QtWidgets.QLineEdit()
        self.search.setPlaceholderText("search...")
        self.search.editingFinished.connect(self._search_datasets)
        grid.addWidget(self.search, 0, 0)

        self.table = QtWidgets.QTreeView()
        self.table.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows)
        self.table.setSelectionMode(
            QtWidgets.QAbstractItemView.SingleSelection)
        grid.addWidget(self.table, 1, 0)

        self.table_model = Model(dict())
        datasets_sub.add_setmodel_callback(self.set_model)
开发者ID:cntnly,项目名称:artiq,代码行数:22,代码来源:datasets.py

示例7: __init__

    def __init__(self, manager, dock, expurl):
        self.manager = manager
        self.expurl = expurl

        QtWidgets.QTreeWidget.__init__(self)
        self.setColumnCount(3)
        self.header().setStretchLastSection(False)
        if hasattr(self.header(), "setSectionResizeMode"):
            set_resize_mode = self.header().setSectionResizeMode
        else:
            set_resize_mode = self.header().setResizeMode
        set_resize_mode(0, QtWidgets.QHeaderView.ResizeToContents)
        set_resize_mode(1, QtWidgets.QHeaderView.Stretch)
        set_resize_mode(2, QtWidgets.QHeaderView.ResizeToContents)
        self.header().setVisible(False)
        self.setSelectionMode(self.NoSelection)
        self.setHorizontalScrollMode(self.ScrollPerPixel)
        self.setVerticalScrollMode(self.ScrollPerPixel)

        self.setStyleSheet("QTreeWidget {background: " +
                           self.palette().midlight().color().name() + " ;}")

        self.viewport().installEventFilter(_WheelFilter(self.viewport()))

        self._groups = dict()
        self._arg_to_widgets = dict()

        arguments = self.manager.get_submission_arguments(self.expurl)

        if not arguments:
            self.addTopLevelItem(QtWidgets.QTreeWidgetItem(["No arguments"]))

        gradient = QtGui.QLinearGradient(
            0, 0, 0, QtGui.QFontMetrics(self.font()).lineSpacing()*2.5)
        gradient.setColorAt(0, self.palette().base().color())
        gradient.setColorAt(1, self.palette().midlight().color())
        for name, argument in arguments.items():
            widgets = dict()
            self._arg_to_widgets[name] = widgets

            entry = procdesc_to_entry(argument["desc"])(argument)
            widget_item = QtWidgets.QTreeWidgetItem([name])
            if argument["tooltip"]:
                widget_item.setToolTip(0, argument["tooltip"])
            widgets["entry"] = entry
            widgets["widget_item"] = widget_item

            for col in range(3):
                widget_item.setBackground(col, gradient)
            font = widget_item.font(0)
            font.setBold(True)
            widget_item.setFont(0, font)

            if argument["group"] is None:
                self.addTopLevelItem(widget_item)
            else:
                self._get_group(argument["group"]).addChild(widget_item)
            fix_layout = LayoutWidget()
            widgets["fix_layout"] = fix_layout
            fix_layout.addWidget(entry)
            self.setItemWidget(widget_item, 1, fix_layout)
            recompute_argument = QtWidgets.QToolButton()
            recompute_argument.setToolTip("Re-run the experiment's build "
                                          "method and take the default value")
            recompute_argument.setIcon(
                QtWidgets.QApplication.style().standardIcon(
                    QtWidgets.QStyle.SP_BrowserReload))
            recompute_argument.clicked.connect(
                partial(self._recompute_argument_clicked, name))

            tool_buttons = LayoutWidget()
            tool_buttons.addWidget(recompute_argument, 1)

            disable_other_scans = QtWidgets.QToolButton()
            widgets["disable_other_scans"] = disable_other_scans
            disable_other_scans.setIcon(
                QtWidgets.QApplication.style().standardIcon(
                    QtWidgets.QStyle.SP_DialogResetButton))
            disable_other_scans.setToolTip("Disable all other scans in "
                                           "this experiment")
            disable_other_scans.clicked.connect(
                partial(self._disable_other_scans, name))
            tool_buttons.layout.setRowStretch(0, 1)
            tool_buttons.layout.setRowStretch(3, 1)
            tool_buttons.addWidget(disable_other_scans, 2)
            if not isinstance(entry, ScanEntry):
                disable_other_scans.setVisible(False)

            self.setItemWidget(widget_item, 2, tool_buttons)

        widget_item = QtWidgets.QTreeWidgetItem()
        self.addTopLevelItem(widget_item)
        recompute_arguments = QtWidgets.QPushButton("Recompute all arguments")
        recompute_arguments.setIcon(
            QtWidgets.QApplication.style().standardIcon(
                QtWidgets.QStyle.SP_BrowserReload))
        recompute_arguments.clicked.connect(dock._recompute_arguments_clicked)

        load_hdf5 = QtWidgets.QPushButton("Load HDF5")
        load_hdf5.setIcon(QtWidgets.QApplication.style().standardIcon(
#.........这里部分代码省略.........
开发者ID:m-labs,项目名称:artiq,代码行数:101,代码来源:experiments.py

示例8: __init__

    def __init__(self, channel, set_mode, force_out, title):
        QtWidgets.QFrame.__init__(self)

        self.channel = channel
        self.set_mode = set_mode
        self.force_out = force_out

        self.setFrameShape(QtWidgets.QFrame.Box)
        self.setFrameShadow(QtWidgets.QFrame.Raised)

        grid = QtWidgets.QGridLayout()
        grid.setContentsMargins(0, 0, 0, 0)
        grid.setHorizontalSpacing(0)
        grid.setVerticalSpacing(0)
        self.setLayout(grid)
        label = QtWidgets.QLabel(title)
        label.setAlignment(QtCore.Qt.AlignCenter)
        label.setSizePolicy(QtWidgets.QSizePolicy.Ignored,
                            QtWidgets.QSizePolicy.Preferred)
        grid.addWidget(label, 1, 1)

        self.stack = QtWidgets.QStackedWidget()
        grid.addWidget(self.stack, 2, 1)

        self.direction = QtWidgets.QLabel()
        self.direction.setAlignment(QtCore.Qt.AlignCenter)
        self.stack.addWidget(self.direction)

        grid_cb = LayoutWidget()
        grid_cb.layout.setContentsMargins(0, 0, 0, 0)
        grid_cb.layout.setHorizontalSpacing(0)
        grid_cb.layout.setVerticalSpacing(0)
        self.override = QtWidgets.QToolButton()
        self.override.setText("OVR")
        self.override.setCheckable(True)
        self.override.setToolTip("Override")
        grid_cb.addWidget(self.override, 3, 1)
        self.level = QtWidgets.QToolButton()
        self.level.setText("LVL")
        self.level.setCheckable(True)
        self.level.setToolTip("Level")
        grid_cb.addWidget(self.level, 3, 2)
        self.stack.addWidget(grid_cb)

        self.value = QtWidgets.QLabel()
        self.value.setAlignment(QtCore.Qt.AlignCenter)
        grid.addWidget(self.value, 3, 1)

        grid.setRowStretch(1, 1)
        grid.setRowStretch(2, 0)
        grid.setRowStretch(3, 0)
        grid.setRowStretch(4, 1)

        self.programmatic_change = False
        self.override.clicked.connect(self.override_toggled)
        self.level.clicked.connect(self.level_toggled)

        self.cur_level = False
        self.cur_oe = False
        self.cur_override = False
        self.refresh_display()
开发者ID:JQIamo,项目名称:artiq,代码行数:61,代码来源:moninj.py

示例9: __init__

    def __init__(self, exp_manager, d_shortcuts, explist_sub, explist_status_sub, schedule_ctl, experiment_db_ctl):
        QtWidgets.QDockWidget.__init__(self, "Explorer")
        self.setObjectName("Explorer")
        self.setFeatures(QtWidgets.QDockWidget.DockWidgetMovable | QtWidgets.QDockWidget.DockWidgetFloatable)

        top_widget = LayoutWidget()
        self.setWidget(top_widget)

        self.exp_manager = exp_manager
        self.d_shortcuts = d_shortcuts
        self.schedule_ctl = schedule_ctl

        top_widget.addWidget(QtWidgets.QLabel("Revision:"), 0, 0)
        self.revision = QtWidgets.QLabel()
        self.revision.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse)
        top_widget.addWidget(self.revision, 0, 1)

        self.stack = QtWidgets.QStackedWidget()
        top_widget.addWidget(self.stack, 1, 0, colspan=2)

        self.el_buttons = LayoutWidget()
        self.el_buttons.layout.setContentsMargins(0, 0, 0, 0)
        self.stack.addWidget(self.el_buttons)

        self.el = QtWidgets.QTreeView()
        self.el.setHeaderHidden(True)
        self.el.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectItems)
        self.el.doubleClicked.connect(partial(self.expname_action, "open_experiment"))
        self.el_buttons.addWidget(self.el, 0, 0, colspan=2)

        open = QtWidgets.QPushButton("Open")
        open.setIcon(QtWidgets.QApplication.style().standardIcon(QtWidgets.QStyle.SP_DialogOpenButton))
        open.setToolTip("Open the selected experiment (Return)")
        self.el_buttons.addWidget(open, 1, 0)
        open.clicked.connect(partial(self.expname_action, "open_experiment"))

        submit = QtWidgets.QPushButton("Submit")
        submit.setIcon(QtWidgets.QApplication.style().standardIcon(QtWidgets.QStyle.SP_DialogOkButton))
        submit.setToolTip("Schedule the selected experiment (Ctrl+Return)")
        self.el_buttons.addWidget(submit, 1, 1)
        submit.clicked.connect(partial(self.expname_action, "submit"))

        self.explist_model = Model(dict())
        explist_sub.add_setmodel_callback(self.set_model)

        self.el.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
        open_action = QtWidgets.QAction("Open", self.el)
        open_action.triggered.connect(partial(self.expname_action, "open_experiment"))
        open_action.setShortcut("RETURN")
        open_action.setShortcutContext(QtCore.Qt.WidgetShortcut)
        self.el.addAction(open_action)
        submit_action = QtWidgets.QAction("Submit", self.el)
        submit_action.triggered.connect(partial(self.expname_action, "submit"))
        submit_action.setShortcut("CTRL+RETURN")
        submit_action.setShortcutContext(QtCore.Qt.WidgetShortcut)
        self.el.addAction(submit_action)
        reqterm_action = QtWidgets.QAction("Request termination of instances", self.el)
        reqterm_action.triggered.connect(partial(self.expname_action, "request_inst_term"))
        reqterm_action.setShortcut("CTRL+BACKSPACE")
        reqterm_action.setShortcutContext(QtCore.Qt.WidgetShortcut)
        self.el.addAction(reqterm_action)

        set_shortcut_menu = QtWidgets.QMenu()
        for i in range(12):
            action = QtWidgets.QAction("F" + str(i + 1), self.el)
            action.triggered.connect(partial(self.set_shortcut, i))
            set_shortcut_menu.addAction(action)

        set_shortcut_action = QtWidgets.QAction("Set shortcut", self.el)
        set_shortcut_action.setMenu(set_shortcut_menu)
        self.el.addAction(set_shortcut_action)

        sep = QtWidgets.QAction(self.el)
        sep.setSeparator(True)
        self.el.addAction(sep)

        scan_repository_action = QtWidgets.QAction("Scan repository HEAD", self.el)

        def scan_repository():
            asyncio.ensure_future(experiment_db_ctl.scan_repository_async())

        scan_repository_action.triggered.connect(scan_repository)
        self.el.addAction(scan_repository_action)

        self.current_directory = ""
        open_file_action = QtWidgets.QAction("Open file outside repository", self.el)
        open_file_action.triggered.connect(lambda: _OpenFileDialog(self, self.exp_manager, experiment_db_ctl).open())
        self.el.addAction(open_file_action)

        self.waiting_panel = WaitingPanel()
        self.stack.addWidget(self.waiting_panel)
        explist_status_sub.add_setmodel_callback(lambda updater: updater.set_explorer(self))
开发者ID:cjbe,项目名称:artiq,代码行数:92,代码来源:explorer.py

示例10: __init__

    def __init__(self, datasets_sub, master_host, master_port):
        QtWidgets.QDockWidget.__init__(self, "Datasets")
        self.setObjectName("Datasets")
        self.setFeatures(QtWidgets.QDockWidget.DockWidgetMovable |
                         QtWidgets.QDockWidget.DockWidgetFloatable)

        grid = LayoutWidget()
        self.setWidget(grid)

        self.search = QtWidgets.QLineEdit()
        self.search.setPlaceholderText("search...")
        self.search.editingFinished.connect(self._search_datasets)
        grid.addWidget(self.search, 0, 0)

        self.table = QtWidgets.QTreeView()
        self.table.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows)
        self.table.setSelectionMode(
            QtWidgets.QAbstractItemView.SingleSelection)
        grid.addWidget(self.table, 1, 0)

        metadata_grid = LayoutWidget()
        self.metadata = {}
        for i, label in enumerate("artiq_version repo_rev file class_name "
                                  "rid start_time".split()):
            metadata_grid.addWidget(QtWidgets.QLabel(label), i, 0)
            v = QtWidgets.QLabel()
            v.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse)
            metadata_grid.addWidget(v, i, 1)
            self.metadata[label] = v
        grid.addWidget(metadata_grid, 2, 0)

        self.table.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
        upload_action = QtWidgets.QAction("Upload dataset to master",
                                          self.table)
        upload_action.triggered.connect(self.upload_clicked)
        self.table.addAction(upload_action)

        self.set_model(Model(dict()))
        datasets_sub.add_setmodel_callback(self.set_model)

        self.master_host = master_host
        self.master_port = master_port
开发者ID:JQIamo,项目名称:artiq,代码行数:42,代码来源:datasets.py

示例11: __init__

    def __init__(self, procdesc, state):
        LayoutWidget.__init__(self)

        scale = procdesc["scale"]

        def apply_properties(widget):
            widget.setDecimals(procdesc["ndecimals"])
            if procdesc["global_min"] is not None:
                widget.setMinimum(procdesc["global_min"]/scale)
            else:
                widget.setMinimum(float("-inf"))
            if procdesc["global_max"] is not None:
                widget.setMaximum(procdesc["global_max"]/scale)
            else:
                widget.setMaximum(float("inf"))
            if procdesc["global_step"] is not None:
                widget.setSingleStep(procdesc["global_step"]/scale)
            if procdesc["unit"]:
                widget.setSuffix(" " + procdesc["unit"])

        center = ScientificSpinBox()
        disable_scroll_wheel(center)
        apply_properties(center)
        center.setPrecision()
        center.setRelativeStep()
        center.setValue(state["center"])
        self.addWidget(center, 0, 1)
        self.addWidget(QtWidgets.QLabel("Center:"), 0, 0)

        span = ScientificSpinBox()
        disable_scroll_wheel(span)
        apply_properties(span)
        span.setPrecision()
        span.setRelativeStep()
        span.setMinimum(0)
        span.setValue(state["span"])
        self.addWidget(span, 1, 1)
        self.addWidget(QtWidgets.QLabel("Span:"), 1, 0)

        step = ScientificSpinBox()
        disable_scroll_wheel(step)
        apply_properties(step)
        step.setPrecision()
        step.setRelativeStep()
        step.setMinimum(0)
        step.setValue(state["step"])
        self.addWidget(step, 2, 1)
        self.addWidget(QtWidgets.QLabel("Step:"), 2, 0)

        randomize = QtWidgets.QCheckBox("Randomize")
        self.addWidget(randomize, 3, 1)
        randomize.setChecked(state["randomize"])

        def update_center(value):
            state["center"] = value*scale

        def update_span(value):
            state["span"] = value*scale

        def update_step(value):
            state["step"] = value*scale

        def update_randomize(value):
            state["randomize"] = value

        center.valueChanged.connect(update_center)
        span.valueChanged.connect(update_span)
        step.valueChanged.connect(update_step)
        randomize.stateChanged.connect(update_randomize)
开发者ID:m-labs,项目名称:artiq,代码行数:69,代码来源:entries.py

示例12: __init__

    def __init__(self, manager, name):
        QDockWidgetCloseDetect.__init__(self, "Log")
        self.setObjectName(name)

        grid = LayoutWidget()
        self.setWidget(grid)

        grid.addWidget(QtWidgets.QLabel("Minimum level: "), 0, 0)
        self.filter_level = QtWidgets.QComboBox()
        self.filter_level.addItems(["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"])
        self.filter_level.setToolTip("Receive entries at or above this level")
        grid.addWidget(self.filter_level, 0, 1)
        self.filter_freetext = QtWidgets.QLineEdit()
        self.filter_freetext.setPlaceholderText("freetext filter...")
        self.filter_freetext.setToolTip("Receive entries containing this text")
        grid.addWidget(self.filter_freetext, 0, 2)

        scrollbottom = QtWidgets.QToolButton()
        scrollbottom.setToolTip("Scroll to bottom")
        scrollbottom.setIcon(QtWidgets.QApplication.style().standardIcon(
            QtWidgets.QStyle.SP_ArrowDown))
        grid.addWidget(scrollbottom, 0, 3)
        scrollbottom.clicked.connect(self.scroll_to_bottom)

        clear = QtWidgets.QToolButton()
        clear.setIcon(QtWidgets.QApplication.style().standardIcon(
            QtWidgets.QStyle.SP_DialogResetButton))
        grid.addWidget(clear, 0, 4)
        clear.clicked.connect(lambda: self.model.clear())

        if manager:
            newdock = QtWidgets.QToolButton()
            newdock.setToolTip("Create new log dock")
            newdock.setIcon(QtWidgets.QApplication.style().standardIcon(
                QtWidgets.QStyle.SP_FileDialogNewFolder))
            # note the lambda, the default parameter is overriden otherwise
            newdock.clicked.connect(lambda: manager.create_new_dock())
            grid.addWidget(newdock, 0, 5)
        grid.layout.setColumnStretch(2, 1)

        self.log = QtWidgets.QTreeView()
        self.log.setSelectionMode(QtWidgets.QAbstractItemView.NoSelection)
        self.log.setHorizontalScrollMode(
            QtWidgets.QAbstractItemView.ScrollPerPixel)
        self.log.setVerticalScrollMode(
            QtWidgets.QAbstractItemView.ScrollPerPixel)
        self.log.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
        grid.addWidget(self.log, 1, 0, colspan=6 if manager else 5)
        self.scroll_at_bottom = False
        self.scroll_value = 0

        # If Qt worked correctly, this would be nice to have. Alas, resizeSections
        # is broken when the horizontal scrollbar is enabled.
        # self.log.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
        # sizeheader_action = QtWidgets.QAction("Resize header", self.log)
        # sizeheader_action.triggered.connect(
        #     lambda: self.log.header().resizeSections(QtWidgets.QHeaderView.ResizeToContents))
        # self.log.addAction(sizeheader_action)

        cw = QtGui.QFontMetrics(self.font()).averageCharWidth()
        self.log.header().resizeSection(0, 26*cw)

        self.model = _Model()
        self.log.setModel(self.model)
        self.model.rowsAboutToBeInserted.connect(self.rows_inserted_before)
        self.model.rowsInserted.connect(self.rows_inserted_after)
        self.model.rowsRemoved.connect(self.rows_removed)
开发者ID:amhankin,项目名称:artiq,代码行数:67,代码来源:log.py

示例13: __init__

    def __init__(self, dock):
        QtWidgets.QTreeWidget.__init__(self)
        self.setColumnCount(3)
        self.header().setStretchLastSection(False)
        try:
            set_resize_mode = self.header().setSectionResizeMode
        except AttributeError:
            set_resize_mode = self.header().setResizeMode
        set_resize_mode(0, QtWidgets.QHeaderView.ResizeToContents)
        set_resize_mode(1, QtWidgets.QHeaderView.Stretch)
        set_resize_mode(2, QtWidgets.QHeaderView.ResizeToContents)
        self.header().setVisible(False)
        self.setSelectionMode(self.NoSelection)
        self.setHorizontalScrollMode(self.ScrollPerPixel)
        self.setVerticalScrollMode(self.ScrollPerPixel)

        self.viewport().installEventFilter(_WheelFilter(self.viewport()))

        self._groups = dict()
        self._arg_to_entry_widgetitem = dict()
        self._dock = dock

        if not self._dock.arguments:
            self.addTopLevelItem(QtWidgets.QTreeWidgetItem(["No arguments"]))

        for name, argument in self._dock.arguments.items():
            try:
                entry = argty_to_entry[argument["desc"]["ty"]](argument)
            except:
                print(name, argument)
            widget_item = QtWidgets.QTreeWidgetItem([name])
            self._arg_to_entry_widgetitem[name] = entry, widget_item

            if argument["group"] is None:
                self.addTopLevelItem(widget_item)
            else:
                self._get_group(argument["group"]).addChild(widget_item)
            self.setItemWidget(widget_item, 1, entry)
            recompute_argument = QtWidgets.QToolButton()
            recompute_argument.setToolTip("Re-run the experiment's build "
                                          "method and take the default value")
            recompute_argument.setIcon(
                QtWidgets.QApplication.style().standardIcon(
                    QtWidgets.QStyle.SP_BrowserReload))
            recompute_argument.clicked.connect(
                partial(self._recompute_argument_clicked, name))
            fix_layout = LayoutWidget()
            fix_layout.addWidget(recompute_argument)
            self.setItemWidget(widget_item, 2, fix_layout)

        widget_item = QtWidgets.QTreeWidgetItem()
        self.addTopLevelItem(widget_item)
        recompute_arguments = QtWidgets.QPushButton("Recompute all arguments")
        recompute_arguments.setIcon(
            QtWidgets.QApplication.style().standardIcon(
                QtWidgets.QStyle.SP_BrowserReload))
        recompute_arguments.clicked.connect(self._recompute_arguments_clicked)

        buttons = LayoutWidget()
        buttons.addWidget(recompute_arguments, 1, 1)
        for i, s in enumerate((1, 0, 0, 1)):
            buttons.layout.setColumnStretch(i, s)
        self.setItemWidget(widget_item, 1, buttons)
开发者ID:amhankin,项目名称:artiq,代码行数:63,代码来源:experiments.py


注:本文中的artiq.gui.tools.LayoutWidget类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。