示例#1
0
    def _wrong_channel(self) -> None:
        if self.manager.prompted_wrong_channel:
            log.debug(
                "Not prompting for wrong channel, already showed it since startup"
            )
            return
        self.manager.prompted_wrong_channel = True

        version = self.manager.version
        downgrade_version = self.manager.updater.version or ""
        version_channel = self.manager.updater.get_version_channel(version)
        current_channel = self.manager.get_update_channel()
        msg = QMessageBox()
        msg.setIcon(QMessageBox.Warning)
        msg.setWindowIcon(self.icon)
        msg.setText(
            Translator.get("WRONG_CHANNEL", [version, version_channel, current_channel])
        )
        switch_channel = msg.addButton(
            Translator.get("USE_CHANNEL", [version_channel]), QMessageBox.AcceptRole
        )
        downgrade = msg.addButton(
            Translator.get("DOWNGRADE_TO", [downgrade_version]), QMessageBox.AcceptRole
        )
        msg.exec_()

        res = msg.clickedButton()
        if downgrade_version and res == downgrade:
            self.manager.updater.update(downgrade_version)
        elif res == switch_channel:
            self.manager.set_update_channel(version_channel)
示例#2
0
    def clear_media_list(self):
        """Clear media conversion list with user confirmation."""
        msg_box = QMessageBox(
            QMessageBox.Warning,
            self.tr('Warning!'),
            self.tr('Clear all tasks?'),
            QMessageBox.NoButton, self)

        msg_box.addButton(self.tr("&Yes"), QMessageBox.AcceptRole)
        msg_box.addButton(self.tr("&No"), QMessageBox.RejectRole)

        if msg_box.exec_() == QMessageBox.AcceptRole:
            # If use says YES clear table of conversion tasks
            self.tb_tasks.clearContents()
            self.tb_tasks.setRowCount(0)
            # Clear MediaList.medias so it does not contain any element
            self.media_list.clear()
            # Update buttons so user cannot convert, clear, or stop if there
            # is no file in the list
            self.update_interface(convert=False,
                                  clear=False,
                                  remove=False,
                                  stop=False,
                                  presets=False,
                                  profiles=False)
示例#3
0
文件: utils.py 项目: gpiantoni/phypno
def choose_file_or_dir():
    """Create a simple message box to see if the user wants to open dir or file

    Returns
    -------
    str
        'dir' or 'file' or 'ieegorg' or 'abort'

    """
    question = QMessageBox(QMessageBox.Information, 'Open Dataset',
                           'Do you want to open a file, a directory or a '
                           'remote ieeg.org dataset?')
    dir_button = question.addButton('Directory', QMessageBox.YesRole)
    file_button = question.addButton('File', QMessageBox.NoRole)
    remote_button = question.addButton('Remote Dataset', QMessageBox.NoRole)
    question.addButton(QMessageBox.Cancel)
    question.exec_()
    response = question.clickedButton()

    if response == dir_button:
        return 'dir'
    elif response == file_button:
        return 'file'
    elif response == remote_button:
        return 'remote'
    else:
        return 'abort'
    def generate(self):
        if self.__pathToMessages == "":
            #throw a dialog here
            errorMessageBox = QMessageBox()
            errorMessageBox.setText("Error:");
            errorMessageBox.setInformativeText("You don't seem to have specified a messages.htm file for me to parse.")
            errorMessageBox.exec_()
            return
        
        pickSaveFileMessageBox = QMessageBox()
        pickSaveFileMessageBox.setText("Please specify where you would like to save the wordcloud picture.")
        pickSaveFileMessageBox.setInformativeText("It may take 1-2 minutes or longer to parse through all of your Facebook messages. A pop-up dialog will alert you when I have finished creating the image.")
        pickSaveFileMessageBox.setStandardButtons(QMessageBox.Cancel | QMessageBox.Save)
        pickSaveFileMessageBox.setDefaultButton(QMessageBox.Save)
        but = pickSaveFileMessageBox.exec_()
        if but == QMessageBox.Cancel:
            return
        saveFileName = QFileDialog.getSaveFileName(self,"Save PNG Image","~/","PNG Image (*.png)")[0]

        s = grab_messages.parse_messages(self.__pathToMessages,saveFileName)
        wordcloudgen.makeWordCloud(s,saveFileName)

        
        doneMessageBox = QMessageBox()
        doneMessageBox.setText("Done. Please check " + saveFileName + " for your word cloud image.")
        doneMessageBox.addButton("Done, Thanks.",QMessageBox.RejectRole)
        doneBut = doneMessageBox.exec_()
        QCoreApplication.instance().quit()
示例#5
0
    def __on_thread_update_finished(self):
        self._thread.quit()
        # Clear notificator
        notification_widget = Pireal.get_service("notification")
        notification_widget.clear()

        msg = QMessageBox(self)
        if not self._updater.error:
            if self._updater.version:
                version = self._updater.version
                msg.setWindowTitle(self.tr("New version available!"))
                msg.setText(self.tr("Check the web site to "
                                    "download <b>Pireal {}</b>".format(
                                        version)))
                download_btn = msg.addButton(self.tr("Download!"),
                                             QMessageBox.YesRole)
                msg.addButton(self.tr("Cancel"),
                              QMessageBox.RejectRole)
                msg.exec_()
                r = msg.clickedButton()
                if r == download_btn:
                    webbrowser.open_new(
                        "http://centaurialpha.github.io/pireal")
        self._thread.deleteLater()
        self._updater.deleteLater()
