def editingFinishedHandler(self): settings = QSettings() old = settings.value("computation/reduce",QtReduceDefaults.REDUCE) new = self.reduceBinary.text() if old == new: return self.reduceBinary.blockSignals(True) tit = "Change Binary?" txt = self.tr("Do you really want to change this setting?") itxt = self.tr("If yes, then the binary ") itxt += '"' + new + '" ' itxt += self.tr("will be used at the next restart.") mbox = QMessageBox(self) mbox.setIcon(QMessageBox.Question) mbox.setWindowModality(Qt.WindowModal) mbox.setWindowTitle(tit) mbox.setText(txt) mbox.setInformativeText(itxt) mbox.setStandardButtons(QMessageBox.Yes|QMessageBox.No) button = mbox.exec_() if button == QMessageBox.Yes: settings.setValue("computation/reduce",new) else: self.reduceBinary.setText(old) self.reduceBinary.blockSignals(False)
def __savediag(self): diag = QMessageBox(self) msg = 'Do you want to save the changes in your worksheet "' msg += (self.controller.fileName().split('/')[-1] or 'untitled') + '"?' diag.setText(msg) diag.setInformativeText("Otherwise they will get lost") diag.setIcon(QMessageBox.Warning) diag.setStandardButtons(QMessageBox.StandardButton.Discard | QMessageBox.StandardButton.Cancel | QMessageBox.StandardButton.Save) diag.setWindowModality(Qt.WindowModal) return diag.exec_()
def Launch(): """This function checks whether or not the user has selected one or more objects. It then calls the '_Launch_Main_Dialog' class. """ if len(gui.Selection.getSelection()) > 0: __Launch_Main_Dialog() else: message = 'No FreeCAD objects have been selected for MultiCopy!' message_box = QMessageBox( QMessageBox.Critical, 'MultiCopy - Error Message', message ) message_box.setWindowModality(QtCore.Qt.ApplicationModal) message_box.exec_()
def event_link_clicked(self, url): url_string = url.toString() if 'file' in urlparse.parse_qs(urlparse.urlparse(url_string).query): msgbox = QMessageBox() msgbox.setWindowTitle('Installing') msgbox.setText('Installing theme. Please wait...') msgbox.setStandardButtons(0) msgbox.setAttribute(Qt.WA_DeleteOnClose) msgbox.setWindowModality(Qt.NonModal) msgbox.show() msgbox.repaint( ) # Qt didn't want to show the text so we force a repaint # Download and install the theme package = self.module.download( 'http://localhost/test/download.php?file=2800&name=Fat-flat.xpf' ) #package = self.module.download(url_string) try: self.module.install(package) msgbox.close() complete_msgbox = QMessageBox() complete_msgbox.setWindowTitle('Complete') complete_msgbox.setText('Install complete.') complete_msgbox.setStandardButtons(QMessageBox.Ok) complete_msgbox.setAttribute(Qt.WA_DeleteOnClose) complete_msgbox.exec_() except: msgbox.close() print "Unexpected error:", sys.exc_info()[:2] failed_msgbox = QMessageBox() failed_msgbox.setWindowTitle('Failed') failed_msgbox.setText( 'Install failed. Please try again later.') failed_msgbox.setStandardButtons(QMessageBox.Ok) failed_msgbox.setAttribute(Qt.WA_DeleteOnClose) failed_msgbox.exec_() else: QDesktopServices.openUrl(url)
def __binary(self): binary = QSettings().value("computation/reduce", QtReduceDefaults.REDUCE) if not os.path.exists(sys.path[0] + "/" + binary): tit = self.tr("Unable to Connect to Reduce") txt = self.tr("The binary ") txt += '"' + binary + '" ' txt += self.tr("does not exist.") itxt = self.tr("Using the default binary ") itxt += '"' + QtReduceDefaults.REDUCE + '"' itxt += self.tr(". ") itxt += self.tr("Please check the Preferences.") mbox = QMessageBox() mbox.setIcon(QMessageBox.Warning) mbox.setWindowModality(Qt.WindowModal) mbox.setWindowTitle(tit) mbox.setText(txt) mbox.setInformativeText(itxt) mbox.exec_() binary = QtReduceDefaults.REDUCE return binary
def event_link_clicked(self, url): url_string = url.toString() if 'file' in urlparse.parse_qs(urlparse.urlparse(url_string).query): msgbox = QMessageBox() msgbox.setWindowTitle('Installing') msgbox.setText('Installing theme. Please wait...') msgbox.setStandardButtons(0) msgbox.setAttribute(Qt.WA_DeleteOnClose) msgbox.setWindowModality(Qt.NonModal) msgbox.show() msgbox.repaint() # Qt didn't want to show the text so we force a repaint # Download and install the theme package = self.module.download('http://localhost/test/download.php?file=2800&name=Fat-flat.xpf') #package = self.module.download(url_string) try: self.module.install(package) msgbox.close() complete_msgbox = QMessageBox() complete_msgbox.setWindowTitle('Complete') complete_msgbox.setText('Install complete.') complete_msgbox.setStandardButtons(QMessageBox.Ok) complete_msgbox.setAttribute(Qt.WA_DeleteOnClose) complete_msgbox.exec_() except: msgbox.close() print "Unexpected error:", sys.exc_info()[:2] failed_msgbox = QMessageBox() failed_msgbox.setWindowTitle('Failed') failed_msgbox.setText('Install failed. Please try again later.') failed_msgbox.setStandardButtons(QMessageBox.Ok) failed_msgbox.setAttribute(Qt.WA_DeleteOnClose) failed_msgbox.exec_() else: QDesktopServices.openUrl(url)
def open(self,fileName): tempFileName = fileName if tempFileName == '': tempFileName = self.fileName xmlReader = QtReduceXmlReader(self) newModel = xmlReader.readModel(tempFileName) if not newModel: tit = self.tr("Unable to Open File") txt = self.tr("The file ") txt += '"' + fileName + '" ' txt += self.tr("cannot be opened.") mbox = QMessageBox(self) mbox.setIcon(QMessageBox.Information) mbox.setWindowModality(Qt.WindowModal) mbox.setWindowTitle(tit) mbox.setText(txt) mbox.exec_() return False self.removeRows(0,self.rowCount()) self.insertRows(0,len(newModel)) for row in range(len(newModel)): self.setData(self.index(row,0),newModel[row],self.RawDataRole) return True
def __abortComputationBox(self): tit = self.tr("Aborting Batch Computation") txt = self.tr("Reduce is currently evaluating several groups in " "batch. Do you want to interrupt only the current " "computation or all?") diag = QMessageBox(self.model.controller.mainWindow) diag.setWindowTitle(tit) diag.setIcon(QMessageBox.Question) diag.setText(txt) abortAll = diag.addButton("Abort All",QMessageBox.YesRole) abortCurrent = diag.addButton("Abort Current",QMessageBox.YesRole) cancel = diag.addButton(QMessageBox.StandardButton.Cancel) diag.setDefaultButton(abortAll) diag.setEscapeButton(cancel) diag.setWindowModality(Qt.WindowModal) diag.exec_() ans = diag.clickedButton() if ans == abortAll: return 'all' elif ans == abortCurrent: return 'current' elif ans == cancel: return 'cancel' traceLogger.critical("unidentifiable button %s" % ans)
def Activated(self): dlg = QMessageBox(QMessageBox.Information, 'FreeCAD: Inventor workbench...', 'Command not ' + self.__class__.__name__ + ' yet implemented!') dlg.setWindowModality(Qt.ApplicationModal) dlg.exec_()