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


Python QGraphicsView.setFixedSize方法代码示例

本文整理汇总了Python中AnyQt.QtWidgets.QGraphicsView.setFixedSize方法的典型用法代码示例。如果您正苦于以下问题:Python QGraphicsView.setFixedSize方法的具体用法?Python QGraphicsView.setFixedSize怎么用?Python QGraphicsView.setFixedSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AnyQt.QtWidgets.QGraphicsView的用法示例。


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

示例1: EditLinksDialog

# 需要导入模块: from AnyQt.QtWidgets import QGraphicsView [as 别名]
# 或者: from AnyQt.QtWidgets.QGraphicsView import setFixedSize [as 别名]
class EditLinksDialog(QDialog):
    """
    A dialog for editing links.

    >>> dlg = EditLinksDialog()
    >>> dlg.setNodes(file_node, test_learners_node)
    >>> dlg.setLinks([(file_node.output_channel("Data"),
    ...               (test_learners_node.input_channel("Data")])
    >>> if dlg.exec_() == EditLinksDialog.Accpeted:
    ...     new_links = dlg.links()
    ...

    """
    def __init__(self, *args, **kwargs):
        QDialog.__init__(self, *args, **kwargs)

        self.setModal(True)

        self.__setupUi()

    def __setupUi(self):
        layout = QVBoxLayout()

        # Scene with the link editor.
        self.scene = LinksEditScene()
        self.view = QGraphicsView(self.scene)
        self.view.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.view.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.view.setRenderHint(QPainter.Antialiasing)

        self.scene.editWidget.geometryChanged.connect(self.__onGeometryChanged)

        # Ok/Cancel/Clear All buttons.
        buttons = QDialogButtonBox(QDialogButtonBox.Ok |
                                   QDialogButtonBox.Cancel |
                                   QDialogButtonBox.Reset,
                                   Qt.Horizontal)

        clear_button = buttons.button(QDialogButtonBox.Reset)
        clear_button.setText(self.tr("Clear All"))

        buttons.accepted.connect(self.accept)
        buttons.rejected.connect(self.reject)
        clear_button.clicked.connect(self.scene.editWidget.clearLinks)

        layout.addWidget(self.view)
        layout.addWidget(buttons)

        self.setLayout(layout)
        layout.setSizeConstraint(QVBoxLayout.SetFixedSize)

        self.setSizeGripEnabled(False)

    def setNodes(self, source_node, sink_node):
        """
        Set the source/sink nodes (:class:`.SchemeNode` instances)
        between which to edit the links.

        .. note:: This should be called before :func:`setLinks`.

        """
        self.scene.editWidget.setNodes(source_node, sink_node)

    def setLinks(self, links):
        """
        Set a list of links to display between the source and sink
        nodes. The `links` is a list of (`OutputSignal`, `InputSignal`)
        tuples where the first element is an output signal of the source
        node and the second an input signal of the sink node.

        """
        self.scene.editWidget.setLinks(links)

    def links(self):
        """
        Return the links between the source and sink node.
        """
        return self.scene.editWidget.links()

    def __onGeometryChanged(self):
        size = self.scene.editWidget.size()
        left, top, right, bottom = self.getContentsMargins()
        self.view.setFixedSize(size.toSize() + \
                               QSize(left + right + 4, top + bottom + 4))
开发者ID:RachitKansal,项目名称:orange3,代码行数:86,代码来源:editlinksdialog.py


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