Python PyQt5.QtWidgets 模块,QMessageBox() 实例源码

我们从Python开源项目中,提取了以下48个代码示例,用于说明如何使用PyQt5.QtWidgets.QMessageBox()

项目:plasma-transparent-panel    作者:psifidotos    | 项目源码 | 文件源码
def deleteThemeBtnClicked(self, pressed):
        msg = QtWidgets.QMessageBox()
        msg.setIcon(QtWidgets.QMessageBox.Warning)

        msg.setText("Would you like to delete theme <b>"+self.themeCmb.currentText()+"</b> ?")
        msg.setWindowTitle("Delete Theme Confirmation")
        msg.setStandardButtons(QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No)

        retval = msg.exec_()

        if retval == QtWidgets.QMessageBox.Yes:
            themepath = os.path.join(os.getenv("HOME"),".local/share/plasma/desktoptheme/")
            themepath = os.path.join(themepath, str(self.themeCmb.currentText()) )
            if os.path.isdir(themepath):
                shutil.rmtree(themepath)
                self.updateThemeCmb("")
项目:pytc-gui    作者:harmslab    | 项目源码 | 文件源码
def close_program_callback(self):
        """
        Close the program out.
        """

        ret = QW.QMessageBox.Ok
        if not self._accept_exit_program:
            if len(self._fit.experiments) > 0:
                m = QW.QMessageBox()
                m.setText("Are you sure you want to exit?")
                m.setIcon(QW.QMessageBox.Warning)
                m.setStandardButtons(QW.QMessageBox.Ok  | QW.QMessageBox.Cancel)
                m.setDefaultButton(QW.QMessageBox.Cancel)
                ret = m.exec_()

        if ret == QW.QMessageBox.Ok:
            self._accept_exit_program = True
            self._main_widgets.clear()
            self._app.instance().closeAllWindows()
        else:
            self._accept_exit_program = False
项目:activity-browser    作者:LCA-ActivityBrowser    | 项目源码 | 文件源码
def setup_help_menu(self):
        bug_icon = QtGui.QIcon(icons.debug)
        help_menu = QtWidgets.QMenu('&Help', self.window)
        help_menu.addAction(
            self.window.icon,
            '&About Activity Browser',
            self.about)

        help_menu.addAction(
            '&About Qt',
            lambda: QtWidgets.QMessageBox.aboutQt(self.window)
        )
        help_menu.addAction(
            bug_icon,
            '&Report Bug on github',
            self.raise_issue_github
        )
        help_menu.addAction(
            bug_icon,
            '&Report Bug',
            self.raise_issue_from_app
        )
        return help_menu
项目:FuME    作者:fupadev    | 项目源码 | 文件源码
def get_selectedMatches(self):
        selected = []
        indexes = self.tableView.selectedIndexes()

        if indexes == []:
            QtWidgets.QMessageBox.information(self, QtWidgets.qApp.tr("Keine Spiele ausgewählt"),
                                              QtWidgets.qApp.tr("Du hast kein Spiel ausgewählt.\n\n"
                                                                "Bitte markiere eine oder mehrere Zeilen "
                                                                "in der Spielübersicht und probiere es erneut."),
                                              QtWidgets.QMessageBox.Ok)
            return None
        else:
            for index in sorted(indexes):
                match_id = self.tableView.model().record(index.row()).value('match_id')
                match_date = self.tableView.model().record(index.row()).value('match_date')
                home = self.tableView.model().record(index.row()).value('home')
                guest = self.tableView.model().record(index.row()).value('guest')
                selected.append({'match_id': match_id, 'match_date': match_date, 'home': home, 'guest': guest})

            # remove dublicates; from https://stackoverflow.com/a/9427216/6304901
            selected = [dict(t) for t in set([tuple(d.items()) for d in selected])]

            return selected
项目:sequana    作者:sequana    | 项目源码 | 文件源码
def __init__(self, msg, details="", parent=None):
        super().__init__(parent=parent)
        self.setWindowTitle("Error message")
        self.setIcon(QW.QMessageBox.Critical)

        # Force a minimum width ! Cannot use setFixedWidth. This is a trick
        # found on
        # http://www.qtcentre.org/threads/22298-QMessageBox-Controlling-the-width
        layout = self.layout()
        spacer = QW.QSpacerItem(600,0)
        layout.addItem(spacer, layout.rowCount(), 0,1,layout.columnCount())

        msg = '<b style="color:red">' + msg + "</b><br><br>"
        try: details = str(details).replace("\\n", "<br>")
        except: pass
        self.setText(msg + details)
项目:sequana    作者:sequana    | 项目源码 | 文件源码
def copy(self, source, target, force):
        if os.path.exists(target) and force is False:
            save_msg = WarningMessage(
                    "The file <i>{0}</i> already exists in the working directory".format(source))
            save_msg.setInformativeText(
                    "Do you want to overwrite it?")
            save_msg.setStandardButtons(
                    QW.QMessageBox.Yes | QW.QMessageBox.Discard |
                    QW.QMessageBox.Cancel)
            save_msg.setDefaultButton(QW.QMessageBox.Yes)
            # Yes == 16384
            # Save == 2048
            retval = save_msg.exec_()
            if retval in [16384, 2048]:
                self.warning("Overwritting %s" % target)
                super(BaseFactory, self).copy(source, target)
        else:
                super(BaseFactory, self).copy(source, target)
