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

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

项目:pbtk    作者:marin-m    | 项目源码 | 文件源码
def assert_installed(win=None, modules=[], binaries=[]):
    missing = defaultdict(list)
    for items, what, func in ((modules, 'modules', find_spec),
                              (binaries, 'binaries', which)):
        for item in items:
            if not func(item):
                missing[what].append(item)
    if missing:
        msg = []
        for subject, names in missing.items():
            if len(names) == 1:
                subject = {'modules': 'module', 'binaries': 'binary'}[subject]
            msg.append('%s "%s"' % (subject, '", "'.join(names)))
        msg = 'You are missing the %s for this.' % ' and '.join(msg)
        if win:
            from PyQt5.QtWidgets import QMessageBox
            QMessageBox.warning(win, ' ', msg)
        else:
            raise ImportError(msg)
    return not missing
项目:pbtk    作者:marin-m    | 项目源码 | 文件源码
def extraction_done(self, outputs):
        nb_written_all, wrote_endpoints = 0, False

        for folder, output in outputs.items():
            nb_written, wrote_endpoints = extractor_save(BASE_PATH, folder, output)
            nb_written_all += nb_written

        if wrote_endpoints:
            self.set_view(self.welcome)
            QMessageBox.information(self.view, ' ', '%d endpoints and their <i>.proto</i> structures have been extracted! You can now reuse the <i>.proto</i>s or fuzz the endpoints.' % nb_written_all)

        elif nb_written_all:
            self.set_view(self.welcome)
            QMessageBox.information(self.view, ' ', '%d <i>.proto</i> structures have been extracted! You can now reuse the <i>.protos</i> or define endpoints for them to fuzz.' % nb_written_all)

        else:
            self.set_view(self.choose_extractor)
            QMessageBox.warning(self.view, ' ', 'This extractor did not find Protobuf structures in the corresponding format for specified files.')
项目:a-cadmci    作者:florez87    | 项目源码 | 文件源码
def save(self):
        """
        Orders the AppController to save the current trained models.

        Parameters
        ----------
        None

        Return
        ----------
        None
        """
        if self.controller.isTrained():
            self.controller.save()
            QMessageBox.information(self.train, "Message", "Save succesful.")
        else:
            QMessageBox.warning(self.train, "Message", "Must have at least 1 trained classifier.")
项目:a-cadmci    作者:florez87    | 项目源码 | 文件源码
def trainSystem(self):
        """
        Orders the AppController to train a model based on the selected database.

        Parameters
        ----------
        None

        Return
        ----------
        None
        """
        if self.path_train:
            trained = self.controller.train(self.path_train, self.comboBoxDatabaseTrain.currentText())
            self.path_train = None
            if not trained:
                QMessageBox.critical(self.train, "Message", "File columns or labels mismatch.")
            else:
                QMessageBox.information(self.train, "Message", "Training succesful.")
        else:
            QMessageBox.warning(self.train, "Message", "Must pick a database file.")
项目:Computer-graphics    作者:Panda-Lewandowski    | 项目源码 | 文件源码
def add_bars(win):
    if len(win.edges) == 0:
        QMessageBox.warning(win, "????????!", "?? ?????? ??????????!")
        return
    win.pen.setColor(red)
    w.lines.append([[win.edges[0].x() - 15, win.edges[0].y() - 15],
                    [win.edges[1].x() - 15, win.edges[1].y() - 15]])
    add_row(w.table_bars)
    i = w.table_bars.rowCount() - 1
    item_b = QTableWidgetItem("[{0}, {1}]".format(win.edges[0].x() - 15 , win.edges[0].y() - 15))
    item_e = QTableWidgetItem("[{0}, {1}]".format(win.edges[1].x() - 15, win.edges[1].y() - 15))
    w.table_bars.setItem(i, 0, item_b)
    w.table_bars.setItem(i, 1, item_e)
    w.scene.addLine(win.edges[0].x() - 15, win.edges[0].y() - 15, win.edges[1].x() - 15, win.edges[1].y() - 15, w.pen)

    win.pen.setColor(red)
    w.lines.append([[win.edges[0].x() + 15, win.edges[0].y() + 15],
                    [win.edges[1].x() + 15, win.edges[1].y() + 15]])
    add_row(w.table_bars)
    i = w.table_bars.rowCount() - 1
    item_b = QTableWidgetItem("[{0}, {1}]".format(win.edges[0].x() + 15, win.edges[0].y() + 15))
    item_e = QTableWidgetItem("[{0}, {1}]".format(win.edges[1].x() + 15, win.edges[1].y() + 15))
    w.table_bars.setItem(i, 0, item_b)
    w.table_bars.setItem(i, 1, item_e)
    w.scene.addLine(win.edges[0].x() + 15, win.edges[0].y() + 15, win.edges[1].x() + 15, win.edges[1].y() + 15, w.pen)