示例#6
0
	def fileChanged(self, fileName):
		ind = self.fileNames.index(fileName)
		self.tabWidget.setCurrentIndex(ind)
		if not QFile.exists(fileName):
			self.editBoxes[ind].document().setModified(True)
			QMessageBox.warning(self, '', self.tr(
				'This file has been deleted by other application.\n'
				'Please make sure you save the file before exit.'))
		elif not self.editBoxes[ind].document().isModified():
			# File was not modified in ReText, reload silently
			self.openFileMain()
			self.updatePreviewBox()
		else:
			text = self.tr(
				'This document has been modified by other application.\n'
				'Do you want to reload the file (this will discard all '
				'your changes)?\n')
			if self.autoSaveEnabled:
				text += self.tr(
					'If you choose to not reload the file, auto save mode will '
					'be disabled for this session to prevent data loss.')
			messageBox = QMessageBox(QMessageBox.Warning, '', text)
			reloadButton = messageBox.addButton(self.tr('Reload'), QMessageBox.YesRole)
			messageBox.addButton(QMessageBox.Cancel)
			messageBox.exec()
			if messageBox.clickedButton() is reloadButton:
				self.openFileMain()
				self.updatePreviewBox()
			else:
				self.autoSaveEnabled = False
				self.editBoxes[ind].document().setModified(True)
		if fileName not in self.fileSystemWatcher.files():
			# https://github.com/retext-project/retext/issues/137
			self.fileSystemWatcher.addPath(fileName)
示例#7
0
    def _show_backup_decision(self, error=None):
        text = '<p>{0}</p><p>{1}</p>'.format(
            self.BACKUP_INTRO_TEXT if error is None else error,
            self.BACKUP_PROMPT_TEXT,
        )

        dialog = QMessageBox(
            QMessageBox.Question if error is None else QMessageBox.Critical,
            self.BACKUP_DIALOG_CAPTION if error is None else self.BACKUP_DIALOG_ERROR_CAPTION,
            text,
        )

        revert_button = dialog.addButton(self.REVERT_BACKUP_BUTTON_TEXT, QMessageBox.AcceptRole)
        delete_button = dialog.addButton(self.DELETE_BACKUP_BUTTON_TEXT, QMessageBox.DestructiveRole)
        examine_button = dialog.addButton(self.EXAMINE_BACKUP_BUTTON_TEXT, QMessageBox.ActionRole)
        dialog.addButton(self.QUIT_BUTTON_TEXT, QMessageBox.RejectRole)

        dialog.exec()
        clicked_button = dialog.clickedButton()

        if clicked_button == examine_button:
            QMetaObject.invokeMethod(self, '_examine_backup', Qt.QueuedConnection)
        elif clicked_button == revert_button:
            self._progress_dialog = QProgressDialog(None)
            self._progress_dialog.setLabelText(self.REVERT_BACKUP_PROGRESS_TEXT)
            self._progress_dialog.setCancelButton(None)
            self._progress_dialog.setRange(0, 0)
            self._progress_dialog.forceShow()

            self.request_revert_backup.emit()
        elif clicked_button == delete_button:
            self.request_delete_backup.emit()
        else:
            self.quit()
示例#8
0
文件: ocsvm.py 项目: rhoef/afw
    def checkParameters(self, parent):
        """Pop up a dialog and ask the user wether to proceed with current
        unoptimized parameters, run cross validation or cancel.
        """

        title = "Optimize Parameters"
        text = "You need to optimize SVM parameters before you predict."

        QApplication.restoreOverrideCursor()

        qmb = QMessageBox(QMessageBox.Question, title, text, parent=parent)
        ignoreBtn = qmb.addButton(qmb.Ignore)
        cancelBtn = qmb.addButton(qmb.Cancel)
        runBtn = qmb.addButton(
            "Optimize", qmb.AcceptRole)
        qmb.exec_()

        QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))

        if qmb.clickedButton() == runBtn:
            # parent sets some flag
            parent.estimateParameters()
            return True
        elif qmb.clickedButton() == ignoreBtn:
            return True
        elif qmb.clickedButton() == cancelBtn:
            return False

        raise RuntimeError()
示例#9
0
    def __on_thread_update_finished(self):
        # Hide overlay widget
        self.overlay.hide()
        self._thread.quit()
        msg = QMessageBox(self)
        if not self._updater.error:
            if self._updater.version:
                version = self._updater.version
                msg.setWindowTitle(self.tr("New version available!"))
                msg.setText(self.tr("Check the web site to "
                                    "download <b>Pireal {}</b>".format(
                                        version)))
                download_btn = msg.addButton(self.tr("Download!"),
                                             QMessageBox.YesRole)
                msg.addButton(self.tr("Cancel"),
                              QMessageBox.RejectRole)
                msg.exec_()
                r = msg.clickedButton()
                if r == download_btn:
                    webbrowser.open_new(
                        "http://centaurialpha.github.io/pireal")
            else:
                msg.setWindowTitle(self.tr("Information"))
                msg.setText(self.tr("Last version installed"))
                msg.addButton(self.tr("Ok"),
                              QMessageBox.AcceptRole)
                msg.exec_()
        else:
            msg.critical(self, self.tr("Error"),
                         self.tr("Connection error"))

        self._thread.deleteLater()
        self._updater.deleteLater()
示例#10
0
    def save_all(self):
        if self.num_frames == 0:
            return

        settings = constants.SETTINGS
        try:
            not_show = settings.value('not_show_save_dialog', type=bool, defaultValue=False)
        except TypeError:
            not_show = False

        if not not_show:
            cb = QCheckBox("Don't ask me again.")
            msg_box = QMessageBox(QMessageBox.Question, self.tr("Confirm saving all signals"),
                                  self.tr("All changed signal files will be overwritten. OK?"))
            msg_box.addButton(QMessageBox.Yes)
            msg_box.addButton(QMessageBox.No)
            msg_box.setCheckBox(cb)

            reply = msg_box.exec()
            not_show_again = cb.isChecked()
            settings.setValue("not_show_save_dialog", not_show_again)
            self.not_show_again_changed.emit()

            if reply != QMessageBox.Yes:
                return

        for f in self.signal_frames:
            if f.signal is None or f.signal.filename == "":
                continue
            f.signal.save()
