def toolbar(self, title, actions=None): toolbar = ToolBar(title) toolbar.setObjectName(u'%sToolBar' % title) toolbar.setMovable(False) toolbar.setFixedHeight(32) toolbar.setIconSize(QSize(30, 30)) toolbar.setToolButtonStyle(Qt.ToolButtonIconOnly) if actions: addActions(toolbar, actions) self.addToolBar(Qt.TopToolBarArea, toolbar) return toolbar
def setupMenus(self): labelMenu = QMenu() # noinspection PyUnresolvedReferences addActions(labelMenu, (editLabel, delBox)) self.menus = Struct(file=self.menu('&File'), edit=self.menu('&Edit'), view=self.menu('&View'), machine_learning=self.menu('&Machine Learning'), help=self.menu('&Help'), recentFiles=QMenu('Open &Recent'), labelList=labelMenu) # noinspection PyUnresolvedAttribute self.menus.file.aboutToShow.connect(self.updateFileMenu)
def setupCanvasWidget(self): action = partial(newAction, self) # Create and add a widget for showing current label items self.canvas = Canvas(parent=self) self.canvas.zoomRequest.connect(self.zoomRequest) self.canvas.setDrawingShapeToSquare( self.settings.get(SETTING_DRAW_SQUARE, False)) self.canvas.scrollRequest.connect(self.scrollRequest) self.canvas.newShape.connect(self.newShape) self.canvas.shapeMoved.connect(self.setDirty) self.canvas.selectionChanged.connect(self.shapeSelectionChanged) self.canvas.drawingPolygon.connect(self.toggleDrawingSensitive) # Custom context menu for the canvas widget: # noinspection PyUnresolvedReferences addActions(self.canvas.menus[0], self.actions.beginnerContext) addActions(self.canvas.menus[1], (action('&Copy here', self.copyShape), action('&Move here', self.moveShape)))
def populateMenus(self): labels = self.dock.toggleViewAction() labels.setText(getStr('showHide')) labels.setShortcut('Ctrl+Shift+L') # noinspection PyUnresolvedReferences addActions(self.menus.file, (openFile, self.menus.recentFiles, openDir, changeSaveDir, impVideo, openAnnotation, saveFile, changeFormat, saveAs, closeFile, resetAll, close)) # noinspection PyUnresolvedReferences addActions(self.menus.help, (showTutorialDialog, showInfo)) # noinspection PyUnresolvedReferences addActions(self.menus.view, (self.autoSaving, self.singleClassMode, self.displayLabelOption, labels, advancedMode, None, prevImg, nextImg, None, hideAll, showAll, None, zoomIn, zoomOut, zoomOrg, None, setFitWin, setFitWidth)) # noinspection PyUnresolvedReferences addActions(self.menus.machine_learning, (commitAnnotatedFrames, trainModel, visualize, None))
def populateModeActions(self): if self.beginner(): tool, menu = self.actions.beginner, self.actions.beginnerContext else: tool, menu = self.actions.advanced, self.actions.advancedContext self.tools.clear() addActions(self.tools, tool) self.canvas.menus[0].clear() addActions(self.canvas.menus[0], menu) self.menus.edit.clear() actions = (self.actions.create,) if self.beginner() \ else (self.actions.setCreateMode, self.actions.setEditMode, self.actions.verifyImg) addActions(self.menus.edit, actions + self.actions.editMenu)
def menu(self, title, actions=None): menu = self.menuBar().addMenu(title) if actions: addActions(menu, actions) return menu
def setAdvanced(self): self.tools.clear() addActions(self.tools, self.actions.advanced)
def setBeginner(self): self.tools.clear() addActions(self.tools, self.actions.beginner)