项目:Computer-graphics    作者:Panda-Lewandowski    | 项目源码 | 文件源码
def clipping(win):
    if len(win.clip) <= 1:
        QMessageBox.warning(win, "??????!", "?????????? ?? ?????!")

    if len(win.pol) <= 1:
        QMessageBox.warning(win, "??????!", "????????????? ?? ?????!")

    if len(win.pol) > 1 and len(win.clip) > 1:
        norm = isConvex(win.clip)
        if not norm:
            QMessageBox.warning(win, "??????!", "?????????? ?? ????????!???????? ?? ????? ???? ?????????!")
        else:
            p = sutherland_hodgman(win.clip, win.pol, norm)
            if p:
                win.pen.setWidth(2)
                win.pen.setColor(red)
                win.scene.addPolygon(p, win.pen)
                win.pen.setWidth(1)
项目:Milis-Yukleyici    作者:sonakinci41    | 项目源码 | 文件源码
def bolumFormatla(self, hedef):
        komut = "umount -l " + hedef
        self.f.bilgi_label.setText(komut)
        if os.path.exists(hedef):
            os.system(komut)
            self.f.surec_cubugu.setValue(50)
            komut2 = "mkfs.ext4 -F " + hedef
            try:
                os.system(komut2)
                self.f.surec_cubugu.setValue(100)
            except OSError as e:
                QMessageBox.warning(self, self.e.d[self.e.s_d]["Hata"], str(e))
                qApp.closeAllWindows()
                self.f.bilgi_label.setText(hedef + self.e.d[self.e.s_d][" disk bölümü formatland?."])
        else:
            QMessageBox.warning(self, self.e.d[self.e.s_d]["Hata"], self.e.d[self.e.s_d]["Disk bulunamad?. Program kapat?lacak."])
            qApp.closeAllWindows()
项目:dxf2gcode    作者:cnc-club    | 项目源码 | 文件源码
def App_Cont_or_Calc_IntPts(self, geo=None, cont=None):
        """
        App_Cont_or_Calc_IntPts()
        Calculate and assign the start and end points
        """

        tol = g.config.point_tolerance
        points = []
        warning = 0
        for i in range(len(geo)):
            # logger.debug("geo: %s" %geo[i])
            warning = geo[i].App_Cont_or_Calc_IntPts(cont, points, i, tol, warning)

        if warning:
            QMessageBox.warning(g.window, self.tr("Short Elements"),
                                self.tr("Length of some Elements too short!"
                                "\nLength must be greater than tolerance."
                                "\nSkipped Geometries"))

        return points
项目:pysport    作者:sportorg    | 项目源码 | 文件源码
def create_file(self, update_data=True):

        # TODO: save changes in current file

        file_name = get_save_file_name(_('Create SportOrg file'), _("SportOrg file (*.sportorg)"),
                                       str(time.strftime("%Y%m%d")))
        if file_name is not '':
            try:
                GlobalAccess().clear_filters(remove_condition=False)
                File(file_name, logging.root).create()
                self.file = file_name
                self.add_recent_file(self.file)
                self.set_title(file_name)
            except Exception as e:
                logging.exception(str(e))
                QMessageBox.warning(self, _('Error'), _('Cannot create file') + ': ' + file_name)
            # remove data
            if update_data:
                races[0] = Race()
            self.refresh()
项目:uitester    作者:IfengAutomation    | 项目源码 | 文件源码
def tag_save(self):
        tag_id = self.tag_id_line_edit.text()
        tag_name = self.tag_name_line_edit.text()
        tag_description = self.tag_description_text_edit.toPlainText()
        if tag_name == '' or tag_description == '':
            QMessageBox.warning(self, 'tag editor', 'tag name and description can\'t be empty')
        else:
            if len(tag_name) > 8:
                QMessageBox.warning(self, 'tag editor', 'tag name is not greater than 8 characters')
            else:
                if tag_id:
                    self.tag.name = tag_name
                    self.tag.description = tag_description
                    self.db_helper.update_tag()
                    QMessageBox.information(self, 'tag editor', 'tag update success')#todo ??????
                else:
                    tag = self.db_helper.query_tag_by_name(tag_name)
                    if tag is None:
                        tag = self.db_helper.insert_tag(tag_name, tag_description)
                        self.tag_id_line_edit.setText(str(tag.id))
                        self.tag = tag
                        QMessageBox.information(self, 'tag editor', 'tag insert success')#todo ??????
                    else:
                        QMessageBox.warning(self, 'tag editor', 'tag has existed')