项目:kawaii-player    作者:kanishka-linux    | 项目源码 | 文件源码
def qmsg_message(txt):
    print(txt)
    #root = tkinter.Tk()
    #width = root.winfo_screenwidth()
    #height = root.winfo_screenheight()
    #print(width, height, '--screen--tk--')
    msg = QtWidgets.QMessageBox()
    msg.setGeometry(0, 0, 50, 20)
    #msg.setWindowFlags(QtCore.Qt.Window | QtCore.Qt.FramelessWindowHint)
    msg.setWindowModality(QtCore.Qt.NonModal)
    msg.setWindowTitle("Kawaii-Player MessageBox")

    msg.setIcon(QtWidgets.QMessageBox.Information)
    msg.setText(txt+'\n\n(Message Will Autohide in 5 seconds)')
    msg.show()

    frame_timer = QtCore.QTimer()
    frame_timer.timeout.connect(lambda x=0: frame_options(msg))
    frame_timer.setSingleShot(True)
    frame_timer.start(5000)
    msg.exec_()
项目:Enibar    作者:ENIB    | 项目源码 | 文件源码
def test_add_note_categories(self):
        self.win.add_note_category_input.setText("test1")
        self.app.sendEvent(self.win.add_note_category_input, QtGui.QKeyEvent(QtGui.QKeyEvent.KeyPress, QtCore.Qt.Key_Return, QtCore.Qt.NoModifier))

        self.assertEqual(self.win.add_note_category_input.text(), "")
        self.assertEqual(self.get_items(self.win.shown_note_categories_list), ['test1'])
        self.assertEqual(self.get_items(self.win.hidden_note_categories_list), [])

        self.win.add_note_category_input.setText("test2")
        self.win.add_note_category_button.click()

        self.assertEqual(self.win.add_note_category_input.text(), "")
        self.assertEqual(self.get_items(self.win.shown_note_categories_list), ['test1', 'test2'])
        self.assertEqual(self.get_items(self.win.hidden_note_categories_list), [])

        self.win.add_note_category_input.setText("test2")

        def verif():
            win = self.app.activeWindow()
            self.assertIsInstance(win, QtWidgets.QMessageBox)
            win.accept()
        QtCore.QTimer.singleShot(200, verif)
        self.win.add_note_category_button.click()
项目:reversi_ai    作者:andysalerno    | 项目源码 | 文件源码
def poll_msg_queue(self):
        self.board = self.socket_receiver.get_board()
        self.repaint()

        winner = self.socket_receiver.get_winner()
        if winner is not None:
            dialog = QtWidgets.QMessageBox()
            dialog.setText('{} wins.'.format(winner))
            dialog.exec_()

        player_with_no_moves = self.socket_receiver.get_no_moves()
        if player_with_no_moves is not None:
            name = color_name[player_with_no_moves]
            dialog = QtWidgets.QMessageBox()
            dialog.setText('{} had no moves, skipping turn.'.format(name))
            dialog.exec_()
项目:Sephrasto    作者:Aeolitus    | 项目源码 | 文件源码
def saveButton(self):
        self.updateAll()
        spath, _ = QtWidgets.QFileDialog.getSaveFileName(None,"Charakter speichern...","","XML-Datei (*.xml)")
        if spath == "":
            return
        if ".xml" not in spath:
            spath = spath + ".xml"
        try:
            Wolke.Char.xmlSchreiben(spath)
        except:
            infoBox = QtWidgets.QMessageBox()
            infoBox.setIcon(QtWidgets.QMessageBox.Information)
            infoBox.setText("Speichern des Charakters fehlgeschlagen!")
            infoBox.setInformativeText("Beim Speichern des Charakters ist ein Fehler aufgetreten!\n\
Fehlercode: " + str(Wolke.Fehlercode) + "\n\
Fehlermeldung: " + Wolke.ErrorCode[Wolke.Fehlercode] + "\n")
            infoBox.setWindowTitle("Charakter speichern fehlgeschlagen.")
            infoBox.setStandardButtons(QtWidgets.QMessageBox.Ok)
            infoBox.setEscapeButton(QtWidgets.QMessageBox.Close)  
            infoBox.exec_()
项目:desktop-stream-viewer    作者:AbiosGaming    | 项目源码 | 文件源码
def rewind(self):
        if not cfg[CONFIG_BUFFER_STREAM]:
            QtWidgets.QMessageBox().warning(
                self,
                "Warning",
                "Cannot Rewind. You currently have buffering turned off."
            )
            return
        if self.rewound is None:
            self.rewound = QtWidgets.QMainWindow(parent=self)
            self.rewound.setWindowTitle("Rewound Stream")
            self.rewound.resize(QtWidgets.QDesktopWidget().availableGeometry(-1).size() * 0.5)
            self.rewound.frame = RewoundVideoFrame(self.rewound, self.stream.buffer)
            # Set events:
            self.rewound.closeEvent = self.close_rewound
            self.rewound.frame._fullscreen = self.fullscreen_rewound

            self.rewound.setCentralWidget(self.rewound.frame)
            self.rewound.show()
            # Init values
            self.rewound.is_fullscreen = False

    # Following functions belong to the rewound window
