本文整理汇总了Python中canvas.Canvas.selectShape方法的典型用法代码示例。如果您正苦于以下问题:Python Canvas.selectShape方法的具体用法?Python Canvas.selectShape怎么用?Python Canvas.selectShape使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类canvas.Canvas
的用法示例。
在下文中一共展示了Canvas.selectShape方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MainWindow
# 需要导入模块: from canvas import Canvas [as 别名]
# 或者: from canvas.Canvas import selectShape [as 别名]
#.........这里部分代码省略.........
line_color=s.line_color.getRgb()\
if s.line_color != self.lineColor else None,
fill_color=s.fill_color.getRgb()\
if s.fill_color != self.fillColor else None,
points=[(p.x(), p.y()) for p in s.points])
shapes = [format_shape(shape) for shape in self.canvas.shapes]
# Can add differrent annotation formats here
try:
if self.usingPascalVocFormat is True:
print('savePascalVocFormat save to:' + filename)
lf.savePascalVocFormat(filename, shapes, str(self.filename), self.imageData,
self.lineColor.getRgb(), self.fillColor.getRgb())
else:
lf.save(filename, shapes, str(self.filename), self.imageData,
self.lineColor.getRgb(), self.fillColor.getRgb())
self.labelFile = lf
self.filename = filename
return True
except LabelFileError as e:
self.errorMessage(u'Error saving label data',
u'<b>%s</b>' % e)
return False
def copySelectedShape(self):
self.addLabel(self.canvas.copySelectedShape())
#fix copy and delete
self.shapeSelectionChanged(True)
def labelSelectionChanged(self):
item = self.currentItem()
if item and self.canvas.editing():
self._noSelectionSlot = True
self.canvas.selectShape(self.itemsToShapes[item])
def labelItemChanged(self, item):
shape = self.itemsToShapes[item]
label = item.text()
if label != shape.label:
shape.label = item.text()
self.setDirty()
else: # User probably changed item visibility
self.canvas.setShapeVisible(shape, item.checkState() == Qt.Checked)
## Callback functions:
def newShape(self):
"""Pop-up and give focus to the label editor.
position MUST be in global coordinates.
"""
if len(self.labelHist) > 0:
self.labelDialog = LabelDialog(parent=self, listItem=self.labelHist)
text = self.labelDialog.popUp()
if text is not None:
self.addLabel(self.canvas.setLastLabel(text))
if self.beginner(): # Switch to edit mode.
self.canvas.setEditing(True)
self.actions.create.setEnabled(True)
else:
self.actions.editMode.setEnabled(True)
self.setDirty()
if text not in self.labelHist:
self.labelHist.append(text)