项目:ovirt-desktop-client    作者:nkovacne    | 项目源码 | 文件源码
def acquire_vm_from_vmpool(self, rowid):
        """
            Description: A machine will be acquired by a user if they click on the icon of a VmPool
            Arguments: The row id that has been clicked. This relationship is stored using the VmData class.
            Returns: Nothing
        """

        self.lastclick = int(time())         # Last click timestamp update

        vmtype = self.vmdata[rowid].vmtype

        if vmtype == 'vmpool':
            try:
                QMessageBox.information(None, _('apptitle') + ': ' + _('info'), _('acquiring_vm_from_pool'))
                vmp = conf.OVIRTCONN.vmpools.get(id=self.vmdata[rowid].vmid)
                vmp.allocatevm()
                self.refresh_grid()
            except ConnectionError:
                QMessageBox.critical(None, _('apptitle') + ': ' + _('error'), _('unexpected_connection_drop'))
                quit()
            except RequestError:
                QMessageBox.critical(None, _('apptitle') + ': ' + _('error'), _('cannot_attach_vm_to_user'))
        else:
            QMessageBox.warning(None, _('apptitle') + ': ' + _('warning'), _('object_is_not_a_vmpool'))
项目:alignment_calculator    作者:andersas    | 项目源码 | 文件源码
def calculateDalpha(self):

        try:
            a_par = self.ui.alpha_par.text();
            a_perp = self.ui.alpha_perp.text();
            if (a_par == ""):
                a_par = "0";
            if (a_perp == ""):
                a_perp = "0";


            self.ui.deltaAlpha.setText(str(round(float(a_par)-float(a_perp),5)));
        except ValueError:
            self.ui.deltaAlpha.setText("");

#        try:
#            result = QMessageBox.information(QWidget(),'Information','Some informative text');
#            print(result);
#            result = QMessageBox.warning(QWidget(),'Warn','WARNONNN!');
#            result = QMessageBox.warning(QWidget(),'Warn','WARNONNN!');
#            print(result);
#            self.enable_save_option();
#        finally:
#            self.enable_Go_button();
#
项目:ClassifyHub    作者:Top-Ranger    | 项目源码 | 文件源码
def check_user_and_secret():
    github_secret = github.GithubSecret()

    if not github_secret.secret_available:
        QMessageBox.warning(None, 'No authentification possible',
                            'Authentificated requests are not possible - this will limit you to only a few GitHub requests per hour. '
                            'Please ensure that the user file ({}) and the secret file ({}) exist in your setup. '
                            'The file names must match exactly, including the file extension, which is not visible on all systems.'.format(
                                configserver.get('user_file'), configserver.get('secret_file')))


##
# \brief Class for communication between UI and algorithm.
#
# This class is responsible for the communication between the algorithm and the UI (written in QML).
# All classes decleared as Qt slots are callable from QML. Only one instance of the class should be used.
项目:ClassifyHub    作者:Top-Ranger    | 项目源码 | 文件源码
def get_file_content(self):
        filename = QFileDialog.getOpenFileName(None, 'Open file')[0]
        if filename is '':
            return ''
        try:
            with open(filename, 'r') as file:
                try:
                    return str(file.read())
                except Exception as e:
                    QMessageBox.warning(None, 'Can not open file', 'Can not open file {}:\n{}'.format(filename, e))
                    return ''
        except IOError:
            return ''

    ##
    # \brief Returns the remaining rate limit
    #
    # Returns -1 if an error occurred. This request do not xount against the rate limit.
    #
    # \return Rate limit or -1 if error occurred
项目:Thread-Chat-Client    作者:Nyamcat    | 项目源码 | 文件源码
def login_click(self):
        string = ''
        ID = self.inputID.text()
        passwd = self.inputPW.text()

        result = mysign.login(ID, passwd, s, key)

        if result == 1:
            QMessageBox.warning(self, '???', '??? ?? ????? ?? ????.')
        elif result == 3:
            QMessageBox.warning(self, '???', '??? ?? ????? ???? ????')
        else:
            QMessageBox.information(self, '???', result + '?, ?????.')

            user_info['username'] = result
            user_info['account'] = ID

            self.tmp = MainForm()
            self.hide()
            self.tmp.draw()

        self.inputID.setText("")
        self.inputPW.setText("")
项目:Thread-Chat-Client    作者:Nyamcat    | 项目源码 | 文件源码
def check_btn_click(self):
        ID = self.inputID.text()

        if len(ID) < 5 or len(ID) > 20:
            QMessageBox.warning(self, '?? ??', '???? 5???? 20?? ??? ?????.')
            self.inputID.setText("")
            return
        elif len(ID) > 5 or len(ID) < 20:

            string = mysign.overlap(ID, s, key)

            if string == 'success':
                QMessageBox.information(self, '?? ??', '?? ??? ??? ???')
                self.i = 1

            else:
                QMessageBox.warning(self, '?? ??', '?? ???? ??? ???.')
                self.inputID.setText("")