项目:desktop-stream-viewer    作者:AbiosGaming    | 项目源码 | 文件源码
def generate_conf(self):
        """Generate a config from the provided settings."""
        # Quality options should be provided as a comma-separated string.
        quality_text = self.dialog.findChild(QtCore.QObject, QUALITY_SETTINGS).text()
        quality_options = [quality.strip()
                           for quality
                           in quality_text.split(CONFIG_QUALITY_DELIMITER_SPLIT)]

        # Set new cfg values
        cfg[CONFIG_QUALITY] = quality_options
        cfg[CONFIG_BUFFER_STREAM] = self.dialog.findChild(QtCore.QObject, RECORD_SETTINGS).isChecked()
        cfg[CONFIG_MUTE] = self.dialog.findChild(QtCore.QObject, MUTE_SETTINGS).isChecked()
        cfg[CONFIG_BUFFER_SIZE] = self.dialog.findChild(QtCore.QObject, BUFFER_SIZE).value()

        QtWidgets.QMessageBox.critical(
            self,
            "Caution",
            "Some of your changes may require a restart in order to take effect."
        )

        try:
            cfg.dump()
        except IOError:
            print("Could not dump config file.")
项目:desktop-stream-viewer    作者:AbiosGaming    | 项目源码 | 文件源码
def on_fail_add_stream(self, err, args):
        # Remove the loading feedback
        self.hide_loading_gif()

        if err == AddStreamError.URL_NOT_SUPPORTED:
            (title, text) = args
            QtWidgets.QMessageBox().warning(self, title, text)
        elif err == AddStreamError.DEFAULT_QUALITY_MISSING:
            (stream_options, url) = args
            quality, ok = self._get_user_quality_preference(stream_options)
            if ok:
                self.add_new_stream(url, quality)
                return
        else:
            (title, text) = args
            QtWidgets.QMessageBox().warning(self, title, text)

        self.add_new_stream()
项目:plasma-transparent-panel    作者:psifidotos    | 项目源码 | 文件源码
def askThemeCreation(self):
        msg = QtWidgets.QMessageBox()
        msg.setIcon(QtWidgets.QMessageBox.Warning)

        newtheme=self.themeCmb.currentText()+' - '+self.panel+' Transparent'
        msg.setText("Would you like to create theme <b>"+newtheme+"</b> ?")
        msg.setWindowTitle("Create Theme Confirmation")
        msg.setStandardButtons(QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No)

        retval = msg.exec_()

        if retval == QtWidgets.QMessageBox.Yes:
            command = 'python transparentpanel.py "'+self.themeCmb.currentText()+'" '+self.panel
            for shad in self.shadows:
                command = command + " " +shad
            os.system(str(command))
            self.updateThemeCmb(newtheme)
            msg2 = QtWidgets.QMessageBox()
            msg2.setIcon(QtWidgets.QMessageBox.Information)
            msg2.setText("Your new theme was created and you can activate it through Plasma System Settings")
            msg2.setWindowTitle("New Theme Created")
            msg2.setStandardButtons(QtWidgets.QMessageBox.Ok)
            retval2 = msg2.exec_()
项目:pyENL    作者:jon85p    | 项目源码 | 文件源码
def cerrarPyENL(self, event=None):
        # QtWidgets.QMessageBox.about(self, "Advertencia", "Estoy saliendo")
        if self.archivoModificado:
            msgBox = QtWidgets.QMessageBox()
            msgBox.setText("El documento se ha modificado")
            msgBox.setInformativeText("¿Desea guardar los cambios?");
            msgBox.setStandardButtons(QtWidgets.QMessageBox.Save | QtWidgets.QMessageBox.Discard | QtWidgets.QMessageBox.Cancel)
            msgBox.setDefaultButton(QtWidgets.QMessageBox.Save)
            ret = msgBox.exec_()
            if ret == QtWidgets.QMessageBox.Save:
                self.guardaArchivo()
                QtWidgets.qApp.quit()
            elif ret == QtWidgets.QMessageBox.Discard:
                QtWidgets.qApp.quit()
            elif ret == QtWidgets.QMessageBox.Cancel:
                if event:
                    event.ignore()
            else:
                QtWidgets.QMessageBox.about(self, "Error", "Esto no debería salir")
        else:
            QtWidgets.qApp.quit()
项目:pyENL    作者:jon85p    | 项目源码 | 文件源码
def abreArchivo(self):
        if self.archivoModificado:
            msgBox = QtWidgets.QMessageBox()
            msgBox.setText("El documento se ha modificado")
            msgBox.setInformativeText("¿Desea guardar los cambios?");
            msgBox.setStandardButtons(QtWidgets.QMessageBox.Save | QtWidgets.QMessageBox.Discard | QtWidgets.QMessageBox.Cancel)
            msgBox.setDefaultButton(QtWidgets.QMessageBox.Save)
            ret = msgBox.exec_()
            if ret == QtWidgets.QMessageBox.Save:
                self.guardaArchivo()
                self.abreArchivoAccion()
            elif ret == QtWidgets.QMessageBox.Discard:
                self.abreArchivoAccion()
            elif ret == QtWidgets.QMessageBox.Cancel:
                pass
            else:
                QtWidgets.QMessageBox.about(self, "Error", "Esto no debería salir")
        else:
            self.abreArchivoAccion()