示例#11
0
def queryExtraConfDialog(source, ev):
    if queryExtraConfUseConf(source, ev, defaultReject=False):
        return True

    ycmpath = ev.info["conf"]

    title = "Allow YouCompleteMe extra conf?"
    text = "Load %r? This may be a security risk if the file comes from an untrusted source." % ycmpath
    dlg = QMessageBox(QMessageBox.Question, title, text)
    bOkOnce = dlg.addButton("Load once", QMessageBox.AcceptRole)
    bOkAlways = dlg.addButton("Load always", QMessageBox.AcceptRole)
    bNoOnce = dlg.addButton("Reject once", QMessageBox.RejectRole)
    bNoAlways = dlg.addButton("Reject always", QMessageBox.RejectRole)
    dlg.setDefaultButton(bNoOnce)
    dlg.setEscapeButton(bNoOnce)
    dlg.exec_()

    clicked = dlg.clickedButton()
    if clicked in (bOkOnce, bOkAlways):
        if clicked is bOkAlways:
            addToFile(ycmpath, getConfigFilePath(CONF_ACCEPT))
        ev.accept(True)
        return True
    elif clicked in (bNoOnce, bNoAlways):
        if clicked is bNoAlways:
            addToFile(ycmpath, getConfigFilePath(CONF_REJECT))
        ev.accept(False)
        return True

    return False