项目:Thread-Chat-Client    作者:Nyamcat    | 项目源码 | 文件源码
def search_click(self):
        ID = self.input_search_ID.text()


        mysocket.sendMsg(s, '3', key)
        mysocket.sendMsg(s, ID, key)
        string = mysocket.getMsg(s, key)

        self.add_btn.setVisible(False)

        self.nickname.setText(string)

        if string == 'not Find!' or string == 'not Find! ':
            QMessageBox.warning(self, '', '???? ?? ID ???.')
            self.nickname.setText('???? ?? ID ???.')

        elif friend.__contains__(ID) == False:
            self.add_btn.setVisible(True)
            #string2 = mysocket.getMsg(s, key)
            #print(string2)

        else:
            QMessageBox.warning(self, '', '?? ???? ?? ??? ???.')
            self.nickname.setText(self.input_search_ID.text()+' ?? ?? ??? ??? ???.')
项目:Thread-Chat-Client    作者:Nyamcat    | 项目源码 | 文件源码
def with_btn_click(self):
        if self.input_PW.text() == '':
            QMessageBox.warning(self, '?? ??', '????? ??? ???')
            return

        answer = QMessageBox.warning(self, '?? ??', '??? ?? ???????\n??? ??? ??? ??????.', QMessageBox.Ok|QMessageBox.No)
        if (answer == QMessageBox.No):
            return
        else:
            QMessageBox.information(self, '??? ??', '?? ????')
            """
            mysocket.sendMsg(s, '2', key)
            mysocket.sendMsg(s, self.input_PW.text(), key)
            result = mysocket.getMsg(s, key)
            if result == 'PW different' or result == 'PW different ':
                QMessageBox.warning(self, '?? ??', '?? ?? ??')
                return
            else:
                QMessageBox.information(self, '?? ??', '???? ??????. ??~')
                ??? ???.
            """
项目:StudentsManager    作者:Zaeworks    | 项目源码 | 文件源码
def onDelete(self):
        student = self.selection
        if not student:
            return
        confirm = QMessageBox.warning(QtWidgets.QWidget(),
                                      "????", "????????",
                                      QMessageBox.Yes | QMessageBox.No)
        if confirm == QMessageBox.Yes:
            item = self.tableIndex[student]
            n = self.studentTable.topLevelItemCount()
            for i in range(0, n):
                if self.studentTable.topLevelItem(i) == item:
                    self.studentTable.takeTopLevelItem(i)
                    self.tableList.remove(student)
                    self.tableIndex.pop(student)
                    break
            public.studentManager.delete(student)
项目:pbtk    作者:marin-m    | 项目源码 | 文件源码
def prompt_rename(self):
        text, good = QInputDialog.getText(self.app.view, ' ', 'Rename this field:', text=self.text(0).strip('+ '))
        if text:
            if not match('^[a-zA-Z0-9_]+$', text):
                QMessageBox.warning(self.app.view, ' ', 'This is not a valid alphanumeric name.')
                self.prompt_rename()
            else:
                try:
                    if self.do_rename(text):
                        return
                except Exception:
                    pass
                QMessageBox.warning(self.app.view, ' ', 'Field was not found in .proto, did you edit it elsewhere?')
项目:pbtk    作者:marin-m    | 项目源码 | 文件源码
def new_endpoint(self, path):
        if not self.proto_fs.isDir(path):
            path = self.proto_fs.filePath(path)

            if not getattr(self, 'only_resp_combo', False):
                self.create_endpoint.pbRequestCombo.clear()
            self.create_endpoint.pbRespCombo.clear()

            has_msgs = False
            for name, cls in load_proto_msgs(path):
                has_msgs = True
                if not getattr(self, 'only_resp_combo', False):
                    self.create_endpoint.pbRequestCombo.addItem(name, (path, name))
                self.create_endpoint.pbRespCombo.addItem(name, (path, name))
            if not has_msgs:
                QMessageBox.warning(self.view, ' ', 'There is no message defined in this .proto.')
                return

            self.create_endpoint.reqDataSubform.hide()

            if not getattr(self, 'only_resp_combo', False):
                self.create_endpoint.endpointUrl.clear()
                self.create_endpoint.transports.clear()
                self.create_endpoint.sampleData.clear()
                self.create_endpoint.pbParamKey.clear()
                self.create_endpoint.parsePbCheckbox.setChecked(False)

                for name, meta in transports.items():
                    item = QListWidgetItem(meta['desc'], self.create_endpoint.transports)
                    item.setData(Qt.UserRole, (name, meta.get('ui_data_form')))

            elif getattr(self, 'saved_transport_choice'):
                self.create_endpoint.transports.setCurrentItem(self.saved_transport_choice)
                self.pick_transport(self.saved_transport_choice)
                self.saved_transport_choice = None

            self.only_resp_combo = False
            self.set_view(self.create_endpoint)
