python类QMessageBox()的实例源码

main.py 文件源码 项目:plasma-transparent-panel 作者: psifidotos 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
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("")
main_window.py 文件源码 项目:pytc-gui 作者: harmslab 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
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
menu_bar.py 文件源码 项目:activity-browser 作者: LCA-ActivityBrowser 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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
app.py 文件源码 项目:FuME 作者: fupadev 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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
messages.py 文件源码 项目:sequana 作者: sequana 项目源码 文件源码 阅读 37 收藏 0 点赞 0 评论 0
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_gui.py 文件源码 项目:sequana 作者: sequana 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
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)
player_functions.py 文件源码 项目:kawaii-player 作者: kanishka-linux 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
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_()
test_gui_note_categories_management_window.py 文件源码 项目:Enibar 作者: ENIB 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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_window.py 文件源码 项目:reversi_ai 作者: andysalerno 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
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_()
CharakterEditor.py 文件源码 项目:Sephrasto 作者: Aeolitus 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
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_()
videoframes.py 文件源码 项目:desktop-stream-viewer 作者: AbiosGaming 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
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
main.py 文件源码 项目:desktop-stream-viewer 作者: AbiosGaming 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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.")
main.py 文件源码 项目:desktop-stream-viewer 作者: AbiosGaming 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
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()
main.py 文件源码 项目:plasma-transparent-panel 作者: psifidotos 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
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.py 文件源码 项目:pyENL 作者: jon85p 项目源码 文件源码 阅读 46 收藏 0 点赞 0 评论 0
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.py 文件源码 项目:pyENL 作者: jon85p 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
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()
ImgurClientDialog.py 文件源码 项目:DownloaderForReddit 作者: MalloyDelacroix 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
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_()
base.py 文件源码 项目:lolLoadingInfo 作者: fab0l1n 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
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()
player_functions.py 文件源码 项目:AnimeWatch 作者: kanishka-linux 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
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_()
player_functions.py 文件源码 项目:AnimeWatch 作者: kanishka-linux 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
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_()
main_window.py 文件源码 项目:pytc-gui 作者: harmslab 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
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)
main_window.py 文件源码 项目:pytc-gui 作者: harmslab 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
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)
main_window.py 文件源码 项目:pytc-gui 作者: harmslab 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
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.py 文件源码 项目:notepad 作者: lfsando 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
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.py 文件源码 项目:notepad 作者: lfsando 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
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.py 文件源码 项目:notepad 作者: lfsando 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
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_()
helper.py 文件源码 项目:grid-control 作者: akej74 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
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)
helper.py 文件源码 项目:grid-control 作者: akej74 项目源码 文件源码 阅读 39 收藏 0 点赞 0 评论 0
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_()
helper.py 文件源码 项目:grid-control 作者: akej74 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
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_()
wb_svn_ui_actions.py 文件源码 项目:scm-workbench 作者: barry-scott 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
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_()


问题


面经


文章

微信
公众号

扫码关注公众号