项目:DownloaderForReddit    作者:MalloyDelacroix    | 项目源码 | 文件源码
def help_dialog(self):
        help_message = QtWidgets.QMessageBox()
        help_message.setWindowTitle('Imgur Client Help')
        help_message.setText('You must supply your own imgur client id and client secret in order for this app to use '
                             'the imgur api.<br><br>Due to the limits imposed by the imgur api, it is necessary for '
                             'each user to get their own credentials from imgur.com and supply them to the app for '
                             'personal use.<br>Each client is only allowed 12,200 requests per day, so to keep '
                             'each user from running out of requests, this client information is not '
                             'supplied by the app.<br><br>Please follow the link below to obtain an imgur client-id'
                             'and client-secret. You will need an imgur account<br><br>Recommended details to enter:'
                             '<br>Application name: Downloader for Reddit<br>Authorization type: Anonymous usage '
                             'without authorization<br>Authorization callback url: https://google.com (any valid url '
                             'will work here and it does not matter for anonymous usage)<br>Application '
                             'website: https://github.com/MalloyDelacroix/DownloaderForReddit<br>Email: '
                             'Your email address to email your credentials to.')
        help_message.setTextFormat(QtCore.Qt.RichText)
        help_message.setInformativeText("<a href='https://api.imgur.com/oauth2/addclient'>https://api.imgur.com/oauth2/addclient<a/>")
        help_message.exec_()
项目:lolLoadingInfo    作者:fab0l1n    | 项目源码 | 文件源码
def closeEvent(self, QCloseEvent):
        log.info("close initiated")
        msg = QtWidgets.QMessageBox.question(QtWidgets.QMessageBox(),
                                             "Exit",
                                             "You sure?",
                                             QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No)
        if msg == QtWidgets.QMessageBox.Yes:
            log.info("yes")
            log.info("closed")
            app.exit()
        else:
            log.info("notYes")
            QCloseEvent.ignore()
            if self.isHidden():
                self.showMinimized()
                self.hide()
                self.trayIcon.show()
项目:AnimeWatch    作者:kanishka-linux    | 项目源码 | 文件源码
def qmsg_message(txt):
    print(txt)
    #root = tkinter.Tk()
    #width = root.winfo_screenwidth()
    #height = root.winfo_screenheight()
    #print(width,height,'--screen--tk--')
    msg = QtWidgets.QMessageBox()
    msg.setGeometry(0,0,50,20)
    #msg.setWindowFlags(QtCore.Qt.Window | QtCore.Qt.FramelessWindowHint)
    msg.setWindowModality(QtCore.Qt.NonModal)
    msg.setWindowTitle("AnimeWatch MessageBox")

    msg.setIcon(QtWidgets.QMessageBox.Information)
    msg.setText(txt+'\n\n(Message Will Autohide in 5 seconds)')
    msg.show()

    frame_timer = QtCore.QTimer()
    frame_timer.timeout.connect(lambda x=0:frame_options(msg))
    frame_timer.setSingleShot(True)
    frame_timer.start(5000)
    msg.exec_()
项目:AnimeWatch    作者:kanishka-linux    | 项目源码 | 文件源码
def qmsg_message(txt):
    print(txt)
    #root = tkinter.Tk()
    #width = root.winfo_screenwidth()
    #height = root.winfo_screenheight()
    #print(width,height,'--screen--tk--')
    msg = QtWidgets.QMessageBox()
    msg.setGeometry(0,0,50,20)
    #msg.setWindowFlags(QtCore.Qt.Window | QtCore.Qt.FramelessWindowHint)
    msg.setWindowModality(QtCore.Qt.NonModal)
    msg.setWindowTitle("AnimeWatch MessageBox")

    msg.setIcon(QtWidgets.QMessageBox.Information)
    msg.setText(txt+'\n\n(Message Will Autohide in 5 seconds)')
    msg.show()

    frame_timer = QtCore.QTimer()
    frame_timer.timeout.connect(lambda x=0:frame_options(msg))
    frame_timer.setSingleShot(True)
    frame_timer.start(5000)
    msg.exec_()
项目:pytc-gui    作者:harmslab    | 项目源码 | 文件源码
def open_fitter_dialog(self):
        """
        Open a transient dialog for opening a saved fit object.
        """
        file_name, _ = QW.QFileDialog.getOpenFileName(self, "Save Global Fit", "", "Pickle Files (*.pkl);;")

        opened_fitter, version = pickle.load(open(file_name, "rb"))
        if self._version == version:
            self._fit = opened_fitter
            self._fit.emit_changed()
        else:
            err = "Could not load fit. Current version is {}, but file version is {}.".format(self._version,version)
            error_message = QW.QMessageBox.warning(self,err, QW.QMessageBox.Ok)