项目:a-cadmci    作者:florez87    | 项目源码 | 文件源码
def validateSystem(self):
        """
        Orders the AppController to validate a model based on the selected database.

        Parameters
        ----------
        None

        Return
        ----------
        None
        """
        if self.path_validate:
            checked, validated, accuracy, precision, sensitivity, specificity, kappa = self.controller.validate(self.path_validate, self.spinBoxFolds.value(), self.comboBoxDatabaseValidate.currentText())
            self.path_validate = None
            if not validated:
                QMessageBox.warning(self.validate, "Message", "Classifier for "+ self.comboBoxDatabaseValidate.currentText() + " database is not trained.")
                self.clearValidateLineEdits()
            else:
                self.lineEditAccuracy.setText(str(accuracy))
                self.lineEditPrecision.setText(str(precision))
                self.lineEditSensitivity.setText(str(sensitivity))
                self.lineEditSpecificity.setText(str(specificity))
                self.lineEditKappa.setText(str(kappa))
                QMessageBox.information(self.train, "Message", "Validation finished.")
            if not checked:
                QMessageBox.critical(self.validate, "Message", "File columns or labels mismatch.")
                self.clearValidateLineEdits()
        else:
            QMessageBox.warning(self.validate, "Message", "Must pick a database file.")
            self.clearValidateLineEdits()
项目:a-cadmci    作者:florez87    | 项目源码 | 文件源码
def predictDiagnosis(self):
        """
        Orders the AppController to predict the class and probabilities of the selected features.

        Parameters
        ----------
        None

        Return
        ----------
        None
        """        
        predicted, diagnosis, prediction, classes = self.controller.predict(self.comboBoxCDR.currentText(), 
                                self.spinBoxMMSE.value(), 
                                self.spinBoxMoCA.value(), 
                                self.spinBoxGDS.value(),
                                self.spinBoxAge.value(),
                                self.spinBoxEducation.value(),
                                self.comboBoxDatabase.currentText())
        if not predicted:
            QMessageBox.warning(self.train, "Message", "Classifier for "+ self.comboBoxDatabase.currentText() + " database is not trained.")
            self.clearResultLineEdits()
        else:
            self.lineEditResult.setText(str(diagnosis[0]))
            self.lineEditSane.setText(str(prediction[0][list(classes).index('Sane')]) + '%')
            self.lineEditMild.setText(str(prediction[0][list(classes).index('Mild')]) + '%')
            self.lineEditSerious.setText(str(prediction[0][list(classes).index('Serious')]) + '%')
项目:uPyLoader    作者:BetaRavener    | 项目源码 | 文件源码
def _save_local(self):
        path = self.localPathEdit.text()
        if not path:
            QMessageBox.warning(self, "Invalid path", "Enter correct path for local file.")
            return

        try:
            with open(path, "w") as file:
                file.write(self.codeEdit.toPlainText())
        except IOError:
            QMessageBox.critical(self, "Save operation failed", "Couldn't save the file. Check path and permissions.")
项目:uPyLoader    作者:BetaRavener    | 项目源码 | 文件源码
def _save_to_mcu(self):
        name = self.remotePathEdit.text()
        if not name:
            QMessageBox.warning(self, "Invalid name", "Enter correct name for remote file.")
            return

        content = self.codeEdit.toPlainText()
        if not content:
            QMessageBox.warning(self, "Empty file", "Can't write empty file.")
            return

        progress_dlg = FileTransferDialog(FileTransferDialog.UPLOAD)
        progress_dlg.finished.connect(self.mcu_file_saved.emit)
        progress_dlg.show()
        self._connection.write_file(name, content, progress_dlg.transfer)
项目:Computer-graphics    作者:Panda-Lewandowski    | 项目源码 | 文件源码
def clipping(win):
    norm = isConvex(win.edges)
    if not norm:
        QMessageBox.warning(win, "??????!", "?????????? ?? ????????!???????? ?? ????? ???? ?????????!")

    for b in win.lines:
        win.pen.setColor(blue)
        cyrus_beck(b, win.edges, norm, win.scene, win.pen)
    win.pen.setColor(red)
