本文整理汇总了Python中AnyQt.QtWidgets.QGraphicsView.setVerticalScrollBarPolicy方法的典型用法代码示例。如果您正苦于以下问题:Python QGraphicsView.setVerticalScrollBarPolicy方法的具体用法?Python QGraphicsView.setVerticalScrollBarPolicy怎么用?Python QGraphicsView.setVerticalScrollBarPolicy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtWidgets.QGraphicsView
的用法示例。
在下文中一共展示了QGraphicsView.setVerticalScrollBarPolicy方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: EditLinksDialog
# 需要导入模块: from AnyQt.QtWidgets import QGraphicsView [as 别名]
# 或者: from AnyQt.QtWidgets.QGraphicsView import setVerticalScrollBarPolicy [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))
示例2: OWPythagoreanForest
# 需要导入模块: from AnyQt.QtWidgets import QGraphicsView [as 别名]
# 或者: from AnyQt.QtWidgets.QGraphicsView import setVerticalScrollBarPolicy [as 别名]
class OWPythagoreanForest(OWWidget):
name = 'Pythagorean Forest'
description = 'Pythagorean forest for visualising random forests.'
icon = 'icons/PythagoreanForest.svg'
priority = 1001
inputs = [('Random forest', RandomForestModel, 'set_rf')]
outputs = [('Tree', TreeModel)]
# Enable the save as feature
graph_name = 'scene'
# Settings
depth_limit = settings.ContextSetting(10)
target_class_index = settings.ContextSetting(0)
size_calc_idx = settings.Setting(0)
size_log_scale = settings.Setting(2)
zoom = settings.Setting(50)
selected_tree_index = settings.ContextSetting(-1)
CLASSIFICATION, REGRESSION = range(2)
def __init__(self):
super().__init__()
# Instance variables
self.forest_type = self.CLASSIFICATION
self.model = None
self.forest_adapter = None
self.dataset = None
self.clf_dataset = None
# We need to store refernces to the trees and grid items
self.grid_items, self.ptrees = [], []
self.color_palette = None
# Different methods to calculate the size of squares
self.SIZE_CALCULATION = [
('Normal', lambda x: x),
('Square root', lambda x: sqrt(x)),
('Logarithmic', lambda x: log(x * self.size_log_scale)),
]
self.REGRESSION_COLOR_CALC = [
('None', lambda _, __: QColor(255, 255, 255)),
('Class mean', self._color_class_mean),
('Standard deviation', self._color_stddev),
]
# CONTROL AREA
# Tree info area
box_info = gui.widgetBox(self.controlArea, 'Forest')
self.ui_info = gui.widgetLabel(box_info, label='')
# Display controls area
box_display = gui.widgetBox(self.controlArea, 'Display')
self.ui_depth_slider = gui.hSlider(
box_display, self, 'depth_limit', label='Depth', ticks=False,
callback=self.max_depth_changed)
self.ui_target_class_combo = gui.comboBox(
box_display, self, 'target_class_index', label='Target class',
orientation=Qt.Horizontal, items=[], contentsLength=8,
callback=self.target_colors_changed)
self.ui_size_calc_combo = gui.comboBox(
box_display, self, 'size_calc_idx', label='Size',
orientation=Qt.Horizontal,
items=list(zip(*self.SIZE_CALCULATION))[0], contentsLength=8,
callback=self.size_calc_changed)
self.ui_zoom_slider = gui.hSlider(
box_display, self, 'zoom', label='Zoom', ticks=False, minValue=20,
maxValue=150, callback=self.zoom_changed, createLabel=False)
# Stretch to fit the rest of the unsused area
gui.rubber(self.controlArea)
self.controlArea.setSizePolicy(
QSizePolicy.Preferred, QSizePolicy.Expanding)
# MAIN AREA
self.scene = QGraphicsScene(self)
self.scene.selectionChanged.connect(self.commit)
self.grid = OWGrid()
self.grid.geometryChanged.connect(self._update_scene_rect)
self.scene.addItem(self.grid)
self.view = QGraphicsView(self.scene)
self.view.setRenderHint(QPainter.Antialiasing, True)
self.view.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
self.mainArea.layout().addWidget(self.view)
self.resize(800, 500)
self.clear()
def set_rf(self, model=None):
"""When a different forest is given."""
self.clear()
self.model = model
if model is not None:
#.........这里部分代码省略.........
示例3: OWPythagoreanForest
# 需要导入模块: from AnyQt.QtWidgets import QGraphicsView [as 别名]
# 或者: from AnyQt.QtWidgets.QGraphicsView import setVerticalScrollBarPolicy [as 别名]
class OWPythagoreanForest(OWWidget):
name = 'Pythagorean Forest'
description = 'Pythagorean forest for visualising random forests.'
icon = 'icons/PythagoreanForest.svg'
priority = 1001
inputs = [('Random forest', RandomForestModel, 'set_rf')]
outputs = [('Tree', TreeModel)]
# Enable the save as feature
graph_name = 'scene'
# Settings
depth_limit = settings.ContextSetting(10)
target_class_index = settings.ContextSetting(0)
size_calc_idx = settings.Setting(0)
zoom = settings.Setting(50)
selected_tree_index = settings.ContextSetting(-1)
def __init__(self):
super().__init__()
self.model = None
self.forest_adapter = None
self.instances = None
self.clf_dataset = None
# We need to store refernces to the trees and grid items
self.grid_items, self.ptrees = [], []
# In some rare cases, we need to prevent commiting, the only one
# that this currently helps is that when changing the size calculation
# the trees are all recomputed, but we don't want to output a new tree
# to keep things consistent with other ui controls.
self.__prevent_commit = False
self.color_palette = None
# Different methods to calculate the size of squares
self.SIZE_CALCULATION = [
('Normal', lambda x: x),
('Square root', lambda x: sqrt(x)),
('Logarithmic', lambda x: log(x + 1)),
]
# CONTROL AREA
# Tree info area
box_info = gui.widgetBox(self.controlArea, 'Forest')
self.ui_info = gui.widgetLabel(box_info)
# Display controls area
box_display = gui.widgetBox(self.controlArea, 'Display')
self.ui_depth_slider = gui.hSlider(
box_display, self, 'depth_limit', label='Depth', ticks=False,
callback=self.update_depth)
self.ui_target_class_combo = gui.comboBox(
box_display, self, 'target_class_index', label='Target class',
orientation=Qt.Horizontal, items=[], contentsLength=8,
callback=self.update_colors)
self.ui_size_calc_combo = gui.comboBox(
box_display, self, 'size_calc_idx', label='Size',
orientation=Qt.Horizontal,
items=list(zip(*self.SIZE_CALCULATION))[0], contentsLength=8,
callback=self.update_size_calc)
self.ui_zoom_slider = gui.hSlider(
box_display, self, 'zoom', label='Zoom', ticks=False, minValue=20,
maxValue=150, callback=self.zoom_changed, createLabel=False)
# Stretch to fit the rest of the unsused area
gui.rubber(self.controlArea)
self.controlArea.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Expanding)
# MAIN AREA
self.scene = QGraphicsScene(self)
self.scene.selectionChanged.connect(self.commit)
self.grid = OWGrid()
self.grid.geometryChanged.connect(self._update_scene_rect)
self.scene.addItem(self.grid)
self.view = QGraphicsView(self.scene)
self.view.setRenderHint(QPainter.Antialiasing, True)
self.view.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
self.mainArea.layout().addWidget(self.view)
self.resize(800, 500)
self.clear()
def set_rf(self, model=None):
"""When a different forest is given."""
self.clear()
self.model = model
if model is not None:
self.forest_adapter = self._get_forest_adapter(self.model)
self._draw_trees()
self.color_palette = self.forest_adapter.get_trees()[0]
self.instances = model.instances
# this bit is important for the regression classifier
if self.instances is not None and self.instances.domain != model.domain:
#.........这里部分代码省略.........