项目:pytc-gui    作者:harmslab    | 项目源码 | 文件源码
def export_results_dialog(self):
        """
        Bring up transient dialog for exporting results.
        """

        out_dir, _ = QW.QFileDialog.getSaveFileName(self, "Export Experiment Output", "", "*")

        try:

            os.mkdir(out_dir) 

            data_file = open(os.path.join(out_dir,"fit_param.csv"), "w")
            data_file.write(self._fit.fitter.fit_as_csv)
            data_file.close()

            plot_save = PdfPages(os.path.join(out_dir,"main_plot.pdf"))
            fig, ax = self._fit.fitter.plot()
            plot_save.savefig(fig)
            plot_save.close()

            plot_save = PdfPages(os.path.join(out_dir,"corner_plot.pdf"))
            fig = self._fit.fitter.corner_plot()
            plot_save.savefig(fig)
            plot_save.close()

            log_save = open(os.path.join(out_dir,"session.log"),"w")
            spew = self._main_widgets.message_box.toPlainText()
            log_save.write(spew)
            log_save.close()


        except Exception as ex:
            template = "An exception of type {0} occurred. Arguments:\n{1!r}"
            err = template.format(type(ex).__name__,ex.args)
            error_message = QW.QMessageBox.warning(self,err, QW.QMessageBox.Ok)
项目:pytc-gui    作者:harmslab    | 项目源码 | 文件源码
def new_session_callback(self):
        """
        Start a competely new session.
        """

        warning = "Are you sure you want to start a new session?"
        warning_message = QW.QMessageBox.warning(self, "warning!",warning, 
                                                 QW.QMessageBox.Yes | QW.QMessageBox.No)
        if warning_message == QW.QMessageBox.Yes:
            self._fit.clear()
            self._fit.fitter_list = {}
            self._main_widgets.delete()
            self.__init__(self._app)
项目:notepad    作者:lfsando    | 项目源码 | 文件源码
def closeEvent(self, event):
        if self.has_changed:
            save_ = QtWidgets.QMessageBox()
            save_.setIcon(QtWidgets.QMessageBox.Question)
            save_.setWindowTitle('Save and Exit')
            save_.setText('The document has been modified.')
            save_.setInformativeText('Do you want to save your changes?')
            save_.setStandardButtons(QtWidgets.QMessageBox.Save | QtWidgets.QMessageBox.Discard |
                                     QtWidgets.QMessageBox.Cancel)
            save_.setDefaultButton(QtWidgets.QMessageBox.Save)
            save_.setEscapeButton(QtWidgets.QMessageBox.Cancel)
            reply = save_.exec_()

            # reply returns an int
            # Save
            if reply == 2048:
                self.save_file()
                event.accept()
            # Discard
            elif reply == 8388608:
                event.accept()
            # Cancel
            else:
                event.ignore()
        else:
            event.accept()

    # DEFAULT VISUALS, STATUSBAR AND SYNTAX
项目:notepad    作者:lfsando    | 项目源码 | 文件源码
def save_box(self, new=False, open=False):
        """Save Message Box"""

        reply = QtWidgets.QMessageBox().question(self, 'Notepad', "Do you want to save {}".format(self.file_name),
                                                 QtWidgets.QMessageBox.Save | QtWidgets.QMessageBox.No |
                                                 QtWidgets.QMessageBox.Cancel, QtWidgets.QMessageBox.Save)
        if reply == QtWidgets.QMessageBox.Save:
            self.save_file()
            if new:
                return True

        elif reply == QtWidgets.QMessageBox.No:
            if new:
                return True

        elif reply == QtWidgets.QMessageBox.Cancel:
            if new:
                return False
            elif open:
                pass
项目:notepad    作者:lfsando    | 项目源码 | 文件源码
def error_box(why):
        """Open Error Box with exception"""

        error_message = QtWidgets.QMessageBox()
        error_message.setWindowTitle('Error !')
        error_message.setIcon(QtWidgets.QMessageBox.Critical)
        error_message.setText('An error was found.')
        error_message.setInformativeText('%s' % why)
        error_message.exec_()
项目:grid-control    作者:akej74    | 项目源码 | 文件源码
def excepthook(excType, excValue, tracebackobj):
    """Rewritten "excepthook" function, to display a message box with details about the exception.

    @param excType exception type
    @param excValue exception value
    @param tracebackobj traceback object
    """
    separator = '-' * 40
    notice = "An unhandled exception has occurred\n"

    tbinfofile = io.StringIO()
    traceback.print_tb(tracebackobj, None, tbinfofile)
    tbinfofile.seek(0)
    tbinfo = tbinfofile.read()
    errmsg = '%s: \n%s' % (str(excType), str(excValue))
    sections = [separator, errmsg, separator, tbinfo]
    msg = '\n'.join(sections)

    # Create a QMessagebox
    error_box = QtWidgets.QMessageBox()

    error_box.setText(str(notice)+str(msg))
    error_box.setWindowTitle("Grid Control - unhandled exception")
    error_box.setIcon(QtWidgets.QMessageBox.Critical)
    error_box.setStandardButtons(QtWidgets.QMessageBox.Ok)
    error_box.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse)

    # Show the window
    error_box.exec_()
    sys.exit(1)
项目:grid-control    作者:akej74    | 项目源码 | 文件源码
def show_error(message):
    """Display "message" in a "Critical error" message box with 'OK' button."""

    # Create a QMessagebox
    message_box = QtWidgets.QMessageBox()

    message_box.setText(message)
    message_box.setWindowTitle("Error")
    message_box.setWindowIcon(QtGui.QIcon(QtGui.QPixmap(":/icons/grid.png")))
    message_box.setIcon(QtWidgets.QMessageBox.Critical)
    message_box.setStandardButtons(QtWidgets.QMessageBox.Ok)
    message_box.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse)

    #Show the window
    message_box.exec_()