项目:Milis-Yukleyici    作者:sonakinci41    | 项目源码 | 文件源码
def bolumBagla(self, hedef, baglam):
        komut = "mount " + hedef + " " + baglam
        try:
            os.system(komut)
            self.f.surec_cubugu.setValue(100)
        except OSError as e:
            QMessageBox.warning(self, self.e.d[self.e.s_d]["Hata"], str(e))
            qApp.closeAllWindows()
            self.f.bilgi_label.setText(hedef + " " + baglam + self.e.d[self.e.s_d][" alt?na ba?land?."])
项目:Milis-Yukleyici    作者:sonakinci41    | 项目源码 | 文件源码
def bolumCoz(self, hedef):
        komut = "umount -l " + hedef
        try:
            os.system(komut)
        except OSError as e:
            QMessageBox.warning(self, self.e.d[self.e.s_d]["Hata"], str(e))
            qApp.closeAllWindows()
        self.f.surec_cubugu.setValue(100)
        self.f.bilgi_label.setText(hedef + self.e.d[self.e.s_d][" çözüldü."])
项目:vidcutter    作者:ozmartian    | 项目源码 | 文件源码
def checkDiskSpace(self, path: str):
        # noinspection PyCallByClass
        if self.spaceWarningDelivered or not QFileInfo.exists(path):
            return
        info = QStorageInfo(path)
        available = info.bytesAvailable() / 1000 / 1000
        if available < VideoService.spaceWarningThreshold:
            warnmsg = 'There is less than {0}MB of disk space available at the target folder selected to save ' \
                      'your media. VidCutter WILL FAIL to produce your media if you run out of space during ' \
                      'operations.'
            QMessageBox.warning(self.parentWidget(), 'Disk space warning',
                                warnmsg.format(VideoService.spaceWarningThreshold))
            self.spaceWarningDelivered = True
项目:dxf2gcode    作者:cnc-club    | 项目源码 | 文件源码
def Get_Line_Pairs(self, string):
        line = 0
        line_pairs = dxflinepairsClass([])

        # Start at the first SECTION
        while not string[line].startswith("SECTION"):
            line += 1
        line -= 1

        # Continue to the end if no error occurs. Otherwise abort with error
        try:
            while line + 1 < len(string):
                line_pairs.line_pair.append(dxflinepairClass(int(string[line].strip()), string[line + 1].strip()))
                line += 2

        except ValueError:
            message = self.tr('Reading stopped at line %i.\n "%s" is not a valid code (number) - please, check/correct dxf file')\
                      % (line + 1, string[line].strip())
            logger.warning(message)
            QMessageBox.warning(g.window, self.tr("Warning reading linepairs"), message)

        line_pairs.nrs = len(line_pairs.line_pair)
        logger.debug(self.tr('Did read %i of linepairs from DXF') % line_pairs.nrs)
        return line_pairs

    # Search the sections in the DXF file to recognize Blocke.
项目:dxf2gcode    作者:cnc-club    | 项目源码 | 文件源码
def saveProject(self):
        """
        Save all variables to file
        """
        prj_filename = self.showSaveDialog(self.tr('Save project to file'), "Project files (*%s)" % c.PROJECT_EXTENSION)
        save_prj_filename = file_str(prj_filename[0])

        # If Cancel was pressed
        if not save_prj_filename:
            return

        (beg, ende) = os.path.split(save_prj_filename)
        (fileBaseName, fileExtension) = os.path.splitext(ende)

        if fileExtension != c.PROJECT_EXTENSION:
            if not QtCore.QFile.exists(save_prj_filename):
                save_prj_filename += c.PROJECT_EXTENSION

        pyCode = self.d2g.export()
        try:
            # File open and write
            f = open(save_prj_filename, "w")
            f.write(str_encode(pyCode))
            f.close()
            logger.info(self.tr("Save project to FILE was successful"))
        except IOError:
            QMessageBox.warning(g.window,
                                self.tr("Warning during Save Project As"),
                                self.tr("Cannot Save the File"))
项目:pysport    作者:sportorg    | 项目源码 | 文件源码
def open_file(self, file_name=None):
        if file_name:
            try:
                File(file_name, logging.root).open()
                self.file = file_name
                self.set_title(file_name)
                self.add_recent_file(self.file)
                self.init_model()
            except Exception as e:
                logging.exception(str(e))
                self.delete_from_recent_files(file_name)
                QMessageBox.warning(self, _('Error'), _('Cannot read file, format unknown') + ': ' + file_name)
