def saveXML(self): if len(self.tools.framemenu.getAllFrames()) > 1: result = QFileDialog.getSaveFileName(self, 'Choose the destination for the animation file!', '.', 'Animation File (*.armo)') if result[0] != "": XML().toXML(self.tools.framemenu.getAllFrames(), result[0]) else: QMessageBox.information(self, "Stickman Message", "You need at least 2 frames to save the animation!")
def importGraph(self, text): '''Init text after an import. Argument(s): text (str): Textual representation of the graph ''' self.acceptUpdate = False self.setPlainText(text) pydotGraph = graph_from_dot_data(text) # Check that attributes are in valid form message = self.checkItemsAttributes(pydotGraph.get_nodes(), pydotGraph.get_edges()) if not message: self.rebuildTextModel(text, pydotGraph) # Send every elements to the model to build him for id, args in self.nodes.items(): self.controller.onCreateNode(id, args) for id, args in self.edges.items(): self.controller.onCreateEdge(args[EdgeArgs.sourceId], args[EdgeArgs.destId]) # Some attributes are in invalid form else: QMessageBox.warning(self, "Syntax error", message) self.acceptUpdate = True
def QuestionDialog(title, text, info = None, dontAsk = False): msgBox = QMessageBox() buttonYes = msgBox.addButton(_("Yes"), QMessageBox.ActionRole) buttonNo = msgBox.addButton(_("No"), QMessageBox.ActionRole) answers = {buttonYes:"yes", buttonNo :"no"} if dontAsk: buttonDontAsk = msgBox.addButton(_("Don't ask again"), QMessageBox.ActionRole) answers[buttonDontAsk] = "dontask" msgBox.setText(text) if not info: info = _("Do you want to continue?") msgBox.setInformativeText(info) dialog = Dialog(_(title), msgBox, closeButton = False, isDialog = True, icon="question") dialog.resize(300,120) dialog.exec_() ctx.mainScreen.processEvents() if msgBox.clickedButton() in answers.keys(): return answers[msgBox.clickedButton()] return "no"
def _validate_monkeys(self): first_month = Monkey.unslash(self.ui.firstMonthEdit.text()) last_month = Monkey.unslash(self.ui.lastMonthEdit.text()) if not Monkey.is_valid_pair(first_month, last_month): msg = 'Invalid time frame: invalid month or first month after last month!' QMessageBox.critical(QMessageBox(), 'Input Error', msg) self.ui.firstMonthEdit.setFocus() return None return TimeInterval(first_month=first_month, last_month=last_month)
def _save_clicked(self): rec = self._valid_emp() if rec: try: rec.save() except AllocatException as e: QMessageBox.critical(QMessageBox(), 'Input Error', e.msg) self.ui.nameEdit.setFocus() return Dataset.employees = Employee.get_all() self._load_list(Dataset.employees.keys(), rec.name) self.ui.addBtn.setEnabled(True)
def fromXML(self): file = QFileDialog.getOpenFileName(self, "Load Animation", ".", "Animation Files (*.armo)") if file[0] != "": try: frames = XML().fromXML(file[0]) self.tools.framemenu.removeAllFrames() for frame in frames: self.tools.framemenu.addNewFrame(frame) if len(frames) > 0: getWorld().setWorldFrom(frames[0]) except: QMessageBox.information(self, "Stickman Message", "The animation file is not valid!")
def show_warning(text): """ Shows a simple warning with given text. """ msg_box = QMessageBox() msg_box.setText(text) msg_box.setStandardButtons(QMessageBox.Ok) msg_box.setDefaultButton(QMessageBox.Ok) msg_box.exec()
def about(self): # Get the about text from a file inside the plugin zip file # The get_resources function is a builtin function defined for all your # plugin code. It loads files from the plugin zip file. It returns # the bytes from the specified file. # # Note that if you are loading more than one file, for performance, you # should pass a list of names to get_resources. In this case, # get_resources will return a dictionary mapping names to bytes. Names that # are not found in the zip file will not be in the returned dictionary. text = get_resources('about.txt') QMessageBox.about(self, 'About the Interface Plugin Demo', text.decode('utf-8'))
def buttonExportClicked(self): (filePaths, filter) = QFileDialog.getOpenFileNames( parent=self, caption="转换数据库文件为文本格式", directory=QApplication.applicationDirPath() + "/../data", filter="Database file (*.db * mdb)", ) if not filePaths: return # if DatabaseMgr().convertToText(filePaths): QMessageBox.information(self, "格式转换", "转换成功!") else: QMessageBox.warning(self, "格式转换", "转换失败!")
def makeDatabase(self): '''Runs recollindex outside calibre like in a terminal. Look for recollindex for more information about the flags and options''' self.cmd = [prefs['pathToRecoll'] + '/recollindex', '-c', prefs['pathToCofig'] + '/plugins/recollFullTextSearchPlugin'] #TODO: Fix for Linux #self.cmd = 'LD_LIBRARY_PATH="" ' + prefs['pathToRecoll'] + '/recollindex -c ' + prefs['pathToCofig'] + '/plugins/recollFullTextSearchPlugin' if self.replaceDatabase == True : self.cmd += [' -z'] self.p = Popen(self.cmd, shell=False) # TODO: Was close_fds nessesary? check it on linux #self.p = Popen(self.cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True) box = QMessageBox() box.about(self, 'Please read! \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t','Depending on you library size this operation can take a lot of time.\nThe process runs outside calibre so you can use or close it, but do not use this plugin.\nFor now there is no information about when recoll finishs,\nso look up, whether a recoll of recollindex process is running on you system.')
def msgbox(cls, typename, text, button0, button1=None, button2=None, title=None, form=None): if form: logger.warn("MessageBox: Se intentó usar form, y no está implementado.") icon = QMessageBox.NoIcon if not title: title = "Pineboo" if typename == "question": icon = QMessageBox.Question if not title: title = "Question" elif typename == "information": icon = QMessageBox.Information if not title: title = "Information" elif typename == "warning": icon = QMessageBox.Warning if not title: title = "Warning" elif typename == "critical": icon = QMessageBox.Critical if not title: title = "Critical" # title = unicode(title,"UTF-8") # text = unicode(text,"UTF-8") msg = QMessageBox(icon, title, text) msg.addButton(button0) if button1: msg.addButton(button1) if button2: msg.addButton(button2) return msg.exec_()
def InfoDialog(text, button=None, title=None, icon="info"): if not title: title = _("Information") if not button: button = _("OK") msgBox = QMessageBox() buttonOk = msgBox.addButton(button, QMessageBox.ActionRole) msgBox.setText(text) dialog = Dialog(_(title), msgBox, closeButton = False, isDialog = True, icon = icon) dialog.resize(300,120) dialog.exec_() ctx.mainScreen.processEvents()
def show_font_face_rule_for_font_file(file_data, added_name, parent=None): try: fm = FontMetadata(BytesIO(file_data)).to_dict() except UnsupportedFont: return pp = _('Change this to the relative path to: %s') % added_name rule = '''@font-face {{ src: url({pp}); font-family: "{ff}"; font-weight: {w}; font-style: {sy}; font-stretch: {st}; }}'''.format(pp=pp, ff=fm['font-family'], w=fm['font-weight'], sy=fm['font-style'], st=fm['font-stretch']) QApplication.clipboard().setText(rule) QMessageBox.information(parent, _('Font file added'), _( 'The font file <b>{}</b> has been added. The text for the CSS @font-face rule for this file has been copied' ' to the clipboard. You should paste it into whichever CSS file you want to add this font to.').format(added_name))
def _monkey_clicked(self, row, col): employee = self.tbl.item(row, 0).text() monkey = self.monkeys[col - 2] hdr = '%s\n%s' % (employee, Monkey.prettify(monkey)) lines = [] total = 0 for asn in self.efforts[employee].assignments: interval = TimeInterval( first_month=asn.first_month, last_month=asn.last_month ) asn_monkeys = Monkey.monkey_list(interval) if monkey in asn_monkeys: lines.append('%s: %d' % (asn.project_name, asn.effort)) total += asn.effort msg = hdr + '\n\n' + '\n'.join(lines) + ('\n\nTotal: %d' % total) QMessageBox.information(QMessageBox(), 'Effort Breakdown', msg)
def _remove_clicked(self): nickname = self.ui.nicknameEdit.text() msg = 'Are you sure you want to remove project ' + nickname + '?' reply = QMessageBox.question(QMessageBox(), 'Double check', msg) if reply == QMessageBox.Yes: rec = Dataset.projects[nickname] rec.remove() del Dataset.projects[nickname] self._load_list(Dataset.projects.keys())
def deleteFrame(self, caller): if not self.buttons.active == None: response = QMessageBox.question(caller, 'Frame Remove Message', "Are you sure you want to delete this frame?", QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes) if response == QMessageBox.Yes: self.buttons.active.setParent(None) del self.buttons[self.buttons.active] if self.start_index > 0: self.start_index = self.start_index-1 self.parent().canvas.hideMessage() self.rearrangeButtons()
def load(self, f): """Load file with name f. If succuss, return True. Otherwise, return False.""" if not os.path.isfile(f): return False self.encoding = None try: data = open(f, encoding="utf_8").read() self.encoding = "utf_8" except: try: data = open(f, encoding="latin_1").read() except: pass self.encoding = "latin_1" if not self.encoding: s = "Failed to open {}. File is not UTF-8 or Latin-1.".format(f) QMessageBox.critical(self, "File Error", s) return False self.setPlainText(data) return True
def _save_clicked(self): interval = self._validate_monkeys() if not interval: return rec = Project([ self.current_rec_id, self.ui.nicknameEdit.text(), self.ui.nameEdit.text(), interval.first_month, interval.last_month, self.ui.notesEdit.toPlainText(), self.ui.billingEdit.toPlainText() ]) try: rec.save() except AllocatException as e: QMessageBox.critical(QMessageBox(), 'Input Error', e.msg) self.ui.nameEdit.setFocus() return Dataset.projects = Project.get_all() self._load_list(Dataset.projects.keys(), rec.nickname) self.ui.addBtn.setEnabled(True)
def maybeSave(self): if not self.textPane.document().isModified(): return True ret = QMessageBox.warning(self, 'GuiScannos', 'The document has been modified.\n' 'Do you want to save your changes?', QMessageBox.Save | QMessageBox.Discard | QMessageBox.Cancel) if ret == QMessageBox.Save: return self.fileSave() if ret == QMessageBox.Cancel: return False return True
def _valid_emp(self): name = self.ui.nameEdit.text() if not Employee.is_valid_name(name): msg = 'Employee name is invalid' QMessageBox.critical(QMessageBox(), 'Input Error', msg) self.ui.nameEdit.setFocus() return None grade = self.ui.gradeEdit.text() if not Employee.is_valid_grade_step(grade): msg = 'Employee grade is invalid' QMessageBox.critical(QMessageBox(), 'Input Error', msg) self.ui.gradeEdit.setFocus() return None step = self.ui.stepEdit.text() if not Employee.is_valid_grade_step(step): msg = 'Employee step is invalid' QMessageBox.critical(QMessageBox(), 'Input Error', msg) self.ui.stepEdit.setFocus() return None fte = self.ui.fteEdit.text() if not Employee.is_valid_fte(fte): msg = 'Employee FTE is invalid' QMessageBox.critical(QMessageBox(), 'Input Error', msg) self.ui.fteEdit.setFocus() return None cp = '015' if self.ui.cp15Button.isChecked() else '016' investigator = self.ui.investigatorBox.isChecked() notes = self.ui.notesEdit.toPlainText() return Employee([ self.cur_rec_id, name, int(grade), int(step), int(fte), cp, investigator, notes ])
def exportToPDF(self): if self.slotsExportedDisabled_: return util = FLUtil() fileName = QFileDialog.getSaveFileName( self, util.translate("app", "Exportar a PDF"), "", util.translate("app", "Fichero PDF (*.pdf)") ) if fileName[0] == '': return if fileName[0].upper().find(".PDF") == -1: fileName = fileName[0] + ".pdf" if QtCore.QFile.exists(fileName): q = QMessageBox.question( self, util.translate("app", "Sobreescribir {}").format(fileName), util.translate( "app", "Ya existe un fichero llamado {}. ¿Desea sobreescribirlo?" ).format(fileName), util.translate("app", "&Sí"), util.translate("app", "&No"), "", 0, 1 ) if q: return self.slotPrintReportToPdf(fileName)
def show_dialog(self): QMessageBox.information(self, 'A test dialog', 'While this dialog is shown, the global menu should be hidden')
def login_check(self): # if self.ui.UserName.text() == 'hadrianl' and self.ui.Password.text() == '666666': if True: self.accept() else: QMessageBox.critical(self, '错误', '用户名或密码不匹配')
def encrypt_InputImage(self): #self.loading = LoadingScreen() #self.loading.startLoading() self.progressBar.setFormat("Encrypting...") self.step = 0 self.progressBar.setValue(self.step) if self.radioButton_2.isChecked(): if (self.plainTextEdit.toPlainText() == ""): QMessageBox.about(None, "Title", "Enter Plain Text") return elif (self.imagepath_2.text() == ""): QMessageBox.about(None, "Title", "Choose Input Image") return self.progressBar.setValue(self.step + 15) s1.encoded_message_image = s1.generate_encoded_image_from_text( self.plainTextEdit.toPlainText()) self.progressBar.setValue(self.step + 30) s1.hide() self.progressBar.setValue(self.step + 55) self.inputImage.setPixmap(QtGui.QPixmap('images/o1.png')) self.inputImage.adjustSize() img = Image.open('images/o1.png') width, height = img.size self.progressBar.setValue(self.step + 75) self.StegoImageSize.setText(str(width * height) + " pixels") self.StegoImageSize.setStyleSheet("background-color: lightgreen") self.progressBar.setValue(self.step + 100) if self.radioButton.isChecked(): if (self.plainTextEdit.toPlainText() == ""): QMessageBox.about(None, "Title", "Enter Plain Text") return elif (self.imagepath_2.text() == ""): QMessageBox.about(None, "Title", "Choose Input Image") return elif (self.keyTextBox.text() == ""): QMessageBox.about(None, "Title", "Enter the Key") return self.progressBar.setValue(self.step + 5) data = s2.encode(self.plainTextEdit.toPlainText(), self.keyTextBox.text(), self.imagepath_2.text()) self.progressBar.setValue(self.step + 20) img = Image.open('images/aes.png') width, height = img.size self.progressBar.setValue(self.step + 35) self.StegoImageSize.setText(str(width * height) + " pixels") self.progressBar.setValue(self.step + 50) self.StegoImageSize.setStyleSheet("background-color: lightgreen") self.plainTextEdit.setPlainText("") self.progressBar.setValue(self.step + 75) self.plainTextEdit_2.setPlainText(str(data)) self.progressBar.setValue(self.step + 100) #self.loading.stopLoading() self.progressBar.setFormat("Encrypted 100%..") QMessageBox.about(None, "Info", "Encryption is successful")
def limitCharacters(self): if len(self.plainTextEdit.toPlainText()) > 200: QMessageBox.about(None, "Error", "Not more than 200 characters allowed")
def step_dialog(parent, title, msg, det_msg=''): d = QMessageBox(parent) d.setWindowTitle(title) d.setText(msg) d.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel) return d.exec_() & QMessageBox.Cancel
def show_messagebox(message, title, icon=QMessageBox.Information): msg_box = QMessageBox() msg_box.setIcon(icon) msg_box.setText(message) # msg_box.setInformativeText(message) msg_box.setWindowTitle(title) # msg_box.setDetailedText("The details are as follows:") msg_box.setStandardButtons(QMessageBox.Ok) retval = msg_box.exec_()
def doStartSubProcess(self, strObjName): print('Button {} clicked'.format(strObjName)) args0 = strObjName.split('_') iIndex = int(args0[1]) strAddress = self.lstTextEditAddress[iIndex].text() strPort = self.lstTextEditPort[iIndex].text() #todo fix here if strAddress != "" and strAddress != 'localhost': msg = QMessageBox() msg.setIcon(QMessageBox.Information) msg.setText("尝试启动远程服务进程!😹 ") msg.setInformativeText("不是本地localhost本地进程😹 ") msg.setWindowTitle("操作提示:") msg.setDetailedText("请在远程机器上启动本程序启动服务进程") retval = msg.exec() return if strAddress == "": strAddress = 'localhost' if strPort == "": strPort = str(portNumberStart + iIndex) mediator = self.getMediator() bRetOk = mediator.startUpEastMoneyZjlxProcess(self, iIndex, strAddress, strPort)
def show_success(self): message = QMessageBox(self.gui) message.setIcon(QMessageBox.Information) message.setText("KiPEO has compleletly reshaped your e-book.\r\n\r\nWould you like to see what we have changed?") message.setWindowTitle("KiPEO") message.setStandardButtons(QMessageBox.Yes | QMessageBox.No) message.show() user_choice = message.exec_() if user_choice == QMessageBox.Yes: #Show the user what changes we have made, allowing her to #revert them if necessary self.boss.show_current_diff() #Update the editor UI to take into account all the changes we #have made self.boss.apply_container_update_to_gui()
def file_load(self): """Loads mpdj data from a file. Opens a file dialog which asks for the file to load.""" global_properties = GlobalProperties.get_instance() file_name = self.file_dialog(load_save_type=QFileDialog.AcceptOpen) if file_name: if global_properties.changes_happened_since_last_save: retval = show_discard_data_ok_cancel_message() if not global_properties.changes_happened_since_last_save or retval == QMessageBox.Ok: try: global_properties.load_mpdjdata_from_file(file_name) except AttributeError as err: message_box = QMessageBox() message_box.setText( 'Error reading your MPDJ-File: {}'.format(err)) message_box.setWindowTitle('Load error.') message_box.setStandardButtons(QMessageBox.Ok) message_box.setIcon(QMessageBox.Warning) message_box.exec_()
def show_discard_data_ok_cancel_message(): """Shows a QMessageBox to ask if the current mpdj data should be discarded. Contains an OK and an Cancel Button.""" msg = QMessageBox() msg.setIcon(QMessageBox.Question) msg.setText("You have unsaved changes in your current Data. Discard\ unsaved changes and proceed?") msg.setInformativeText("Unsaved changes will be lost.") msg.setWindowTitle("Unsaved changes") msg.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel) retval = msg.exec_() return retval
def save_mpdj_data_to_file(self, p_file_name: str): """Saves the current mpdj data to the file by the path given in p_file_name.""" try: global_properties = GlobalProperties.get_instance() global_properties.save_mpdj_data_to_file(p_file_name) self.statusBar().showMessage('Saved to {}'.format(p_file_name), 5000) except (OSError, IOError) as exception: message_box = QMessageBox() message_box.setText('Error saving the file: {}'.format( str(exception))) message_box.setWindowTitle('Error saving the file.') message_box.setStandardButtons(QMessageBox.Ok) message_box.setIcon(QMessageBox.Warning) message_box.exec_()
def file_dialog(self, load_save_type=QFileDialog.AcceptSave): """Opens an file save dialog and returns the selected filename.""" file_save_dialog = QFileDialog(self) file_save_dialog.setFileMode(QFileDialog.AnyFile) file_save_dialog.setAcceptMode(load_save_type) file_save_dialog.setNameFilters( ["MPDJ files (*.{})".format(FILE_SUFFIX)]) file_save_dialog.selectNameFilter( "MPDJ files (*.{})".format(FILE_SUFFIX)) file_save_dialog.setDefaultSuffix((FILE_SUFFIX)) exec_value = file_save_dialog.exec() if exec_value == 0: return None file_names = file_save_dialog.selectedFiles() if len(file_names) != 1: message_box = QMessageBox() message_box.setText('Please select only one file!') message_box.setWindowTitle('Save error.') message_box.setStandardButtons(QMessageBox.Ok) message_box.setIcon(QMessageBox.Information) message_box.exec_() return None return file_names[0]
def error_handler(typ, value, trace): QApplication.restoreOverrideCursor() QMessageBox.critical(iface, typ.__name__, "{}".format(value)) SYS_HOOK(typ, value, trace)
def __init__(self, title, text, type="ok", default=None, customButtons =None, customIcon=None, run=True, destroyAfterRun=True, detailed=False, longText=""): self.rc = None self.dialog = None self.msgBox = QMessageBox() self.doCustom = False self.customButtons = customButtons icon = None buttons = None if type == 'ok': buttons = QMessageBox.Ok icon = "question" elif type == 'error': icon = "error" buttons = QMessageBox.Ok elif type == 'warning': icon = "warning" buttons = QMessageBox.Ok elif type == 'okcancel': icon = "question" buttons = QMessageBox.Ok | QMessageBox.Cancel elif type == 'question': icon = "question" buttons = QMessageBox.Ok | QMessageBox.Cancel elif type == 'yesno': icon = "question" buttons = QMessageBox.Yes | QMessageBox.No elif type == 'custom': self.doCustom = True if customIcon: icon = customIcon else: icon = "question" text = "<qt>%s</qt>" % text.replace("\n", " ") self.msgBox.setText(text) if detailed: self.msgBox.setDetailedText(unicode(longText)) if self.doCustom: button = None for index, text in enumerate(self.customButtons): button = self.msgBox.addButton(text, QMessageBox.ActionRole) if default is not None and default == index: self.msgBox.setDefaultButton(button) else: self.msgBox.setStandardButtons(buttons) if default == "no": default = QMessageBox.No elif default == "yes": default = QMessageBox.Yes elif default == "ok": default = QMessageBox.Ok else: default = None self.msgBox.setDefaultButton(default) self.dialog = Dialog(_(title), self.msgBox, closeButton=False, isDialog=True, icon=icon) self.dialog.resize(QSize(0,0)) if run: self.run(destroyAfterRun)
def startAllThread(self): msg = QMessageBox() msg.setIcon(QMessageBox.Information) msg.setText("😯还未实现,请一个个点击 按钮启动进程!😹 ") msg.setInformativeText("🤐一次启动,电脑会变得很慢,后期实现😹 ") msg.setWindowTitle("😬操作提示:") msg.setDetailedText("🤔笔记本电脑严重发烫") retval = msg.exec() pass
def doStopSubProcess(self, strObjName): print('Button {} clicked'.format(strObjName)) args0 = strObjName.split('_') iIndex = int(args0[1]) strAddress = self.lstTextEditAddress[iIndex].text() strPort = self.lstTextEditPort[iIndex].text() #todo fix here if strAddress != "" and strAddress != 'localhost': msg = QMessageBox() msg.setIcon(QMessageBox.Information) msg.setText("远程程服务进程!😹 ") msg.setInformativeText("不是本地localhost本地进程😹 ") msg.setWindowTitle("操作提示:") msg.setDetailedText("请在远程机器上关闭服务进程") retval = msg.exec() return if strAddress == "": strAddress = 'localhost' if strPort == "": strPort = portNumberStart + iIndex mediator = self.getMediator() mediator.shutdownEastMoneyZjlxProcess(self, iIndex, strAddress, strPort) # self.lstBntStartSubProcessSocketServer[iIndex].setEnabled(True) # self.lstBntStopSubProcessSocketServer[iIndex].setEnabled(False) # # self.lstTextEditPort[iIndex].setEnabled(True) # self.lstTextEditAddress[iIndex].setEnabled(True) pass
def display_info(self, text: str): message_box = QMessageBox() message_box.setIcon(QMessageBox.Information) message_box.setWindowTitle("Information") message_box.setText(text) message_box.setStandardButtons(QMessageBox.Ok) message_box.exec_()
def accept(self): """Tries to add brick, and closes the dialog if successful.""" filename = self.wfile.filename() # read fits file busy = BusyIndicator() try: input_hdu = pyfits.open(filename)[0] except Exception as err: busy.reset_cursor() QMessageBox.warning( self, "Error reading FITS", "Error reading FITS file %s: %s" % (filename, str(err))) return # check name srcname = str(self.wname.text()) or os.path.splitext( os.path.basename(str(filename)))[0] if srcname in set([src.name for src in self.model.sources]): QMessageBox.warning( self, "Already in model", "<p>The model already contains a source named '%s'. Please select a different name.</p>" % srcname) return # get image parameters hdr = input_hdu.header max_flux = float(input_hdu.data.max()) wcs = WCS(hdr, mode='pyfits') # Get reference pixel coordinates # wcs.getCentreWCSCoords() doesn't work, as that gives us the middle of the image # So scan the header to get the CRPIX values ra0 = dec0 = 1 for iaxis in range(hdr['NAXIS']): axs = str(iaxis + 1) name = hdr.get('CTYPE' + axs, axs).upper() if name.startswith("RA"): ra0 = hdr.get('CRPIX' + axs, 1) - 1 elif name.startswith("DEC"): dec0 = hdr.get('CRPIX' + axs, 1) - 1 # convert pixel to degrees # print ra0,dec0 ra0, dec0 = wcs.pix2wcs(ra0, dec0) ra0 *= DEG dec0 *= DEG # print ModelClasses.Position.ra_hms_static(ra0) # print ModelClasses.Position.dec_sdms_static(dec0) sx, sy = wcs.getHalfSizeDeg() sx *= DEG sy *= DEG nx, ny = input_hdu.data.shape[-1:-3:-1] pos = ModelClasses.Position(ra0, dec0) flux = ModelClasses.Flux(max_flux) shape = ModelClasses.FITSImage(sx, sy, 0, os.path.basename(filename), nx, ny, pad=float(str(self.wpad.text()) or "1")) img_src = SkyModel.Source(srcname, pos, flux, shape=shape) self.model.setSources(self.model.sources + [img_src]) self.model.emitUpdate(SkyModel.SkyModel.UpdateAll, origin=self) busy.reset_cursor() return QDialog.accept(self)
def display_error(self, text: str): message_box = QMessageBox() message_box.setIcon(QMessageBox.Critical) message_box.setWindowTitle("Error") message_box.setText(text) message_box.setStandardButtons(QMessageBox.Ok) message_box.exec_()
def stopAllThread(self): msg = QMessageBox() msg.setIcon(QMessageBox.Information) msg.setText("🤑还未实现,请一个个点击 按钮关闭进程!😹 ") msg.setInformativeText("🙄一次关闭,电脑会变得很慢,后期实现😹 ") msg.setWindowTitle("操作提示:") msg.setDetailedText("🤮笔记本电脑严重发烫") retval = msg.exec() pass
def focusOutEvent(self, event): '''Handle focus out event. Argument(s): event (QFocusEvent): Focus event ''' self.acceptUpdate = False # Create pydot graph from text pydotGraph = graph_from_dot_data(self.toPlainText()) # If the pydot graph is valid we can rewrite the text and check changes if pydotGraph: # If attributes are in valid form message = self.checkItemsAttributes(pydotGraph.get_nodes(), pydotGraph.get_edges()) if not message: oldNodes = self.nodes oldEdges = self.edges self.nodes = {} self.edges = {} self.rebuildTextModel(self.toPlainText(), pydotGraph) # Compare old and new text and send changes to the model # Add nodes added added = self.nodes.keys() - oldNodes.keys() for idNode in added: self.controller.onCreateNode(idNode, self.nodes[idNode]) # Edit nodes changed intersect = set(self.nodes.keys()).intersection( set(oldNodes.keys())) for idNode in intersect: if self.nodes[idNode] != oldNodes[idNode]: self.controller.onEditNode(idNode, self.nodes[idNode]) # Remove nodes deleted removed = oldNodes.keys() - self.nodes.keys() for idNode in removed: self.controller.onRemoveNode(idNode) # Delete edges which contain the node edgeToRemove = [] for edge in self.edges: if (idNode == self.edges[edge][EdgeArgs.sourceId] or idNode == self.edges[edge][EdgeArgs.destId]): edgeToRemove.append(edge) self.acceptUpdate = True for edge in edgeToRemove: self.removeEdge({ EdgeArgs.id: edge, EdgeArgs.sourceId: self.edges[edge][EdgeArgs.sourceId], EdgeArgs.destId: self.edges[edge][EdgeArgs.destId] }) self.acceptUpdate = False # Remove edges deleted removed = oldEdges.keys() - self.edges.keys() for idEdge in removed: self.controller.onRemoveEdge( oldEdges[idEdge][EdgeArgs.sourceId], oldEdges[idEdge][EdgeArgs.destId]) # Add edges added added = self.edges.keys() - oldEdges.keys() for idEdge in added: nodeSource = self.edges[idEdge][EdgeArgs.sourceId] nodeDest = self.edges[idEdge][EdgeArgs.destId] self.controller.onCreateEdge(nodeSource, nodeDest) QTextEdit.focusOutEvent(self, event) # Some attributes are in invalid form: show an error window else: QMessageBox.warning(self, "Syntax error", message) self.setFocus() # Pydot graph invalid: show an error window else: QMessageBox.warning(self, "Syntax error", "The dot structure is invalid.") self.setFocus() self.acceptUpdate = True
def about(self): text = get_resources('about.txt') QMessageBox.about(self, 'About calibrebeam', text.decode('utf-8'))
def notify_operation_error(operation, msg): QMessageBox.warning(None, 'warning', operation + ': ' + msg)
def display_error(text: str): """Displays an error message to the user.""" message = QMessageBox() message.setIcon(QMessageBox.Critical) message.setWindowTitle("Error") message.setText(text) message.setStandardButtons(QMessageBox.Ok) message.exec_()
def select_load_dataset_mode(self): box = QMessageBox() box.setIcon(QMessageBox.Question) box.setWindowTitle('load seed') box.setText( "Please Select the way to load the seed, " "you can load in new config or load in current config (will overwrite current seeds)!" ) box.setStandardButtons(QMessageBox.Ok | QMessageBox.No | QMessageBox.Cancel) creat_config = box.button(QMessageBox.Ok) creat_config.setText('New') replace_config = box.button(QMessageBox.No) replace_config.setText('Replace') box.exec_() if box.clickedButton() == creat_config: self.on_createConfig_clicked() self.load_seeds(seed_path=self.ui.seedPath.text()) elif box.clickedButton() == replace_config: self.load_seeds(seed_path=self.ui.seedPath.text()) else: self.ui.seedPath.setText('')
def _remove_clicked(self): # nickname = self.ui.nicknameEdit.text() msg = 'Are you sure you want to remove assignment ?' reply = QMessageBox.question(QMessageBox(), 'Double check', msg)
def upfile(self): fname = QFileDialog.getOpenFileName(self, "up file") if fname[0]: information = upfile.up(fname[0]) QMessageBox.information(self, "上传", information)
def borrar_libro(id): res = QMessageBox.question(MainWindow, "Info", "Vas a borrar un registro de id: " + str(id)) if res == QMessageBox.Yes: operaciones_bd.borrar_libro(id) mostrar_table_widget()
def about(self): text = get_resources('about.txt') QMessageBox.about(self, 'About the OPDS Client plugin', text.decode('utf-8'))
def about(self): text = get_resources('about.txt') QMessageBox.about(self, 'About the Calibre Book Brainz Plugin', text.decode('utf-8'))
def javaScriptAlert(self, frame, msg): QMessageBox.information(self.view().parentWidget(), None, msg)
def javaScriptConfirm(self, frame, msg): return QMessageBox.question(self.view().parentWidget(), None, msg) == QMessageBox.Yes
self.parse_command() else: if key in self.ontologies: self.info_bar.build_model(self.ontologies[key], path) self.info_bar.build_tree() self.import_explorer.build_tree(self.ontologies[key]) # just in case anything gets weird, we will save a pointer to the regular console backup = sys.stdout app = MacleodApplication(sys.argv, backup) # Set the style to "Fusion", which looks similar across all platforms app.setStyle(QStyleFactory.create('Fusion')) window = MacleodWindow() # Capture all errors and print statements in our console sys.stdout = window.console window.setWindowTitle("Macleod") window.show() # Generic error capturing while True: try: sys.exit(app.exec_()) except Exception as e: error = QMessageBox() error_text = "An error has occurred:\n{0}".format(e) error.setText(error_text) error.exec()
def notify(self, msg): self.label_turn.setText(msg) QMessageBox.information(self, "提示", msg)
def _save_dialog(self, parent, title, msg, det_msg=''): d = QMessageBox(parent) d.setWindowTitle(title) d.setText(msg) d.setStandardButtons(QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel) return d.exec_()