示例#12
0
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"
示例#13
0
 def handle_bad_login(self):
     self.log.info("Bad username or password")
     msgBox = QMessageBox()
     msgBox.setWindowIcon(QIcon(general.favicon))
     msgBox.setWindowTitle('Login Error')
     msgBox.setIcon(QMessageBox.Warning)
     msgBox.setText("Bad username or password")
     msgBox.addButton(QPushButton('Ok'), QMessageBox.YesRole)
     msgBox.addButton(QPushButton('Reset Password'), QMessageBox.ActionRole)
     ret = msgBox.exec_()
 
     if ret == 1: # if reset password
         self.log.info("Password reset requested. Are you sure?")
         reply = QMessageBox.question(self, "Password Reset", 
                                      "Are you sure you want to reset your password to nothing?",
                                      QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
 
         if reply == QMessageBox.Yes:
             if self.login in self.user_db.all_credentials:
                 self.log.info("Resetting password for user {}...".format(self.login))
                 
                 self.user_db.modify_user(self.login, "")
                 QMessageBox.information(self, "Password was reset", "Your password was reset to empty. You can now login without password.\nAfter logging in, please use the settings dialog to change your password again!")
             else:
                 QMessageBox.warning(self, "Unknown user", "User name {} does not exist. Please use the 'Create new user' button to create it!".format(self.login))
         else:
             self.log.info("Keeping password unchanged")
示例#14
0
    def _root_moved(self, new_path: Path) -> None:
        engine = self.sender()
        log.info(f"Root has been moved for engine: {engine.uid} to {new_path!r}")
        info = [engine.local_folder, str(new_path)]

        msg = QMessageBox()
        msg.setIcon(QMessageBox.Critical)
        msg.setWindowIcon(self.icon)
        msg.setText(Translator.get("DRIVE_ROOT_MOVED", info))
        move = msg.addButton(
            Translator.get("DRIVE_ROOT_UPDATE"), QMessageBox.AcceptRole
        )
        recreate = msg.addButton(
            Translator.get("DRIVE_ROOT_RECREATE"), QMessageBox.AcceptRole
        )
        disconnect = msg.addButton(
            Translator.get("DRIVE_ROOT_DISCONNECT"), QMessageBox.RejectRole
        )
        msg.exec_()
        res = msg.clickedButton()

        if res == disconnect:
            self.manager.unbind_engine(engine.uid)
        elif res == recreate:
            engine.reinit()
            engine.start()
        elif res == move:
            engine.set_local_folder(new_path)
            engine.start()
示例#15
0
    def _confirmReplaceCurrentSettings(self, selection_name):
        #TODO: Refactor to use a Uranium MessageBox API instead of introducing a dependency on PyQt5
        message_box = QMessageBox()
        message_box.setIcon(QMessageBox.Question)
        message_box.setWindowTitle(catalog.i18nc("@title:window", "Replace profile"))
        message_box.setText(catalog.i18nc("@label", "Selecting \"{0}\" replaces your current settings.").format(selection_name))

        update_button = None
        create_button = message_box.addButton(catalog.i18nc("@label", "Create profile"), QMessageBox.YesRole)
        discard_button = message_box.addButton(catalog.i18nc("@label", "Discard changes"), QMessageBox.NoRole)
        cancel_button = message_box.addButton(QMessageBox.Cancel)
        if self._active_profile.isReadOnly():
            message_box.setInformativeText(catalog.i18nc("@label", "Do you want to save your settings in a custom profile?"))
        else:
            message_box.setInformativeText(catalog.i18nc("@label", "Do you want to update profile \"{0}\" or save your settings in a new custom profile?".format(self._active_profile.getName())))
            update_button = message_box.addButton(catalog.i18nc("@label", "Update \"{0}\"".format(self._active_profile.getName())), QMessageBox.YesRole)
        message_box.exec_()
        result = message_box.clickedButton()

        if result == cancel_button:
            return False
        elif result == create_button:
            profile = self.addProfileFromWorkingProfile()
            message = UM.Message.Message(catalog.i18nc("@info:status", "Added a new profile named \"{0}\"").format(profile.getName()))
            message.show()
        elif result == update_button:
            #Replace changed settings of the profile with the changed settings of the working profile
            self._active_profile.setChangedSettings(self.getWorkingProfile().getChangedSettings())
        elif result == discard_button:
            pass

        self.getWorkingProfile().setChangedSettings({})
        return True
示例#16
0
 def _no_space_left(self) -> None:
     msg = QMessageBox()
     msg.setIcon(QMessageBox.Warning)
     msg.setWindowIcon(self.icon)
     msg.setText(Translator.get("NO_SPACE_LEFT_ON_DEVICE"))
     msg.addButton(Translator.get("OK"), QMessageBox.AcceptRole)
     msg.exec_()
示例#17
0
    def _direct_edit_conflict(self, filename: str, ref: Path, digest: str) -> None:
        log.debug(f"Entering _direct_edit_conflict for {filename!r} / {ref!r}")
        try:
            if filename in self._conflicts_modals:
                log.debug(f"Filename already in _conflicts_modals: {filename!r}")
                return
            log.debug(f"Putting filename in _conflicts_modals: {filename!r}")
            self._conflicts_modals[filename] = True

            msg = QMessageBox()
            msg.setInformativeText(
                Translator.get("DIRECT_EDIT_CONFLICT_MESSAGE", [short_name(filename)])
            )
            overwrite = msg.addButton(
                Translator.get("DIRECT_EDIT_CONFLICT_OVERWRITE"), QMessageBox.AcceptRole
            )
            msg.addButton(Translator.get("CANCEL"), QMessageBox.RejectRole)
            msg.setIcon(QMessageBox.Warning)
            msg.exec_()
            if msg.clickedButton() == overwrite:
                self.manager.direct_edit.force_update(ref, digest)
            del self._conflicts_modals[filename]
        except:
            log.exception(
                f"Error while displaying Direct Edit conflict modal dialog for {filename!r}"
            )
示例#18
0
 def _show_msgbox_restart_needed(self) -> None:
     msg = QMessageBox()
     msg.setIcon(QMessageBox.Information)
     msg.setText(Translator.get("RESTART_NEEDED_MSG", values=[APP_NAME]))
     msg.setWindowTitle(APP_NAME)
     msg.addButton(Translator.get("OK"), QMessageBox.AcceptRole)
     msg.exec_()
示例#19
0
 def warningMessage(self):    
     msgBox = QMessageBox(QMessageBox.Warning, "QMessageBox.warning()",
             Dialog.MESSAGE, QMessageBox.NoButton, self)
     msgBox.addButton("Save &Again", QMessageBox.AcceptRole)
     msgBox.addButton("&Continue", QMessageBox.RejectRole)
     if msgBox.exec_() == QMessageBox.AcceptRole:
         self.warningLabel.setText("Save Again")
     else:
         self.warningLabel.setText("Continue")
示例#20
0
 def confirmRestart(self):
     messageBox = QMessageBox(QMessageBox.Question, _("Restart required"), _("<b><big>Restart the system to complete the upgrade</big></b>"), QMessageBox.NoButton, self.window_main)
     yesButton = messageBox.addButton(QMessageBox.Yes)
     noButton = messageBox.addButton(QMessageBox.No)
     yesButton.setText(_("_Restart Now").replace("_", "&"))
     noButton.setText(gettext.dgettext("kdelibs", "&Close"))
     answer = messageBox.exec_()
     if answer == QMessageBox.Yes:
         return True
     return False
 def clearReplaceTable(self):
     msgBox = QMessageBox()
     msgBox.setInformativeText("Очистить таблицу?")
     msgBox.addButton(QMessageBox.Yes)
     msgBox.addButton(QMessageBox.No)
     msgBox.setDefaultButton(QMessageBox.No)
     ret = msgBox.exec_()
     if ret == QMessageBox.Yes:
         self.ReplaceModel.removeRows(0,self.ReplaceModel.rowCount())
         self.ReplaceList.clear()
示例#22
0
def warning_dialog(self, title: str, message: str):
    """
    Shows a warning dialog with an ok -button.

    :param title: Dialog window title
    :param message: Message on dialog
    """
    warning_message = QMessageBox(
        QMessageBox.Warning, title, message, QMessageBox.NoButton, self)
    warning_message.addButton("&Ok", QMessageBox.RejectRole)
    warning_message.exec_()
示例#23
0
def info_dialog(self, title: str, message: str):
    """
    Shows a information dialog with an ok -button.

    :param title: Dialog window title
    :param message: Message on dialog
    """
    info_message = QMessageBox(
        QMessageBox.Information, title, message, QMessageBox.NoButton, self)
    info_message.addButton("&Ok", QMessageBox.RejectRole)
    info_message.exec_()
        def show_module_failed_dialog(module):
            box = QMessageBox(self.parent())
            box.setIcon(QMessageBox.Warning)
            box.setText("Module {} quit unexpectedly".format(module.name))
            box.setDetailedText(module.read_log())

            restart_button = QPushButton("Restart", box)
            restart_button.clicked.connect(module.start)
            box.addButton(restart_button, QMessageBox.AcceptRole)
            box.setStandardButtons(QMessageBox.Cancel)

            box.show()
示例#25
0
文件: viewers.py 项目: JPTIZ/lfc-t2
class ParseResultDialog(QDialog):
    def __init__(self, parent=None, text='No message'):
        super(ParseResultDialog, self).__init__(parent)

        self.msg_box = QMessageBox()
        self.msg_box.setWindowTitle('Test result')
        self.msg_box.setText(text)
        self.msg_box.addButton(QPushButton('&Ok'), QMessageBox.AcceptRole)
        self.msg_box.addButton(QPushButton('&Steps'), QMessageBox.NoRole)

    def show(self):
        return self.msg_box.exec_()
示例#26
0
文件: grade.py 项目: neoalvin/HITers
   def calcgrade(self):
       """calculate averrage grade and GPA"""
       row=0
       grade=0     #学分
       gradebu=0   #北大算法科目绩点
       gradestr=0  #严格算法科目绩点
       gradesum=0  #总学分
       scoresum=0  #总成绩
       gradebusum=0    #北大算法总绩点
       gradestrsum=0   #严格算法总绩点
       scoreaver=0     #平均成绩 
       gradebuaver=0   #北大算法gpa
       gradestraver=0  #严格算法gpa
       count=0     #总课程数
       errorstr=""
       for row in range(self.tableWidget.rowCount()):
           #获取成绩
           if self.tableWidget.item(row,6).text()!="":
               score=float(self.tableWidget.item(row,6).text())
           else:
               score=0
           #获取学分
           if self.tableWidget.item(row, 2).text()!="":
               grade=float(self.tableWidget.item(row, 2).text())
           else:
               errorstr="课程<"+self.tableWidget.item(row, 1).text()+">学分有误!"
           scoresum+=score
           gradesum+=grade
           #北大算法
           gradebu=self.turngpabu(score)
           gradebusum=gradebusum+gradebu*grade
           #严格算法
           gradestr=self.turngpastrict(score)
           gradestrsum=gradestrsum+gradestr*grade
           #课程数+1
           count+=1
       scoreaver=scoresum/count    #平均成绩
       gradebuaver=gradebusum/gradesum     #北大算法GPA结果
       gradestraver=gradestrsum/gradesum   #严格算法GPA结果
       result="平均成绩:   "+str("%4.4f"%scoreaver)+"\n\n北大算法GPA:   "+str("%4.4f"%gradebuaver)+"\n\n严格算法GPA:   "+str("%4.4f"%gradestraver)+"\n"+errorstr
       #可选计算
       """for row in range(self.tableWidget.rowCount()):
           ckb=QCheckBox()
           ckb=QCheckBox(self.tableWidget.cellWidget(row, 0))
           if ckb.isChecked()==True:
               str+=self.tableWidget.item(row,1).text()"""
       msgBox=QMessageBox(self)  
       msgBox.setWindowTitle("绩点计算")  
       msgBox.addButton(self.tr("确定"), QMessageBox.ActionRole)  
       msgBox.addButton("退出",QMessageBox.ActionRole)  
 
       msgBox.setText(self.tr(result))
       msgBox.exec_()
示例#27
0
    def dgeneric(title, text, detailed_text, icon, parent=None):
        '''Build and show a MessageBox whit detailed text'''
        messageBox = QMessageBox(parent)

        messageBox.setIcon(icon)
        messageBox.setDetailedText(detailed_text)
        messageBox.setWindowTitle(title)
        messageBox.setText(text)
        messageBox.addButton(QMessageBox.Ok)
        messageBox.setDefaultButton(QMessageBox.Ok)

        messageBox.exec_()
示例#28
0
 def tip(self):
     tip = QMessageBox(self)
     tip.setWindowTitle("关于")
     tip.setText(
         "微聊是一个基于socket实现的简易聊天室,支持一对多聊天,左侧显示为当前群聊人员\n"
         "你不仅可以发送文本信息,还可以发送emoji表情\n"
         "表情的添加方式有两种:\n"
         "1:在文本框中输入如:thumbs_up:形式的字符,如果输入的表情是支持的,那么它将自动转换为emoji表情\n"
         "2:单击文本框上方的表情按钮,不过因emoji表情库过多,此处仅展示了20个表情\n"
         "想要查看全部支持的emoji表情,可以访问http://www.unicode.org/emoji/charts/full-emoji-list.html\n"
         "最后祝你使用愉快!")
     tip.addButton(QPushButton("我知道了"), QMessageBox.YesRole)
     tip.exec_()
示例#29
0
 def game_over(self):
     self.pause()
     message = QMessageBox()
     message.setWindowIcon(QIcon('images/smorc.png'))
     message.setWindowTitle('Game Over!!!11!')
     message.setText('You Lost((9(')
     restart = message.addButton('MORE!!!!', QMessageBox.AcceptRole)
     message.addButton("That's the End", QMessageBox.RejectRole)
     message.exec()
     if message.clickedButton() == restart:
         self.restart()
     else:
         self.quit()
示例#30
0
 def usun_konto(self):
     msg = QMessageBox(self)
     msg.setIcon(QMessageBox.Warning)
     msg.setText('Czy na pewno chcesz usunąć swoje konto?')
     msg.setWindowTitle('Usuwanie konta')
     msg.addButton('Tak', QMessageBox.YesRole)
     msg.addButton('Nie', QMessageBox.NoRole)
     msg = msg.exec_()
     if not msg and id_user[0] != 1:
         query = 'DELETE FROM "uzytkownicy" WHERE "iduzytkownicy" IS ("' + str(
             id_user[0]) + '");'
         polaczenie(query)
         self.statusBar().showMessage("Usunięto użytkownika", 10000)
示例#31
0
    def message_dialog(self, title, text, buttons):
        """
        display message box and returns the clicked button
        """
        message = QMessageBox()
        message.setWindowTitle(title)
        message.setText(text)
        message.setIcon(QMessageBox.Question)
        for button in buttons:
            message.addButton(button, QMessageBox.YesRole)

        message.exec_()
        return message.clickedButton().text()
示例#32
0
 def mergePopUp(self):
     msgbox = QMessageBox(self)
     msgbox.setWindowTitle("PDF 병합 성공")
     msgbox.setIcon(QMessageBox.Information)
     msgbox.setText("PDF 병합을 성공했습니다.")
     botonyes = QPushButton("경로 열기")
     msgbox.addButton(botonyes, QMessageBox.YesRole)
     botonno = QPushButton("확인")
     msgbox.exec_()
     if msgbox.clickedButton() == botonyes:
         os.startfile(os.path.dirname(self.sName))
     elif msgbox.clickedButton() == botonno:
         msgbox.deleteLater()
示例#33
0
def show_copy_details_box(icon, title, text, details):
    """Shows a QMessageBox with a detail box and a 'Copy details' button
    """
    box = QMessageBox(icon, title, text)
    box.setDetailedText(details)
    copy_button = box.addButton('Copy details', QMessageBox.HelpRole)

    # QMessageBox connects the clicked signal of the new button to a close
    # action - disconnect this and connect to copy_to_clipboard
    copy_button.clicked.disconnect()
    copy_button.clicked.connect(partial(copy_to_clipboard, details))
    box.addButton('OK', QMessageBox.AcceptRole)
    return box.exec_()
示例#34
0
 def remove_file(self, file_name: str):
     items = self.__treeWidget.findItems(file_name, Qt.MatchExactly)
     if len(items) == 1:
         index = self.__treeWidget.indexOfTopLevelItem(items[0])
         self.__treeWidget.takeTopLevelItem(index)
     else:
         dialog = QMessageBox()
         dialog.setIcon(QMessageBox.Critical)
         dialog.setText(
             "An internal error occurred, file '{}' doesn't appear to be open"
             .format(file_name))
         dialog.addButton(QMessageBox.Ok)
         dialog.exec()
示例#35
0
 def _file_already_exists(self, oldpath: Path, newpath: Path) -> None:
     msg = QMessageBox()
     msg.setIcon(QMessageBox.Critical)
     msg.setWindowIcon(self.icon)
     msg.setText(Translator.get("FILE_ALREADY_EXISTS", values=[str(oldpath)]))
     replace = msg.addButton(Translator.get("REPLACE"), QMessageBox.AcceptRole)
     msg.addButton(Translator.get("CANCEL"), QMessageBox.RejectRole)
     msg.exec_()
     if msg.clickedButton() == replace:
         oldpath.unlink()
         normalize_event_filename(newpath)
     else:
         newpath.unlink()
 def alert(self, msg, title, buttons, icon=QMessageBox.Information):
     d = QMessageBox()
     d.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint
                      | QtCore.Qt.WindowMinMaxButtonsHint)
     d.setWindowTitle(title)
     d.setText(msg)
     for button in buttons:
         d.addButton(button)
     res = d.exec_()
     if res == QMessageBox.Yes:
         return True
     else:
         return False