项目:pysport    作者:sportorg    | 项目源码 | 文件源码
def system_message(self, title, content, icon=None, msecs=5000):
        if icon is None:
            icon = 0
        icon_val = {
            'context': Qt.QSystemTrayIcon.Context,
            'critical': Qt.QSystemTrayIcon.Critical,
            'doubleclick': Qt.QSystemTrayIcon.DoubleClick,
            'information': Qt.QSystemTrayIcon.Information,
            'middleclick': Qt.QSystemTrayIcon.MiddleClick,
            'noicon': Qt.QSystemTrayIcon.NoIcon,
            'trigger': Qt.QSystemTrayIcon.Trigger,
            'unknown': Qt.QSystemTrayIcon.Unknown,
            'warning': Qt.QSystemTrayIcon.Warning
        }
        self.system_tray_icon.showMessage(title, content, icon_val[icon] if icon in icon_val else icon, msecs)
项目:pysport    作者:sportorg    | 项目源码 | 文件源码
def split_printout(self, result):
        try:
            split_printout(result)
        except NoResultToPrintException as e:
            logging.warning(str(e))
            mes = QMessageBox(self)
            mes.setText(_('No results to print'))
            mes.exec()
        except NoPrinterSelectedException as e:
            logging.warning(str(e))
            mes = QMessageBox(self)
            mes.setText(_('No printer selected'))
            mes.exec()
项目:pysport    作者:sportorg    | 项目源码 | 文件源码
def import_wo_wdb(self):
        file_name = get_open_file_name(_('Open WDB Winorient file'), _("WDB Winorient (*.wdb)"))
        if file_name is not '':
            try:
                winorient.import_wo_wdb(file_name)
            except WDBImportError as e:
                logging.exception(str(e))
                QMessageBox.warning(self, _('Error'), _('Import error') + ': ' + file_name)
            self.init_model()
项目:pysport    作者:sportorg    | 项目源码 | 文件源码
def export_wo_wdb(self):
        file_name = get_save_file_name(_('Save As WDB file'), _("WDB file (*.wdb)"),
                                       '{}_sportorg_export'.format(time.strftime("%Y%m%d")))
        if file_name is not '':
            try:
                wb = WinOrientBinary()

                GlobalAccess().clear_filters(False)
                wdb_object = wb.export()
                GlobalAccess().apply_filters()

                write_wdb(wdb_object, file_name)
            except Exception as e:
                logging.exception(str(e))
                QMessageBox.warning(self, _('Error'), _('Export error') + ': ' + file_name)
项目:pysport    作者:sportorg    | 项目源码 | 文件源码
def export_iof_result_list(self):
        file_name = get_save_file_name(_('Save As IOF xml'), _("IOF xml (*.xml)"),
                                       '{}_resultList'.format(time.strftime("%Y%m%d")))
        if file_name is not '':
            try:
                iof_xml.export_result_list(file_name)
            except Exception as e:
                logging.exception(str(e))
                QMessageBox.warning(self, _('Error'), _('Export error') + ': ' + file_name)
项目:Mac-Python-3.X    作者:L1nwatch    | 项目源码 | 文件源码
def parseText(argument, name):
    if len(name) == len(argument):
        QMessageBox.warning(None, "Arguments",
                "No argument number found for %s. Remember to put name and "
                "value adjacent! (e.g. -fps100)")
        sys.exit(0)

    return argument[len(name):]
项目:ovirt-desktop-client    作者:nkovacne    | 项目源码 | 文件源码
def change_status(self, rowid):
        """
            Description: If the user clicks on the column which determines VM's status, we'll allow them
                         to change VM's status. This method shows a confirmation dialog and if accepted,
                         it will be notified to oVirt.
            Arguments: The row id that has been clicked. This relationship is stored using the VmData class.
            Returns: Nothing
        """

        global conf

        self.lastclick = int(time())         # Last click timestamp update

        curvmstatus = self.vmdata[rowid].vmstatus
        if curvmstatus != 'up' and curvmstatus != 'down':
            QMessageBox.warning(None, _('apptitle') + ': ' + _('warning'), _('vm_in_unchangeable_status'))
            return

        reply = QMessageBox.question(None, _('apptitle') + ': ' + _('confirm'), '%s <b>%s</b>. %s: <b>%s</b>.' % (_('current_vm_status'), self.current_vm_status(curvmstatus), _('confirm_vm_status_change'), self.toggle_vm_action(curvmstatus)), QMessageBox.Yes | QMessageBox.No, QMessageBox.No)

        if reply == QMessageBox.Yes:
            try:
                vm = conf.OVIRTCONN.vms.get(id=self.vmdata[rowid].vmid)
            except ConnectionError:
                QMessageBox.critical(None, _('apptitle') + ': ' + _('error'), _('unexpected_connection_drop'))
                quit()

            if curvmstatus == 'up':
                try:
                    vm.shutdown()
                    QMessageBox.information(None, _('apptitle') + ': ' + _('success'), _('shutting_down_vm'))
                except RequestError:
                    QMessageBox.warning(None, _('apptitle') + ': ' + _('warning'), _('vm_in_unchangeable_status'))
            if curvmstatus == 'down':
                try:
                    vm.start()
                    QMessageBox.information(None, _('apptitle') + ': ' + _('success'), _('powering_up_vm'))
                except RequestError:
                    QMessageBox.warning(None, _('apptitle') + ': ' + _('warning'), _('vm_in_unchangeable_status'))
