本文整理汇总了Python中canvas.Canvas.scale方法的典型用法代码示例。如果您正苦于以下问题:Python Canvas.scale方法的具体用法?Python Canvas.scale怎么用?Python Canvas.scale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类canvas.Canvas
的用法示例。
在下文中一共展示了Canvas.scale方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MainWindow
# 需要导入模块: from canvas import Canvas [as 别名]
# 或者: from canvas.Canvas import scale [as 别名]
class MainWindow(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
self._create_actions()
self._create_toolbar()
self._canvas = Canvas()
self._canvas.scale(16, 16)
self.setCentralWidget(self._canvas)
def _create_actions(self):
self._delete_action = QAction("Delete", None)
self._delete_action.setShortcuts(QKeySequence.Delete)
self._delete_action.triggered.connect(self._delete)
self._select_action = QAction("Select", None)
self._select_action.setCheckable(True)
self._select_action.triggered.connect(self._use_select_tool)
self._pen_action = QAction("Pen", None)
self._pen_action.setCheckable(True)
self._pen_action.setChecked(True)
self._pen_action.triggered.connect(self._use_pen_tool)
self._new_shape_action = QAction("New Shape", None)
self._new_shape_action.triggered.connect(self._new_shape)
self._tool_group = QActionGroup(None)
self._tool_group.addAction(self._select_action)
self._tool_group.addAction(self._pen_action)
def _create_toolbar(self):
toolbar = self.addToolBar("Tools")
toolbar.addAction(self._delete_action)
toolbar.addAction(self._select_action)
toolbar.addAction(self._pen_action)
toolbar.addAction(self._new_shape_action)
def _use_select_tool(self):
self._canvas.use_tool(SelectTool)
def _use_pen_tool(self):
self._canvas.use_tool(PenTool)
def _new_shape(self):
self._canvas.new_shape()
def _delete(self):
self._canvas.delete_selection()