示例#37
0
 def confirmRestart(self):
     messageBox = QMessageBox(
         QMessageBox.Question, _("Restart required"),
         _("<b><big>Restart the system to complete the upgrade</big></b>"),
         QMessageBox.NoButton, self.window_main)
     yesButton = messageBox.addButton(QMessageBox.Yes)
     noButton = messageBox.addButton(QMessageBox.No)
     yesButton.setText(_("_Restart Now").replace("_", "&"))
     noButton.setText(gettext.dgettext("kdelibs", "&Close"))
     answer = messageBox.exec_()
     if answer == QMessageBox.Yes:
         return True
     return False
示例#38
0
文件: dagger.py 项目: Bleyddyn/malpi
    def unsavedDataAskUser(self, text, yesButtonText, noButtonText):
        msgBox = QMessageBox(QMessageBox.Warning, "Unsaved changes", text)
        #msgBox.setTitle("Unsaved changes")
        #msgBox.setText(text)
        pButtonYes = msgBox.addButton(yesButtonText, QMessageBox.YesRole)
        msgBox.addButton(noButtonText, QMessageBox.NoRole)

        msgBox.exec()

        if msgBox.clickedButton() == pButtonYes:
            return True

        return False
示例#39
0
 def finishExport(self, filename):
     if os.path.exists(filename):
         box = QMessageBox(QMessageBox.Question, "提醒", "导出完成,是否打开文件")
         yes = box.addButton("确定", QMessageBox.YesRole)
         no = box.addButton("取消", QMessageBox.NoRole)
         # box.setIcon(1)
         box.exec_()
         if box.clickedButton() == no:
             return
         elif box.clickedButton() == yes:
             os.startfile(filename)
     else:
         QMessageBox.warning(self, "抱歉", "导出失败")