项目:grid-control    作者:akej74    | 项目源码 | 文件源码
def show_notification(message):
    """Display "message" in a "Information" message box with 'OK' button."""

    # Create a QMessagebox
    message_box = QtWidgets.QMessageBox()

    message_box.setText(message)
    message_box.setWindowTitle("Note")
    message_box.setWindowIcon(QtGui.QIcon(QtGui.QPixmap(":/icons/grid.png")))
    message_box.setIcon(QtWidgets.QMessageBox.Information)
    message_box.setStandardButtons(QtWidgets.QMessageBox.Ok)
    message_box.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse)

    #Show the window
    message_box.exec_()
项目:scm-workbench    作者:barry-scott    | 项目源码 | 文件源码
def __updateToRevisionProcessResults( self, tree_node, rev_list ):
        svn_project = tree_node.project
        filename = tree_node.relativePath()

        if rev_list is not None:
            for rev in rev_list:
                if rev.number > 0:
                    count = self.progress.getEventCount()
                    if count == 0:
                        self.log.info( T_('Updated %(project)s:%(filename)s to revision %(rev)d, no new updates') %
                                                {'project': svn_project.projectName()
                                                ,'filename': filename
                                                ,'rev': rev.number} )
                    else:
                        self.log.info( S_('Updated %(project)s:%(filename)s to revision %(rev)d, %(count)d new update',
                                          'Updated %(project)s:%(filename)s to revision %(rev)d, %(count)d new updates', count) %
                                                {'project': svn_project.projectName()
                                                ,'filename': filename
                                                ,'rev': rev.number
                                                ,'count': count} )
                else:
                    self.log.warning( T_('Already up to date') )

            files_in_conflict = self.progress.getInConflictCount()
            if files_in_conflict > 0:
                box = QtWidgets.QMessageBox(
                        QtWidgets.QMessageBox.Information,
                        T_('Warning'),
                        S_("%d file is in conflict",
                           "%d files are in conflict",
                            files_in_conflict) %
                                (files_in_conflict,),
                        QtWidgets.QMessageBox.Close,
                        parent=self.top_window )
                box.exec_()
项目:scm-workbench    作者:barry-scott    | 项目源码 | 文件源码
def warningMessage( name ):
    #QQQ: need a parent?
    box = QtWidgets.QMessageBox(
            QtWidgets.QMessageBox.Information,
            T_('Warning'),
            T_('Enter a value for %s') % (name,),
            QtWidgets.QMessageBox.Close,
            parent=None )
    box.exec_()
项目:scm-workbench    作者:barry-scott    | 项目源码 | 文件源码
def appActionAbout( self ):
        all_about_info = []
        all_about_info.append( '%s %d.%d.%d' %
                                (' '.join( self.app.app_name_parts )
                                ,wb_scm_version.major
                                ,wb_scm_version.minor
                                ,wb_scm_version.patch) )
        all_about_info.append( '(%s)' % (wb_scm_version.commit,) )
        all_about_info.append( '' )
        all_about_info.append( 'Python %d.%d.%d %s %d' %
                                (sys.version_info.major
                                ,sys.version_info.minor
                                ,sys.version_info.micro
                                ,sys.version_info.releaselevel
                                ,sys.version_info.serial) )
        all_about_info.append( 'PyQt %s, Qt %s' % (Qt.PYQT_VERSION_STR, QtCore.QT_VERSION_STR) )

        for scm_type in self.all_ui_components:
            all_about_info.append( '' )
            all_about_info.extend( self.all_ui_components[ scm_type ].about() )

        all_about_info.append( '' )
        all_about_info.append( T_('Copyright Barry Scott (c) %s. All rights reserved') % (wb_scm_version.copyright_years,) )

        box = QtWidgets.QMessageBox(
            QtWidgets.QMessageBox.Information,
            T_('About %s') % (' '.join( self.app.app_name_parts ),),
            '\n'.join( all_about_info ),
            QtWidgets.QMessageBox.Close,
            parent=self )
        box.exec_()
项目:scm-workbench    作者:barry-scott    | 项目源码 | 文件源码
def errorMessage( self, title, message ):
        box = QtWidgets.QMessageBox(
                    QtWidgets.QMessageBox.Critical,
                    title,
                    message,
                    QtWidgets.QMessageBox.Close,
                    parent=self )
        box.exec_()
项目:scm-workbench    作者:barry-scott    | 项目源码 | 文件源码
def projectActionDelete( self ):
        tree_node = self.selectedScmProjectTreeNode()
        if tree_node is None:
            return

        project_name = tree_node.project.projectName()

        default_button = QtWidgets.QMessageBox.No

        title = T_('Confirm Delete Project')
        message = T_('Are you sure you wish to delete project %s') % (project_name,)

        rc = QtWidgets.QMessageBox.question( self, title, message, defaultButton=default_button )
        if rc == QtWidgets.QMessageBox.Yes:
            # remove from preferences
            self.app.prefs.delProject( project_name )
            self.app.writePreferences()

            # remove from the tree model under the old name
            self.tree_model.delProject( project_name )

            # setup on a new selection
            index = self.tree_model.getFirstProjectIndex()

            if index is not None:
                index = self.tree_sortfilter.mapFromSource( index )
                self.tree_view.setCurrentIndex( index )