项目:ovirt-desktop-client    作者:nkovacne    | 项目源码 | 文件源码
def connect(self, rowid):
        """
            Description: Whenever the user clicks on the 'connect' row, this method will make
                         sure the VM status is up and only then will call the connect2machine method.
            Arguments: The row id that has been clicked. This relationship is stored using the VmData class.
            Returns: Nothing
        """

        self.lastclick = int(time())         # Last click timestamp update

        vmid = self.vmdata[rowid].vmid
        vmname = self.vmdata[rowid].vmname
        vmstatus = self.vmdata[rowid].vmstatus

        if vmstatus != 'up':
            QMessageBox.warning(None, _('apptitle') + ': ' + _('warning'), _('cannot_connect_if_vm_not_up'))
            return

        if vmname in self.openviewer_vms:
            QMessageBox.critical(None, _('apptitle') + ': ' + _('error'), _('cannot_open_more_viewer_sessions'))
            return

        self.openviewer_vms.append(vmname)
        self.refresh_grid()                  # Enforce a dashboard reload to make the icon refresh

        self.connect2machine(vmid, vmname)
项目:ovirt-desktop-client    作者:nkovacne    | 项目源码 | 文件源码
def autologoutwarn_accepted(self):
        """
            Description: Callback issued when the user accepts the message box warning
                         about an imminent autologout event.
            Arguments: None
            Returns: Nothing
        """
        self.lastclick = int(time())
        self.autologoutWarn = False   # This will make the warning be shown next times as well
项目:examples    作者:pyqt    | 项目源码 | 文件源码
def parseText(argument, name):
    if len(name) == len(argument):
        QMessageBox.warning(None, "Arguments",
                "No argument number found for %s. Remember to put name and "
                "value adjacent! (e.g. -fps100)")
        sys.exit(0)

    return argument[len(name):]
项目:Serial    作者:baronleonardo    | 项目源码 | 文件源码
def onError(self, error):
        if error == QSerialPort.ResourceError:
            self.resourcesUnavailable.emit()

        elif error == QSerialPort.PermissionError:
            QMessageBox.warning(self.parent, \
             "Warning", "Can not open %s\nIt may be already opened" % self.portName())
项目:Serial    作者:baronleonardo    | 项目源码 | 文件源码
def showPopup(self):
        self.clear()
        self.updateList()

        if self.lst == []:
            QMessageBox.warning(self.parent, "Warning", "No device attached", QMessageBox.Ok, QMessageBox.NoButton)

        super(ComboBox_Ports, self).showPopup()
项目:alignment_calculator    作者:andersas    | 项目源码 | 文件源码
def noMoleculesWarning(self):
        QMessageBox.warning(self,'Failed to load predefined molecules',self.noMoleculesWarningMsg);
项目:DownloaderForReddit    作者:MalloyDelacroix    | 项目源码 | 文件源码
def no_user_list(self):
        reply = message.warning(self, 'Warning', no_user_list_message, message.Ok)
        return reply == message.Ok
项目:DownloaderForReddit    作者:MalloyDelacroix    | 项目源码 | 文件源码
def no_subreddit_list(self):
        reply = message.warning(self, 'No Subreddit List', no_subreddit_list_message, message.Ok)
        return reply == message.Ok
项目:DownloaderForReddit    作者:MalloyDelacroix    | 项目源码 | 文件源码
def remove_user_list(self):
        reply = message.warning(self, 'Remove User List?', remove_user_list_message, message.Ok, message.Cancel)
        return reply == message.Ok
项目:DownloaderForReddit    作者:MalloyDelacroix    | 项目源码 | 文件源码
def remove_subreddit_list(self):
        reply = message.warning(self, 'Remove Subreddit List?', remove_subreddit_list_message, message.Ok, message.Cancel)
        return reply == message.Ok
项目:DownloaderForReddit    作者:MalloyDelacroix    | 项目源码 | 文件源码
def downloader_running_warning(self):
        text = 'The user finder is still currently running.  Closing now may cause unexpected behaviour and corrupted ' \
               'files.  Are you sure you want to close?'
        reply = message.warning(self, 'User Finder Still Running', text, message.Ok, message.Cancel)
        return reply == message.Ok