我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用PySide.QtGui.QMessageBox()。
def removePath(self): if self.pathsList.currentRow() == -1: return dial = QtGui.QMessageBox() dial.setText(u"Delete all selected paths?") dial.setWindowTitle("Caution!") dial.setIcon(QtGui.QMessageBox.Question) delete_YES = dial.addButton('Yes', QtGui.QMessageBox.YesRole) dial.addButton('No', QtGui.QMessageBox.RejectRole) dial.exec_() if dial.clickedButton() == delete_YES: for i in range(self.pathsList.count(), 0, -1): if self.pathsList.item(i - 1).checkState() == QtCore.Qt.Checked: self.pathsList.takeItem(i - 1)
def addPackageAsNew(self): ''' add package as new - based on other package ''' if str(self.packageName.text()).strip() == "" or str(self.pathToModel.text()).strip() == "": QtGui.QMessageBox().critical(self, u"Caution!", u"At least one required field is empty.") return zawiera = self.sql.has_value("name", self.packageName.text()) if zawiera[0]: dial = QtGui.QMessageBox(self) dial.setText(u"Rejected. Package already exist.") dial.setWindowTitle("Caution!") dial.setIcon(QtGui.QMessageBox.Warning) dial.addButton('Ok', QtGui.QMessageBox.RejectRole) dial.exec_() else: self.addElement()
def version_check_done(self, version): self.version_thread.quit() if version and __version__ != version: version_box = QtGui.QMessageBox(self) version_box.setWindowTitle("New version available!") version_box.setText( "You have version '{}', but there's a new version available: '{}'.".format(__version__, version) ) version_box.addButton("Download now", QtGui.QMessageBox.AcceptRole) version_box.addButton("Remind me later", QtGui.QMessageBox.RejectRole) ret = version_box.exec_() if ret == QtGui.QMessageBox.AcceptRole: QtGui.QDesktopServices.openUrl( QtCore.QUrl("https://github.com/farshield/shortcircuit/releases/tag/{}".format(version)) ) # event: QCloseEvent
def deleteSelected( self ): itemList = self.listFiles.selectedItems() confirmBox = QtGui.QMessageBox() filenameString = "" for item in itemList: filenameString += item.text() + "\n" confirmBox.setText( "Are you sure you want to delete all files related to: %s" % filenameString ) confirmBox.addButton( QtGui.QMessageBox.Cancel ) deleteButton = confirmBox.addButton( "Delete", QtGui.QMessageBox.ActionRole ) confirmBox.setDefaultButton( QtGui.QMessageBox.Cancel ) confirmBox.exec_() if confirmBox.clickedButton() == deleteButton: reverseState = {v: k for k, v in self.stateIds.items()} for item in itemList: #item = self.listFiles.currentItem() if item is None: continue state_id = reverseState[item.text()] # Delete everything self.skulk.remove( state_id ) # The skulk will remove the item with a signal
def showCitationsDialog(self): citations = u""" Zorro: McLeod, R.A., Kowal, J., Ringler, P., Stahlberg, S., Submitted. CTFFIND4: Rohou, A., Grigorieff, N., 2015. CTFFIND4: Fast and accurate defocus estimation from electron micrographs. Journal of Structural Biology, Recent Advances in Detector Technologies and Applications for Molecular TEM 192, 216-221. doi:10.1016/j.jsb.2015.08.008 GCTF: Zhang, K., 2016. Gctf: Real-time CTF determination and correction. Journal of Structural Biology 193, 1-12. doi:10.1016/j.jsb.2015.11.003 SerialEM: Mastronarde, D.N. 2005. Automated electron microscope tomography using robust prediction of specimen movements. J. Struct. Biol. 152:36-51. """ citBox = QtGui.QMessageBox() citBox.setText( citations ) citBox.exec_()
def mergeFamily (self) : mydir = self.inputs.dirCombo.currentText () if not mydir : mess = QtGui.QMessageBox () mess.setText ("Processing directory must be set!") mess.exec_ () return self.statsig.emit ("Merging PH5 families to Sigma. This may take awhile...") pd = MdiChildDos (mydir, "Merging to Sigma...") if pd.good : pd.canceled.connect (self.mdiArea.closeAllSubWindows) self.mdiArea.addSubWindow (pd) pd.show () pd.run () else : pd.close ()
def errorDialog(msg): diag = QtGui.QMessageBox(QtGui.QMessageBox.Critical,u"Error Message",msg ) diag.setWindowFlags(PySide.QtCore.Qt.WindowStaysOnTopHint) diag.exec_()
def captureSnapshot(self): """ Logic to capture all the parameters for the data visualization """ print "Capturing the timepoints" # Code graciously taken from the Qt website msgBox = QtGui.QMessageBox() msgBox.setText("Capturing the snapshot.") msgBox.setInformativeText("Do you want to capture the parameters of the visualization?") msgBox.setStandardButtons(QtGui.QMessageBox.Save | QtGui.QMessageBox.Discard | QtGui.QMessageBox.Cancel) msgBox.setDefaultButton(QtGui.QMessageBox.Save) ret = msgBox.exec_() if ret == QtGui.QMessageBox.Save: Sanpshots = dict() print "Logic for capturing the paprameters of the visualizations" Sanpshots["correlationMode"] = self.widget.ColorNodesBasedOnCorrelation Sanpshots["nodeMapping"] = self.widget.nodeSizeFactor Sanpshots["edgeThickness"] = self.widget.nodeSizeFactor Sanpshots["onlyEdges:"] = self.widget.DisplayOnlyEdges Sanpshots["transparentNodes"] = self.widget.setTransp Sanpshots["highlightEdges"] = self.widget.HighlightedId Sanpshots["communityGraphLevel"] = self.widget.level Sanpshots["datasetLoaded"] = (self.matrix_filename,self.template_filename,self.parcelation_filename) # Make a Directory try: os.makedirs(self.directory_path[0]) except OSError as exception: pass from time import gmtime, strftime fileName = strftime("%Y-%m-%d %H:%M:%S", gmtime()) '2009-01-05 22:14:39' with open(self.directory_path[0]+"/"+fileName, 'w') as outfile: pickle.dump(Sanpshots, outfile)
def about(self): msgBox = QtGui.QMessageBox() msgBox.setText(MESSAGE) msgBox.exec_()
def __init__(self, categoryID): categoryData = readCategories()[categoryID] # dial = QtGui.QMessageBox() dial.setText(u"Delete selected category '{0}'?".format(categoryData[0])) dial.setWindowTitle("Caution!") dial.setIcon(QtGui.QMessageBox.Question) delete = dial.addButton('Yes', QtGui.QMessageBox.AcceptRole) dial.addButton('No', QtGui.QMessageBox.RejectRole) dial.exec_() if dial.clickedButton() == delete: removeCategory(categoryID)
def deleteModel(self): if self.currentRow() != -1: dial = QtGui.QMessageBox() dial.setText(u"Delete selected package?") dial.setWindowTitle("Caution!") dial.setIcon(QtGui.QMessageBox.Question) dial.addButton('No', QtGui.QMessageBox.RejectRole) usunT = dial.addButton('Yes', QtGui.QMessageBox.YesRole) dial.exec_() if dial.clickedButton() == usunT: self.deleteRow(self.currentRow())
def deletePackage(self): ''' delete selected packages from lib ''' try: delAll = False # for i in QtGui.QTreeWidgetItemIterator(self.modelsList): if str(i.value().data(0, QtCore.Qt.UserRole + 1)) == 'C': continue if not i.value().checkState(0) == QtCore.Qt.Checked: continue ########## item = i.value() objectID = str(item.data(0, QtCore.Qt.UserRole)) ########## if not delAll: dial = QtGui.QMessageBox() dial.setText(u"Delete selected package {0}?".format(item.text(0))) dial.setWindowTitle("Caution!") dial.setIcon(QtGui.QMessageBox.Question) delete_YES = dial.addButton('Yes', QtGui.QMessageBox.YesRole) delete_YES_ALL = dial.addButton('Yes for all', QtGui.QMessageBox.YesRole) delete_NO = dial.addButton('No', QtGui.QMessageBox.RejectRole) delete_NO_ALL = dial.addButton('No for all', QtGui.QMessageBox.RejectRole) dial.exec_() if dial.clickedButton() == delete_NO_ALL: break elif dial.clickedButton() == delete_YES_ALL: delAll = True elif dial.clickedButton() == delete_NO: continue # self.sql.delPackage(objectID) item.setCheckState(0, QtCore.Qt.Unchecked) item.setHidden(True) ########## except Exception ,e: FreeCAD.Console.PrintWarning("{0} \n".format(e))
def removeCamera(self): if self.camerasList.currentRow() != -1: dial = QtGui.QMessageBox() dial.setText(u"Delete selected camera?") dial.setWindowTitle("Caution!") dial.setIcon(QtGui.QMessageBox.Question) delete_YES = dial.addButton('Yes', QtGui.QMessageBox.YesRole) dial.addButton('No', QtGui.QMessageBox.RejectRole) dial.exec_() if dial.clickedButton() == delete_YES: self.camerasList.takeItem(self.camerasList.currentRow())
def konwertuj(self): if self.sprawdzPliki(str(self.oldFilePath.text())) and self.sprawdzPliki(str(self.newFilePath.text())): # baza danych sql = dataBase() sql.read(str(self.newFilePath.text())) # stara baza danych oldPath = os.path.dirname(str(self.oldFilePath.text())) oldName = os.path.basename(str(self.oldFilePath.text())) sys.path.append(oldPath) oldModule = __import__(os.path.splitext(oldName)[0]) # for i, j in oldModule.bibliotekaDane.items(): param = sql.has_value("name", i) if not param[0]: sql.addPackage({"name": i, "path": j[0], "x": str(j[1]), "y": str(j[2]), "z": str(j[3]), "rx": str(j[4]), "ry": str(j[5]), "rz": str(j[6]), "add_socket": 0, "add_socket_id": 0, "socket": str(j[7]), "socket_height": str(j[8]), "description": "", "datasheet": ""}) try: if self.removeOld.isChecked(): os.remove(str(self.oldFilePath.text())) except OSError: pass QtGui.QMessageBox().information(self, u"Conversion", u"Conversion finished.") self.reject()
def showInfo(self, info): dial = QtGui.QMessageBox(self) dial.setText(info) dial.setWindowTitle("Info") dial.setIcon(QtGui.QMessageBox.Information) dial.addButton('Ok', QtGui.QMessageBox.RejectRole) dial.exec_()
def captureSnapshot(): """ Logic to capture all the parameters for the data visualization """ # Code graciously taken from the Qt website msgBox = QtGui.QMessageBox() msgBox.setText("Capturing the snapshot.") msgBox.setInformativeText("Do you want to capture the parameters of the visualization?") msgBox.setStandardButtons(QtGui.QMessageBox.Save | QtGui.QMessageBox.Discard | QtGui.QMessageBox.Cancel) msgBox.setDefaultButton(QtGui.QMessageBox.Save) ret = msgBox.exec_() if ret == QtGui.QMessageBox.Save: pass
def _message_box(self, title, text): msg_box = QtGui.QMessageBox(self) msg_box.setWindowTitle(title) msg_box.setText(text) return msg_box.exec_()
def btn_reset_clicked(self): msg_box = QtGui.QMessageBox(self) msg_box.setWindowTitle("Reset chain") msg_box.setText("Are you sure you want to clear all Tripwire data?") msg_box.setStandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No) msg_box.setDefaultButton(QtGui.QMessageBox.No) ret = msg_box.exec_() if ret == QtGui.QMessageBox.Yes: self.nav.reset_chain() self._trip_message("Not connected to Tripwire, yet", MainWindow.MSG_INFO)
def validateAuxTools(self): #self.comboCompressionExt.setEnabled(True) #self.cbDoCompression.setEnabled(True) self.pageGautoConfig.setEnabled(True) self.tbParticlePick.setEnabled(True) warningMessage = "" # Check for installation of lbzip2, pigz, and 7z #if not bool( zorro.util.which('lbzip2') ) and not bool( zorro.util.which('7z') ) and not bool( zorro.util.which('pigz') ): # warningMessage += u"Disabling compression: None of lbzip2, pigz, or 7z found.\n" # # TODO: limit compress_ext if only one is found? # self.comboCompressionExt.setEnabled(False) # self.cbDoCompression.setEnabled(False) # Check for installation of CTFFIND/GCTF if not bool( zorro.util.which('ctffind') ): # Remove CTFFIND4 from options warningMessage += u"Disabling CTFFIND4.1: not found.\n" self.comboCtfProgram.removeItem( self.comboCtfProgram.findText( 'CTFFIND4.1') ) self.comboCtfProgram.removeItem( self.comboCtfProgram.findText( 'CTFFIND4.1, sum') ) if not bool( zorro.util.which('gctf') ): warningMessage += u"Disabling GCTF: not found.\n" self.comboCtfProgram.removeItem( self.comboCtfProgram.findText( 'GCTF') ) self.comboCtfProgram.removeItem( self.comboCtfProgram.findText( 'GCTF, sum') ) # Check for installation of Gautomatch if not bool( zorro.util.which('gautomatch') ): warningMessage += u"Disabling particle picking: Gautomatch not found.\n" self.pageGautoConfig.setEnabled(False) self.tbParticlePick.setEnabled(False) if not bool( zorro.util.which('2dx_viewer') ): warningMessage += u"2dx_viewer not found, using IMS for pop-out views.\n" self.actionPrefer2dx_viewer.setEnabled( False ) self.actionPreferIms.setChecked(True) if bool( warningMessage ): warnBox = QtGui.QMessageBox() warnBox.setText( warningMessage ) warnBox.exec_()
def checkValidPaths( self ): errorState, errorText = self.skulk.paths.validate() if bool( errorState ): errorBox = QtGui.QMessageBox() errorBox.setText( errorText ) errorBox.addButton( QtGui.QMessageBox.Ok ) errorBox.setDefaultButton( QtGui.QMessageBox.Ok ) errorBox.exec_() return not errorState
def showImsHelpDialog(self): citBox = QtGui.QMessageBox() citBox.setText( zorro.zorro_plotting.IMS_HELPTEXT ) citBox.exec_()
def outputDialog(msg): # Create a simple dialog QMessageBox # The first argument indicates the icon used: one of QtGui.QMessageBox.{NoIcon, Information, Warning, Critical, Question} diag = QtGui.QMessageBox(QtGui.QMessageBox.Information, 'Output', msg) diag.setWindowModality(QtCore.Qt.ApplicationModal) diag.exec_()
def quickMsg(self, msg, block=1): tmpMsg = QtWidgets.QMessageBox(self) # for simple msg that no need for translation tmpMsg.setWindowTitle("Info") tmpMsg.setText(msg) if block == 0: tmpMsg.setWindowModality( QtCore.Qt.NonModal ) tmpMsg.addButton("OK",QtWidgets.QMessageBox.YesRole) if block: tmpMsg.exec_() else: tmpMsg.show()
def default_message(self, ui_name): msgName = ui_name[:-7]+"_msg" msg_txt = msgName + " is not defined in uiList." if msgName in self.uiList: msg_txt = self.uiList[msgName] tmpMsg = QtWidgets.QMessageBox() tmpMsg.setWindowTitle("Info") tmpMsg.setText(msg_txt) tmpMsg.addButton("OK",QtWidgets.QMessageBox.YesRole) tmpMsg.exec_()
def quickMsg(self, msg): tmpMsg = QtWidgets.QMessageBox() # for simple msg that no need for translation tmpMsg.setWindowTitle("Info") tmpMsg.setText(msg) tmpMsg.addButton("OK",QtWidgets.QMessageBox.YesRole) tmpMsg.exec_()
def default_message(self, ui_name): msgName = ui_name[:-7]+"_msg" msg_txt = msgName + " is not defined in uiList." if msgName in self.uiList: msg_txt = self.uiList[msgName] tmpMsg = QtGui.QMessageBox() tmpMsg.setWindowTitle("Info") tmpMsg.setText(msg_txt) tmpMsg.addButton("OK",QtGui.QMessageBox.YesRole) tmpMsg.exec_() #======================================= #- UI and RAM content update functions (optional) #=======================================
def quickMsg(self, msg): tmpMsg = QtGui.QMessageBox() # for simple msg that no need for translation tmpMsg.setWindowTitle("Info") tmpMsg.setText(msg) tmpMsg.addButton("OK",QtGui.QMessageBox.YesRole) tmpMsg.exec_()
def message(self, m, i): mBox = QtGui.QMessageBox() mBox.setText(m) #mBox.setStandardButtons( QtGui.QMessageBox.Cancel | QtGui.QMessageBox.Ok ) ok_button = mBox.addButton(QtGui.QMessageBox.Ok) cancel_button = mBox.addButton(QtGui.QMessageBox.Cancel) if i==1: mBox.setIcon(QtGui.QMessageBox.Information) mBox.setWindowTitle('information') elif i == 2: mBox.setIcon(QtGui.QMessageBox.Warning) mBox.setWindowTitle('Oh my God!') elif i == 3: mBox.setIcon(QtGui.QMessageBox.Critical) mBox.setWindowTitle('Saint Mary!') elif i == 0: mBox.setIcon(QtGui.QMessageBox.Question) mBox.setWindowTitle('tel me!') com = mBox.exec_() if mBox.clickedButton() == ok_button: return(True) elif mBox.clickedButton() == cancel_button: return(False)
def message(self, m, i): #m = str(m) mBox = QtGui.QMessageBox() mBox.setText(m) #mBox.setStandardButtons( QtGui.QMessageBox.Cancel | QtGui.QMessageBox.Ok ) ok_button = mBox.addButton(QtGui.QMessageBox.Ok) cancel_button = mBox.addButton(QtGui.QMessageBox.Cancel) if i==1: mBox.setIcon(QtGui.QMessageBox.Information) mBox.setWindowTitle('information') elif i == 2: mBox.setIcon(QtGui.QMessageBox.Warning) mBox.setWindowTitle('Oh my God!') elif i == 3: mBox.setIcon(QtGui.QMessageBox.Critical) mBox.setWindowTitle('Saint Mary!') elif i == 0: mBox.setIcon(QtGui.QMessageBox.Question) mBox.setWindowTitle('tel me!') com = mBox.exec_() if mBox.clickedButton() == ok_button: return(True) elif mBox.clickedButton() == cancel_button: return(False)
def errorDialog(msg): ''' pop up an error QMessageBox''' diag = QtGui.QMessageBox(QtGui.QMessageBox.Critical,u"Error Message",msg ) diag.setWindowFlags(PySide.QtCore.Qt.WindowStaysOnTopHint) diag.exec_()
def showdialog(title="Fehler", text="Schau in den ReportView fuer mehr Details", detail=None): '''display a window with: title,text and detail''' msg = QtGui.QMessageBox() msg.setIcon(QtGui.QMessageBox.Warning) msg.setText(text) msg.setWindowTitle(title) if detail != None: msg.setDetailedText(detail) msg.exec_()
def showdialog(title="Fehler",text="Schau in den ReportView fuer mehr Details",detail=None): msg = QtGui.QMessageBox() msg.setIcon(QtGui.QMessageBox.Warning) msg.setText(text) msg.setWindowTitle(title) if detail<>None: msg.setDetailedText(detail) msg.exec_()
def qt_excepthook(type, value, tb): sys.__excepthook__(type, value, tb) msgbox = QtGui.QMessageBox() msgbox.setInformativeText("Unexpected error occured") msgbox.setText(str(value)) msgbox.setDetailedText('\n'.join(traceback.format_exception(type, value, tb))) msgbox.setIcon(QtGui.QMessageBox.Critical) msgbox.exec_()
def __init__(self, parent=None, app=None): super(MainWindow, self).__init__(parent) self.setupUi(self) self.app = app self.list_model = FileListModel(self) self.fileList.setModel(self.list_model) if not rpcurl_from_config('namecoin'): QtGui.QMessageBox.critical(self, 'No namecoind found', 'Please install and configure Namecoin-Qt first.') sys.exit(1)
def __init__ (self, home, title='X') : super (MdiChildDos, self).__init__ (title, "Close", 0, 0) self.home = home self.good = True self.setMinimumWidth (400) self.fio, self.cmds, self.info = init_fio (None, self.home) if os.path.exists (os.path.join (self.fio.home, 'Sigma')) : mess = QtGui.QMessageBox () mess.setText ("Please remove existing directory {0}.".format (os.path.join (self.fio.home, 'Sigma'))) mess.exec_ () self.good = False #self.wd = watchit.Watchdog (3, userHandler=self.run) #self.wd.start ()
def run (self) : msgs = self.fio.unite ('Sigma') self.setLabelText ("Completed") self.setRange (1, 1) mess = QtGui.QMessageBox () mess.setWindowTitle ("Merge Progress Summary") mess.setDetailedText ('\n'.join (msgs)) #mess.setSizeGripEnabled (True) mess.exec_ () #print "Done" #self.cancel ()
def resetIt (self) : ''' Reset (Kill) all family processes. ''' reply = QtGui.QMessageBox.question(self, 'Message', "Are you sure you want to reset family processing?\nAll state information will be lost!!!", QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.No) if reply == QtGui.QMessageBox.No : return self.killchildren () self.inputs.runButton.setEnabled (True) self.runAct.setEnabled (True)
def about(self): QtGui.QMessageBox.about(self, "About pforma", "The <b>pforma</b> program performs conversions to PH5 in parallel. " "Note to self: Need a better about.")