项目:FuME    作者:fupadev    | 项目源码 | 文件源码
def set_database(self):
        self.db = QtSql.QSqlDatabase.addDatabase('QSQLITE')
        self.db.setDatabaseName(self.dbPath)

        if not self.db.open():
            QtWidgets.QMessageBox.critical(None, QtWidgets.qApp.tr("Datenbank nicht verfügbar"),
                                           QtWidgets.qApp.tr(
                                               "Es konnte keine Verbindung zur Datenbank hergestellt werden.\n"
                                               "Dieses Programm benötigt SQLite support. Bitte lesen Sie "
                                               "die Qt SQL Treiber Dokumentation für mehr Informationen\n\n"
                                               "Klicke Abbrechen zum beenden."),
                                           QtWidgets.QMessageBox.Cancel)
            return False
        else:
            return True
项目:FuME    作者:fupadev    | 项目源码 | 文件源码
def get_cookies(self):
        cookies = self.settings.value('cookie', '')
        if cookies == '':
            QtWidgets.QMessageBox.information(self, QtWidgets.qApp.tr("Cookies"),
                                              QtWidgets.qApp.tr("Keine Cookies vorhanden.\n\n"
                                                                "Erstelle jetzt deine Cookies in den Einstellungen"),
                                              QtWidgets.QMessageBox.Ok)
            return None
        else:
            return cookies
项目:FuME    作者:fupadev    | 项目源码 | 文件源码
def showFilterDialog(self):
        if self.comboBox.currentText() == 'Alle':
            QtWidgets.QMessageBox.warning(self, QtWidgets.qApp.tr("Region wählen"),
                                          QtWidgets.qApp.tr("Bitte zuerst eine Region wählen.\n\n"
                                                            "Ok drücken um fortzufahren."),
                                          QtWidgets.QMessageBox.Ok)
        else:
            self.filterWindow = FilterDialog(self)
            self.filterWindow.show()
项目:FuME    作者:fupadev    | 项目源码 | 文件源码
def showEditDialog(self):
        selected = self.get_selectedMatches()
        if selected == None:
            return
        elif len(selected) == 1:
            self.editDialog = EditDialog(parent=self, selected=selected[0], dbPath=self.dbPath)
            self.editDialog.show()
        else:
            QtWidgets.QMessageBox.warning(self, QtWidgets.qApp.tr("Nur ein Spiel wählen"),
                                          QtWidgets.qApp.tr("Bitte nur ein Spiel auswhählen.\n\n"
                                                            "Ok drücken um fortzufahren."),
                                          QtWidgets.QMessageBox.Ok)
项目:FuME    作者:fupadev    | 项目源码 | 文件源码
def alreadyReservedMessageBox(self, text):
        msgBox = QtWidgets.QMessageBox()
        msgBox.setIcon(QtWidgets.QMessageBox.Information)
        msgBox.setBaseSize(QtCore.QSize(600, 300))
        msgBox.setText("Bereits reservierte Spiele gefunden!")
        msgBox.setInformativeText(text)
        msgBox.exec()
项目:FuME    作者:fupadev    | 项目源码 | 文件源码
def download_match(self):
        date_from = self.dateEdit_3.date()
        if self.actionZeitraum.isChecked():
            date_to = self.dateEdit_4.date()
        else:
            date_to = date_from

        options = {
            'region': self.comboBox.currentText(),
            'date-from': date_from,
            'date-to': date_to,
            'database-path': self.dbPath,
            'parent': self
        }

        if self.comboBox.currentText() == 'Alle':
            QtWidgets.QMessageBox.warning(self, QtWidgets.qApp.tr("Region wählen"),
                                          QtWidgets.qApp.tr("Bitte zuerst eine Region wählen.\n\n"
                                                            "Ok drücken um fortzufahren."),
                                          QtWidgets.QMessageBox.Ok)
            return
        else:
            self.downloadProcessor = DownloadProcessor(options)

        # Connections
        self.downloadProcessor.started.connect(lambda: self.pushButton_5.setEnabled(False))
        self.downloadProcessor.finished.connect(lambda: self.pushButton_5.setEnabled(True))
        self.downloadProcessor.finished.connect(self.sqlmodel_calendar.select)
        self.downloadProcessor.finished.connect(self.tableView.resizeColumnsToContents)
        self.downloadProcessor.loggerSignal.connect(self.logDialog.add)
        self.downloadProcessor.statusBarSignal.connect(self.statusBar.showMessage)

        self.downloadProcessor.start()
