本文整理汇总了Python中AnyQt.QtWidgets.QGraphicsView.width方法的典型用法代码示例。如果您正苦于以下问题:Python QGraphicsView.width方法的具体用法?Python QGraphicsView.width怎么用?Python QGraphicsView.width使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtWidgets.QGraphicsView
的用法示例。
在下文中一共展示了QGraphicsView.width方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: OWPythagoreanForest
# 需要导入模块: from AnyQt.QtWidgets import QGraphicsView [as 别名]
# 或者: from AnyQt.QtWidgets.QGraphicsView import width [as 别名]
#.........这里部分代码省略.........
self.grid.clear()
self._clear_info_box()
self._clear_target_class_combo()
self._clear_depth_slider()
# CONTROL AREA CALLBACKS
def max_depth_changed(self):
"""When the max depth slider is changed."""
for tree in self.ptrees:
tree.set_depth_limit(self.depth_limit)
def target_colors_changed(self):
"""When the target class or coloring method is changed."""
for tree in self.ptrees:
tree.target_class_has_changed()
def size_calc_changed(self):
"""When the size calculation of the trees is changed."""
if self.model is not None:
self.forest_adapter = self._get_forest_adapter(self.model)
self.grid.clear()
self._draw_trees()
# Keep the selected item
if self.selected_tree_index != -1:
self.grid_items[self.selected_tree_index].setSelected(True)
self.max_depth_changed()
def zoom_changed(self):
"""When we update the "Zoom" slider."""
for item in self.grid_items:
item.set_max_size(self._calculate_zoom(self.zoom))
width = (self.view.width() - self.view.verticalScrollBar().width())
self.grid.reflow(width)
self.grid.setPreferredWidth(width)
# MODEL CHANGED METHODS
def _update_info_box(self):
self.ui_info.setText(
'Trees: {}'.format(len(self.forest_adapter.get_trees()))
)
def _update_depth_slider(self):
self.depth_limit = self._get_max_depth()
self.ui_depth_slider.parent().setEnabled(True)
self.ui_depth_slider.setMaximum(self.depth_limit)
self.ui_depth_slider.setValue(self.depth_limit)
# MODEL CLEARED METHODS
def _clear_info_box(self):
self.ui_info.setText('No forest on input.')
def _clear_target_class_combo(self):
self.ui_target_class_combo.clear()
self.target_class_index = 0
self.ui_target_class_combo.setCurrentIndex(self.target_class_index)
def _clear_depth_slider(self):
self.ui_depth_slider.parent().setEnabled(False)
self.ui_depth_slider.setMaximum(0)
# HELPFUL METHODS
def _get_max_depth(self):
return max([tree.tree_adapter.max_depth for tree in self.ptrees])
示例2: OWPythagoreanForest
# 需要导入模块: from AnyQt.QtWidgets import QGraphicsView [as 别名]
# 或者: from AnyQt.QtWidgets.QGraphicsView import width [as 别名]
#.........这里部分代码省略.........
self.grid_items = []
self.grid.clear()
self._clear_info_box()
self._clear_target_class_combo()
self._clear_depth_slider()
def update_depth(self):
"""When the max depth slider is changed."""
for tree in self.ptrees:
tree.set_depth_limit(self.depth_limit)
def update_colors(self):
"""When the target class or coloring method is changed."""
for tree in self.ptrees:
tree.target_class_changed(self.target_class_index)
def update_size_calc(self):
"""When the size calculation of the trees is changed."""
if self.model is not None:
with self._prevent_commit():
self.grid.clear()
self._draw_trees()
# Keep the selected item
if self.selected_tree_index != -1:
self.grid_items[self.selected_tree_index].setSelected(True)
self.update_depth()
def zoom_changed(self):
"""When we update the "Zoom" slider."""
for item in self.grid_items:
item.set_max_size(self._calculate_zoom(self.zoom))
width = (self.view.width() - self.view.verticalScrollBar().width())
self.grid.reflow(width)
self.grid.setPreferredWidth(width)
@contextmanager
def _prevent_commit(self):
try:
self.__prevent_commit = True
yield
finally:
self.__prevent_commit = False
def _update_info_box(self):
self.ui_info.setText('Trees: {}'.format(len(self.forest_adapter.get_trees())))
def _update_depth_slider(self):
self.depth_limit = self._get_max_depth()
self.ui_depth_slider.parent().setEnabled(True)
self.ui_depth_slider.setMaximum(self.depth_limit)
self.ui_depth_slider.setValue(self.depth_limit)
def _clear_info_box(self):
self.ui_info.setText('No forest on input.')
def _clear_target_class_combo(self):
self.ui_target_class_combo.clear()
self.target_class_index = 0
self.ui_target_class_combo.setCurrentIndex(self.target_class_index)
def _clear_depth_slider(self):
self.ui_depth_slider.parent().setEnabled(False)
self.ui_depth_slider.setMaximum(0)