示例#40
0
 def displaySongInfo(self):
     metaDataKeyList = self.player.availableMetaData()
     fullText = '<table class="tftable" border="0">'
     for key in metaDataKeyList:
         value = self.player.metaData(key)
         fullText = fullText + '<tr><td>' + key + '</td><td>' + str(value) + '</td></tr>'
     fullText = fullText + '</table>'
     infoBox = QMessageBox(self)
     infoBox.setWindowTitle('Detailed Song Information')
     infoBox.setTextFormat(Qt.RichText)
     infoBox.setText(fullText)
     infoBox.addButton('OK', QMessageBox.AcceptRole)
     infoBox.show()
示例#41
0
    def reset(self):

        cfgmgr.reset_config()
        logging.debug("CONFIGURATION FILE REMOVED SUCCESSFULLY")
        logging.debug("RESTART")
        msgBox = QMessageBox().window()
        msgBox.about(
            self.pushButton,
            "Info",
            "Please restart guiscrcpy to reset the settings. guiscrcpy will now exit",
        )
        msgBox.addButton("OK", self.quitAct())
        msgBox.show()
示例#42
0
 def CustomMessage(title, msg, informative="", icon="Critical"):
     ''' Custom Informative Message '''
     d = QMessageBox()
     d.setWindowTitle(title)
     d.setText(msg)
     d.setInformativeText(informative)
     d.setIconPixmap(QgsUtils.GetIcon(icon))
     d.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowTitleHint)
     d.addButton(QMessageBox.Yes)
     d.addButton(QMessageBox.No)
     d.setDefaultButton(QMessageBox.No)
     ret = d.exec_()
     return ret
示例#43
0
 def retroceder(self):
     mensaje = QMessageBox(self)
     mensaje.setWindowTitle("Volver al Menú Pricipal")
     mensaje.setText(
         "Está seguro que desea volver al Menú Principal y cancelar la carga de datos?\nSi continúa perderá todos los datos ingresados"
     )
     boton_si = mensaje.addButton("Si", QMessageBox.YesRole)
     boton_no = mensaje.addButton("No", QMessageBox.NoRole)
     mensaje.setDefaultButton(boton_no)
     mensaje.exec()
     if mensaje.clickedButton() == boton_si:
         self.estado = Estados.E_RETROCEDER
         self.accept()
示例#44
0
    def delete_config(self):
        if self.configOptions.currentIndex() < 0: return

        msgBox = QMessageBox()
        msgBox.setWindowTitle("Delete configuration")
        msgBox.setText("Do you want to delete selected configuration?")
        msgBox.setStandardButtons(QMessageBox.Yes)
        msgBox.addButton(QMessageBox.No)
        msgBox.setDefaultButton(QMessageBox.No)
        if msgBox.exec_() == QMessageBox.No:
            return

        self.delete_config_without_confirm()
示例#45
0
def JN(m_email):
    msgBox = QMessageBox()
    msgBox.setWindowIcon(QIcon('./images/logos/logo.jpg'))
    msgBox.setWindowTitle("Bereken Gegevens van Externe Werken")
    msgBox.setIcon(QMessageBox.Information)
    msgBox.setText("Wilt u de financiële gegevens van deze week berekenen?")
    msgBox.setStandardButtons(QMessageBox.Yes)
    msgBox.addButton(QMessageBox.No)
    msgBox.setDefaultButton(QMessageBox.Yes)
    if (msgBox.exec_() == QMessageBox.Yes):
        bereken(m_email)
    else:
        hoofdMenu(m_email)
示例#46
0
        def ehook(exctype, value, tb):
            err = 'Unhandled exception: ' + repr(value)
            details = ''.join(traceback.format_exception(exctype, value, tb))
            print(err, '\n', details)

            q = QMessageBox(qwin)
            q.setIcon(QMessageBox.Critical)
            q.setWindowTitle("Error")
            q.setText(err)
            q.setTextFormat(Qt.PlainText)
            q.setDetailedText(str(details))
            q.addButton('OK', QMessageBox.AcceptRole)
            return q.exec()