项目:FuME    作者:fupadev    | 项目源码 | 文件源码
def set_updateDialog(self, data):
        if not self.settings.value('updates/skipthisversion/%s' % data['current'], False, bool):  # dont skip
            if data['latest'] > data['current']:  # silent check
                data.update({'logo': self.header})
                self.updateDialog = UpdateDialog(parent=self, data=data)
                self.updateDialog.show()
            elif data['active']:  # mannually checked for updates
                QtWidgets.QMessageBox.information(self, QtWidgets.qApp.tr("Software-Update"),
                                                  QtWidgets.qApp.tr("Keine Updates gefunden.\n\n"
                                                                    "FuME ist auf dem neusten Stand!"),
                                                  QtWidgets.QMessageBox.Ok)
            else:
                self.logDialog.add('Auf dem neusten Stand: Version %s' % version)
项目:FuME    作者:fupadev    | 项目源码 | 文件源码
def deleteSettings(self):
        ret = QtWidgets.QMessageBox.critical(self, QtWidgets.qApp.tr("Alle Einstellungen löschen"),
                                             QtWidgets.qApp.tr("Willst du wirklich alle Einstellungen löschen? "
                                                               "Alle Einstellungen gehen verloren.\n\n"
                                                               "Drücke OK um zu bestätigen und Abbrechen um zurückzukehren."),
                                             QtWidgets.QMessageBox.Ok | QtWidgets.QMessageBox.Cancel)
        if ret == QtWidgets.QMessageBox.Ok:
            QtWidgets.QMessageBox.critical(self, QtWidgets.qApp.tr("Alle Einstellungen löschen"),
                                           QtWidgets.qApp.tr("Alle Einstellungen werden gelöscht und das Programm beendet\n\n"
                                                             "Nach dem Beenden sind alle Einstellungen entfernt."),
                                           QtWidgets.QMessageBox.Ok)

            self.parent().close()
            self.settings.clear()
项目:FuME    作者:fupadev    | 项目源码 | 文件源码
def installUpdates(self):
        if platform == "win32":
            url = self.data['url-windows']
            os = 'Windows'
        else:
            url = self.data['url-mac']
            os = 'macOS'

        text = """
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
p, li {{ white-space: pre-wrap; }}
</style></head><body style=" font-family:'.SF NS Text'; font-size:13pt; font-weight:400; font-style:normal;">

Die neuste Version für {platform} kannst du unter folgendem Link herunterladen: <br />
<a href='{url}'>{url}</a><br /><br />
Lade das Update herunter, schließe FuME, installiere die Datei und öffne FuME erneut.<br /><br />
Mit einem klick auf OK erlaubst du FuME, den obigen Link in deinem Browser zu öffnen.<br /><br />

</body></html>
        """.format(platform=os, url=url)

        msgBox = QtWidgets.QMessageBox(self)
        msgBox.setIcon(QtWidgets.QMessageBox.Information)
        msgBox.setWindowTitle("Software-Update")
        msgBox.setText("Software-Update")
        msgBox.setInformativeText(text)
        msgBox.setStandardButtons(QtWidgets.QMessageBox.Cancel | QtWidgets.QMessageBox.Ok)
        msgBox.setDefaultButton(QtWidgets.QMessageBox.Ok)
        msgBox.setBaseSize(QtCore.QSize(550, 275))
        ret = msgBox.exec()

        if ret == QtWidgets.QMessageBox.Ok:
            webbrowser.open(url)
            self.close()
项目:sequana    作者:sequana    | 项目源码 | 文件源码
def __init__(self, *args, **kwargs):
        super(About, self).__init__(*args, **kwargs)
        self.setSizeGripEnabled(True)
        self.setIcon(QW.QMessageBox.Information)
        self.setWindowTitle("Sequana")
        self.setStandardButtons(QW.QMessageBox.Ok)
项目:sequana    作者:sequana    | 项目源码 | 文件源码
def __init__(self, msg, parent=None):
        super().__init__(parent=parent)
        self.setWindowTitle("Warning message")
        self.setIcon(QW.QMessageBox.Warning)
        self.setText(msg)
项目:sequana    作者:sequana    | 项目源码 | 文件源码
def sigint_handler(*args):
    """Handler for the SIGINT signal."""
    sys.stderr.write('\r')
    if QW.QMessageBox.question(None, '', "Are you sure you want to quit?",
                            QW.QMessageBox.Yes | QW.QMessageBox.No,
                            QW.QMessageBox.No) == QW.QMessageBox.Yes:
        QW.QApplication.quit()
项目:sequana    作者:sequana    | 项目源码 | 文件源码
def menuHelp(self):
        url = 'sequana.readthedocs.io'
        pipelines_text = "<ul>\n"
        url = "http://sequana.readthedocs.io/en/master"
        for pipeline in snaketools.pipeline_names:
            pipelines_text += '    <li><a href="%(url)s/pipeline_%(name)s.html">%(name)s</a></li>\n' %\
              {"url":url,"name":pipeline}
        pipelines_text += "</ul>"

        msg = HelpDialog(pipelines=pipelines_text)
        retval = msg.exec_()
        if retval == QW.QMessageBox.Ok:
            msg.close()
项目:sequana    作者:sequana    | 项目源码 | 文件源码
def menuQuit(self):
        self._quit_msg = WarningMessage("Do you really want to quit ?")
        self._quit_msg.setStandardButtons(QW.QMessageBox.Yes | QW.QMessageBox.No)
        self._quit_msg.setDefaultButton(QW.QMessageBox.No)
        quit_answer = self._quit_msg.exec_()
        if quit_answer == QW.QMessageBox.Yes:
            self.close()