def showContextMenu(self, pos): item = self.itemAt(pos) menu = QMenu() it = QTreeWidgetItem.UserType + 1 if item.type() == it: HelperMethods.addActions(menu, self.actionDeleteObject) self.index = item.parent().indexOfChild(item) menu.exec_(self.mapToGlobal(pos))
def simulationToolBar(self, numWidgets): if not hasattr(self, 'SimToolBar'): self.SimToolBar = QToolBar(self.tr("Simulation Tools")) self.SimToolBar.setObjectName("SimToolBar") self.SimToolBar.setAllowedAreas( Qt.TopToolBarArea | Qt.BottomToolBarArea | Qt.LeftToolBarArea | Qt.RightToolBarArea) self.SimToolBar.clear() HelperMethods.addActions(self.SimToolBar, self.simulationMenuActions[0:numWidgets]) self.addToolBar(Qt.TopToolBarArea, self.SimToolBar)
def geometryToolBar(self, reset=False, LoadImage=False): if not hasattr(self, 'GeometryToolBar'): self.GeometryToolBar = QToolBar(self.tr("Geometry Tools")) self.GeometryToolBar.setObjectName("GeometryToolBar") self.GeometryToolBar.setAllowedAreas( Qt.TopToolBarArea | Qt.BottomToolBarArea | Qt.LeftToolBarArea | Qt.RightToolBarArea) self.GeometryToolBar.clear() if LoadImage: HelperMethods.addActions(self.GeometryToolBar, self.geometryMenuActions[4]) self.addToolBar(Qt.RightToolBarArea, self.GeometryToolBar) return if reset: return else: HelperMethods.addActions(self.GeometryToolBar, self.geometryMenuActions[2:]) # self.addToolBarBreak(Qt.TopToolBarArea) self.addToolBar(Qt.RightToolBarArea, self.GeometryToolBar)
def updateFileMenu(self): self.menuFile.clear() HelperMethods.addActions(self.menuFile, self.fileMenuActions[0:-2]) current = self.filename if self.filename is not None else None recentFiles = [] for fname in self.recentFiles: if fname != current and QFile.exists(fname): recentFiles.append(fname) if recentFiles: self.menuFile.addSeparator() for i, fname in enumerate(recentFiles): action = QAction( QIcon(":/logo_SimNDT.png"), "&%d %s" % (i + 1, QFileInfo(fname).fileName()), self) action.setData(fname) self.connect(action, SIGNAL("triggered()"), self.loadFile) self.menuFile.addAction(action) self.menuFile.addSeparator() self.menuFile.addAction(self.fileMenuActions[-2]) self.menuFile.addAction(self.fileMenuActions[-1])
def createToolBar(self): self.fileToolBar = self.addToolBar("File Tools") self.fileToolBar.setObjectName("FileToolBar") HelperMethods.addActions(self.fileToolBar, self.fileMenuActions[:-2])
def createMenus(self): newFileAction = HelperMethods.createAction( self, "&New Simulation", self.fileNew, QKeySequence.New, "document-new.png", self.tr("New Simulation File")) fileOpenAction = HelperMethods.createAction( self, "&Open existing Simulation", self.fileOpen, QKeySequence.Open, 'document-open.png', self.tr("Open an existing Simulation")) fileSaveAction = HelperMethods.createAction( self, "&Save Simulation", self.fileSave, QKeySequence.Save, "document-save.png", self.tr("Save the current Simulation")) fileSaveAsAction = HelperMethods.createAction( self, "Save &As", self.fileSaveAs, QKeySequence.SaveAs, icon="document-save-as.png", tip=self.tr("Save Simulation File As")) fileOpenAction.setIcon(self.style().standardIcon( QStyle.SP_DirOpenIcon)) # fileSaveAction.setIcon(self.style().standardIcon(QStyle.SP_FileDialogNewFolder)) fileExportMatlabAction = HelperMethods.createAction( self, "Export in .mat File", self.exportMatlab, "Ctrl+E", icon="exportMatlab.png", tip=self.tr("Export in .mat File")) fileResetAction = HelperMethods.createAction(self, "Reset Settings", self.resetSettings, icon="reset.png") fileQuitAction = HelperMethods.createAction( self, "&Quit", self.close, "Ctrl+Q", "close", self.tr("Close the application")) self.fileMenuActions = (newFileAction, fileOpenAction, fileSaveAction, fileSaveAsAction, fileExportMatlabAction, None, fileResetAction, fileQuitAction) HelperMethods.setEnabled(self.fileMenuActions[2:5], False) self.connect(self.menuFile, SIGNAL("aboutToShow()"), self.updateFileMenu) self.geometryMenuActions = ( self.actionNew_Geometry_Model, None, self.actionAdd_Ellipse, self.actionAdd_Rectangle, self.actionLoad_Scenario_From_Image, None, self.actionPreview_Labeled_Scenario, self.actionRotate_The_Scenario_90_Clockwise, self.actionRotate_The_Scenario_90_Counter_Clockwise) HelperMethods.setEnabled(self.menuNew_Simulation_Scenario, False) HelperMethods.setEnabled(self.geometryMenuActions, False) self.configurationMenuActions = (self.actionMaterials_Setup, self.actionBoundaty_Conditions_Setup) HelperMethods.setEnabled(self.configurationMenuActions, False) self.inspectionMenuActions = (self.actionSingle_Launch_Inspection, self.actionLinear_Scan_Inspections, self.actionTomography_Inspections) inspectionGroup = QActionGroup(self) HelperMethods.addActions(inspectionGroup, self.inspectionMenuActions) HelperMethods.setEnabled(self.menuInspection_Setup, False) HelperMethods.setEnabled(self.actionSimulation_Setup, False) HelperMethods.setEnabled(self.actionCheck_Simulation_Setup, False) HelperMethods.setEnabled(self.actionRun_Simulation, False) self.actionSignal = HelperMethods.createAction(self, "&Signal Setup", self.signalSetup, "Ctrl+Shift+p", "signal.png", self.tr("Signal Setup")) self.simulationMenuActions = (self.actionNew_Geometry_Model, self.actionMaterials_Setup, self.actionBoundaty_Conditions_Setup, self.actionSingle_Launch_Inspection, self.actionLinear_Scan_Inspections, self.actionTomography_Inspections, self.actionSimulation_Setup, self.actionCheck_Simulation_Setup, self.actionRun_Simulation) self.menuPlotting_Tools.menuAction().setVisible(False) # self.menuAdd_Microstructure.menuAction().setVisible(False) # self.menuTools.menuAction().setVisible(False) helpAboutAction = HelperMethods.createAction(self, "&About SimNDT", self.helpAbout) helpHelpAction = HelperMethods.createAction(self, self.tr("&Help"), self.helpHelp, QKeySequence.HelpContents) helpMenu = self.menubar.addMenu(self.tr("&Help")) HelperMethods.addActions(helpMenu, (helpAboutAction, helpHelpAction))
def showContextMenu(self, pos): menu = QMenu() HelperMethods.addActions(menu, self.parent.actionAdd_Ellipse) HelperMethods.addActions(menu, self.parent.actionAdd_Rectangle) menu.exec_(self.mapToGlobal(pos))