原有代码
canvas中:paintEvent为重写的画图方法 mousePressEvent为鼠标的点击事件
显示在左边栏中的按钮设置(app.py 706)
# Menu buttons on Left
self.actions.tool = (
open_,
opendir,
openNextImg,
openPrevImg,
save,
deleteFile,
None,
createMode,
editMode,
copy,
delete,
undo,
brightnessContrast,
None,
zoom,
fitWidth,
)
# Polygon drawing.
if self.drawing():
self.line.shape_type = self.createMode
self.overrideCursor(CURSOR_DRAW)
if not self.current:
return
if self.outOfPixmap(pos):
# Don't allow the user to draw outside the pixmap.
# Project the point to the pixmap's edges.
pos = self.intersectionPoint(self.current[-1], pos)
elif (
len(self.current) > 1
and self.createMode == "polygon"
and self.closeEnough(pos, self.current[0])
):
# Attract line