示例#47
0
    def about_popup(self):
        msg = QMessageBox()
        msg.setWindowTitle('Documentación')
        msg.setText('Mas Información')
        msg.setIcon(QMessageBox.Question)
        msg.setStandardButtons(QMessageBox.Ok)
        msg.setDefaultButton(QMessageBox.Ok)
        msg.addButton('Tutoriales en Youtube', QMessageBox.YesRole)
        msg.addButton('Pagina Web', QMessageBox.YesRole)

        msg.buttonClicked.connect(self.redirect)

        x = msg.exec_()
示例#48
0
    def append_output(self):
        if self.process is None:  # Can happen when manually interrupting
            return
        lines = strip_ansi_codes(to_str(self.process.readAllStandardOutput()))
        self.add_output_lines(lines)
        # We manually deal with keyboard input in the output
        if 'Export already made! Do you want to erase everything? (y)es / (n)o' in lines:
            msg = QMessageBox()
            msg.setIcon(QMessageBox.Question)
            msg.setWindowTitle('Erase everything?')
            msg.setText('Export already made! Do you want to erase everything?')
            msg.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
            answer = msg.exec_()
            if answer == QMessageBox.Yes:
                answer_string = 'y'
            else:
                answer_string = 'n'
        elif 'Do you want SpyKING CIRCUS to export PCs? (a)ll / (s)ome / (n)o' in lines:
            msg = QMessageBox()
            msg.setIcon(QMessageBox.Question)
            msg.setWindowTitle('Export PCs?')
            msg.setText('Do you want SpyKING CIRCUS to export PCs?')
            no_button = msg.addButton('No', QMessageBox.NoRole)
            some_button = msg.addButton('Some', QMessageBox.YesRole)
            all_button = msg.addButton('All', QMessageBox.YesRole)
            msg.exec_()
            if msg.clickedButton() == no_button:
                answer_string = 'n'
            elif msg.clickedButton() == some_button:
                answer_string = 's'
            elif msg.clickedButton() == all_button:
                answer_string = 'a'
            else:
                answer_string = 'n'
        elif 'You should re-export the data because of a fix in 0.6' in lines:
            msg = QMessageBox()
            msg.setIcon(QMessageBox.Question)
            msg.setWindowTitle('You should re-export the data because of a fix in 0.6')
            msg.setText('Continue anyway (results may not be fully correct)?')
            msg.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
            answer = msg.exec_()
            if answer == QMessageBox.Yes:
                answer_string = 'y'
            else:
                answer_string = 'n'
        else:
            answer_string = ''

        if answer_string:
            self.process.write(answer_string + '\n')
            self.add_output_lines(answer_string + '\n')
示例#49
0
    def clearAllData(self):
        confirmDeleteMessagebox = QMessageBox()
        confirmDeleteMessagebox.setIcon(QMessageBox.Warning)
        confirmDeleteMessagebox.setText(
            "Are you sure you would like to delete all data? This action is irreversible and all current data will be lost!"
        )

        confirmDeleteMessagebox.setWindowTitle("Delete data?")
        confirmDeleteMessagebox.addButton(QMessageBox.Yes)
        confirmDeleteMessagebox.addButton(QMessageBox.No)
        confirmDeleteMessagebox.exec()
        buttonResult = confirmDeleteMessagebox.clickedButton().text(
        )  #could cause probs
        buttonResult = buttonResult.replace("&", "").lower()

        if buttonResult == "yes":  #yes button is pressed

            time.sleep(1)

            proceedMessagebox = QMessageBox()
            proceedMessagebox.setIcon(QMessageBox.Warning)
            proceedMessagebox.setText("Are you sure you would like proceed?")

            proceedMessagebox.setWindowTitle("Proceed?")
            proceedMessagebox.addButton(QMessageBox.Yes)
            proceedMessagebox.addButton(QMessageBox.No)
            proceedMessagebox.exec()
            proceedButtonResult = proceedMessagebox.clickedButton().text(
            )  #could cause probs
            proceedButtonResult = buttonResult.replace("&", "").lower()

            if proceedButtonResult == "yes":  #yes button is pressed
                print("proceeding to delete.")
                time.sleep(.3)
                print("proceeding to delete..")
                time.sleep(.3)
                print("proceeding to delete...")
                time.sleep(.3)
                print("Deleted!")

                currentDate = datetime.date.today()
                day = currentDate.day
                month = currentDate.month
                year = currentDate.year

                formattedDate = "%s-%s-%s" % (month, day, year)

                backupFileName = str("floatDataExported-Backup-" +
                                     formattedDate + ".ssg")

                self.exportFloatData(str(backupFileName))

                with open("floatData.txt", "w") as floatData:
                    floatData.write("")
                floatData.close()

                self.createInfoMessage(
                    "Data Deleted and Backup Created!",
                    "All exsiting data has been deleted. A backup of the data was saved to file '"
                    + str(backupFileName) + "' before it was deleted.")
示例#50
0
def confirmar():
    msg = QMessageBox()
    msg.setIcon(QMessageBox.Question)
    msg.setText("Atenção")
    yes = msg.addButton("sim", QMessageBox.YesRole)
    msg.addButton("Não", QMessageBox.NoRole)
    msg.setInformativeText("Você deseja efetuar o cadastro ?")
    msg.setWindowTitle("Concluir Cadastro")
    msg.show()
    msg.exec_()
    if msg.clickedButton() == yes:
        return True
    else:
        return False
示例#51
0
 def request_for_registration(self):
     if self.identificationRadioButton.isChecked(
     ) or self.verificationRadioButton.isChecked():
         msg = QMessageBox()
         msg.setIcon(QMessageBox.Information)
         msg.setText("Would you like to register?")
         msg.setWindowTitle("Request for signing up")
         yes_button = msg.addButton("Yes", QMessageBox.AcceptRole)
         no_button = msg.addButton("No", QMessageBox.RejectRole)
         msg.exec_()
         if msg.clickedButton() == yes_button:
             return True
         elif msg.clickedButton() == no_button:
             return False
示例#52
0
    def __reset_settings(self):
        """ Remove all settings """

        msg = QMessageBox(self)
        msg.setWindowTitle(self.tr("Reset Settings"))
        msg.setText(self.tr("Are you sure you want to clear all settings?"))
        msg.setIcon(QMessageBox.Question)
        msg.addButton(self.tr("No"), QMessageBox.NoRole)
        yes_btn = msg.addButton(self.tr("Yes"),
                                QMessageBox.YesRole)
        msg.exec_()
        r = msg.clickedButton()
        if r == yes_btn:
            QSettings(settings.SETTINGS_PATH, QSettings.IniFormat).clear()
示例#53
0
def _add_restart_action(action_type, bundles, extra_args, logger, message,
                        session):
    # Show user a dialog (hence error) so they know something happened.
    # Append to on_restart file so bundle action is done on restart.
    import os
    from chimerax.core.toolshed import restart_action_info
    inst_dir, restart_file = restart_action_info()
    try:
        os.makedirs(inst_dir)
    except FileExistsError:
        pass
    with open(restart_file, "a") as f:
        if action_type == "install" and session is not None:
            print(f"toolshed_url\t{session.toolshed.remote_url}", file=f)
        args = [action_type]
        bundle_args = []
        for bundle in bundles:
            if not isinstance(bundle, str):
                # Must be a BundleInfo instance
                bundle_args.append(f"{bundle.name}=={bundle.version}")
            elif bundle.endswith('.whl'):
                # Must be a file
                import shutil
                shutil.copy(bundle, inst_dir)
                bundle_args.append(os.path.split(bundle)[1])
            else:
                # leave as is
                bundle_args.append(bundle)
        args.append(' '.join(bundle_args))
        args.extend(extra_args)
        print("\t".join(args), file=f)
    if session is None or not session.ui.is_gui:
        logger.error(message)
    else:
        from PyQt5.QtWidgets import QMessageBox
        msg_box = QMessageBox(QMessageBox.Question, "Restart ChimeraX?",
                              message)
        msg_box.setInformativeText("Do you want to restart now?")
        yes = msg_box.addButton("Restart Now", QMessageBox.AcceptRole)
        no = msg_box.addButton("Restart Later", QMessageBox.RejectRole)
        msg_box.setDefaultButton(no)
        msg_box.setEscapeButton(no)
        msg_box.exec()
        if msg_box.clickedButton() == yes:
            import sys
            import os
            try:
                os.execv(sys.executable, [sys.executable])
            except Exception as err:
                logger.error("Unable to restart ChimeraX: %s" % err)
示例#54
0
def get_key():
    """Get the Key using KeyGetter

    Notify user if key file is not found
    :return A KeyGetter if successful, None if failed
    """

    key = None
    while key is None:
        try:
            key = KeyGetter()
            return key

        except OSError:
            msg = QMessageBox(QMessageBox.Information, '请插入USB Key',
                              '未找到USB Key, 请插入USB Key后点击确定重试')
            msg.addButton(QMessageBox.Ok).setText('确定')
            msg.addButton(QMessageBox.Abort).setText('退出')

            r = msg.exec()
            if r == QMessageBox.Abort:
                return None

        except ValueError:
            msg = QMessageBox(QMessageBox.Warning, '错误',
                              '插入了错误的USB Key, 请插入正确的USB Key后点击确定重试')
            msg.addButton(QMessageBox.Ok).setText('确定')
            msg.addButton(QMessageBox.Abort).setText('退出')

            r = msg.exec()
            if r == QMessageBox.Abort:
                return None
示例#55
0
 def generate_report(self):
     msg_box = QMessageBox(self)
     msg_box.setIcon(QMessageBox.Information)
     msg_box.setText("Choose format to generate report.")
     msg_box.setWindowTitle("Message")
     pdftBtn = msg_box.addButton('Pdf', QMessageBox.YesRole)
     csvBtn = msg_box.addButton('Csv', QMessageBox.NoRole)
     msg_box.exec_()
     if msg_box.clickedButton() == pdftBtn:
         print("pdf")
         self.choose_directory('pdf')
     elif msg_box.clickedButton() == csvBtn:
         print("csv")
         self.choose_directory('csv')
示例#56
0
 def saving(self, event=''):  # не бейте за костыль
     if len(self.text.toPlainText().split()) != 0 and not self.saved:
         otvet = QMessageBox(self)
         otvet.setWindowTitle('Editor')
         otvet.setText('Сохранить изменения?')
         yes = otvet.addButton('Да', QMessageBox.AcceptRole)
         no = otvet.addButton('Нет', QMessageBox.RejectRole)
         otvet.exec()
     else:
         return
     if otvet.clickedButton() is yes:
         self.save()
         if event != '':  # no comments
             event.accept()
示例#57
0
 def warningMessage(self):
     msgBox = QMessageBox(
         QMessageBox.Warning,
         "QMessageBox.warning()",
         Dialog.MESSAGE,
         QMessageBox.NoButton,
         self,
     )
     msgBox.addButton("Save &Again", QMessageBox.AcceptRole)
     msgBox.addButton("&Continue", QMessageBox.RejectRole)
     if msgBox.exec_() == QMessageBox.AcceptRole:
         self.warningLabel.setText("Save Again")
     else:
         self.warningLabel.setText("Continue")
示例#58
0
    def closeEvent(self, event):
        msgBox = QMessageBox()
        msgBox.setStyleSheet("QLabel{min-width: 250px;}")
        msgBox.setWindowTitle("Confirmati iesirea...")
        msgBox.setInformativeText("Sunteti sigur ca doriti sa iesiti?\n")
        msgBox.addButton(QtWidgets.QPushButton('Nu'), QMessageBox.NoRole)
        msgBox.addButton(QtWidgets.QPushButton('Da'), QMessageBox.YesRole)
        ret_val = msgBox.exec_()

        if ret_val == 1:
            event.accept()
            self.close_sender()
        else:
            event.ignore()
示例#59
0
    def confirm_msg(self, text):
        messageBox = QMessageBox(self)
        messageBox.setWindowTitle("Подтверждение")
        messageBox.setIcon(QMessageBox.Question)
        messageBox.setText(text)
        buttonYes = messageBox.addButton("Да", QMessageBox.YesRole)
        buttonNo = messageBox.addButton("Нет", QMessageBox.NoRole)
        messageBox.setDefaultButton(buttonYes)
        messageBox.exec_()

        if messageBox.clickedButton() == buttonYes:
            return True
        elif messageBox.clickedButton() == buttonNo:
            return False