Python PyQt5.QtWidgets.QMessageBox.warning() Examples

The following are 30 code examples of PyQt5.QtWidgets.QMessageBox.warning(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module PyQt5.QtWidgets.QMessageBox , or try the search function .
Example #1
Source File: centralwidget.py    From autokey with GNU General Public License v3.0 10 votes vote down vote up
def emit(self, record):
        try:
            item = QListWidgetItem(self.format(record))
            if record.levelno > logging.INFO:
                item.setIcon(QIcon.fromTheme("dialog-warning"))
                item.setForeground(QBrush(Qt.red))

            else:
                item.setIcon(QIcon.fromTheme("dialog-information"))

            self.app.exec_in_main(self._add_item, item)

        except (KeyboardInterrupt, SystemExit):
            raise
        except:
            self.handleError(record) 
Example #2
Source File: plugin.py    From IDASkins with MIT License 6 votes vote down vote up
def postprocess_action(self):
        if self._last_event == 'SetFont':
            QMessageBox.warning(
                qApp.activeWindow(),
                "IDASkins",
                "Please note that altering the font settings when IDASkins "
                "is loaded may cause strange effects on font rendering. It is "
                "recommended to restart IDA after making font-related changes "
                "in the settings to avoid instability."
            )

        return super(UiHooks, self).postprocess_action() 
Example #3
Source File: control.py    From equant with GNU General Public License v2.0 6 votes vote down vote up
def generateReportReq(self, strategyIdList):
        """发送生成报告请求"""
        # 量化启动时的恢复策略列表中的策略没有回测数据
        # 策略停止之后的报告数据从本地获取,不发送请求
        # 策略启动时查看数据发送报告请求,从engine获取数据
        # 查看策略的投资报告(不支持查看多个)
        if len(strategyIdList) >= 1:
            id = strategyIdList[0]
            status = self.strategyManager.queryStrategyStatus(id)
            strategyData = self.strategyManager.getSingleStrategy(id)
            if status == ST_STATUS_QUIT:  # 策略已停止,从本地获取数据
                if "ResultData" not in strategyData:  # 程序启动时恢复的策略没有回测数据
                    QMessageBox.warning(None, '警告', '策略未启动,报告数据不存在')
                    return
                reportData = strategyData["ResultData"]
                self.app.reportDisplay(reportData, id)
                return
            self._request.reportRequest(id) 
Example #4
Source File: todopw_z2.py    From python101 with MIT License 6 votes vote down vote up
def loguj(self):
        """ Logowanie użytkownika """
        login, haslo, ok = LoginDialog.getLoginHaslo(self)
        if not ok:
            return

        if not login or not haslo:
            QMessageBox.warning(self, 'Błąd',
                                'Pusty login lub hasło!', QMessageBox.Ok)
            return

        self.osoba = baza.loguj(login, haslo)
        if self.osoba is None:
            QMessageBox.critical(self, 'Błąd', 'Błędne hasło!', QMessageBox.Ok)
            return

        QMessageBox.information(self,
            'Dane logowania', 'Podano: ' + login + ' ' + haslo, QMessageBox.Ok) 
Example #5
Source File: quantosLoginWidget.py    From TradeSim with Apache License 2.0 6 votes vote down vote up
def connect(self):
        userName = str(self.userName.text()).strip()
        password = str(self.password.toPlainText()).strip()
        if len(userName) <= 0 or len(password) <= 0:
            QMessageBox.warning(self, u'获取策略', u'输入用户名和密码')
        else:
            strategyList = self.gateway.getStrategyList(userName, password)
            if strategyList is not None and len(strategyList) > 0:
                self.comboStrategy.clear()
                strategyList_sl = []
                for strategy in strategyList:
                    strategyList_sl.append(str(strategy))
                strategyList_sl.sort()
                self.comboStrategy.addItems(strategyList_sl)
                self.userName.setEnabled(False)
                self.password.setEnabled(False)

            else:
                QMessageBox.warning(self, u'获取策略', u'无法获取相关策略')
                self.comboStrategy.clear()
            
            self.comboStrategy.setFocus() 
Example #6
Source File: main_win.py    From BlindWatermark with GNU General Public License v3.0 6 votes vote down vote up
def on_pushButton_10_clicked(self):
        """
        恢复
        """
        ori_img = self.my_recovery_parameter.get('ori_img',None)
        attacked_img = self.my_recovery_parameter.get('attacked_img',None)
        if not ori_img:
            QMessageBox.warning(self,"警告",'未读取原图',QMessageBox.Ok)
        elif not attacked_img:
            QMessageBox.warning(self,"警告",'未读取受到攻击的图片',QMessageBox.Ok)
        else:
            outfile_path,_ = QFileDialog.getSaveFileName(self, '恢复图片', self.my_bwm_parameter.get('work_path','./'),"PNG (*.png);;All Files (*)")
            if outfile_path:
                rate = self.doubleSpinBox_3.value()
                self.recovery_thread = recovery(ori_img,attacked_img,outfile_path,rate)
                self.recovery_thread.finished.connect(self.recovery_thread.deleteLater)
                self.recovery_thread.num_of_good.connect(self.show_recovery)
                self.recovery_thread.start() 
Example #7
Source File: todopw_z3.py    From python101 with MIT License 6 votes vote down vote up
def loguj(self):
        """ Logowanie użytkownika """
        login, haslo, ok = LoginDialog.getLoginHaslo(self)
        if not ok:
            return

        if not login or not haslo:
            QMessageBox.warning(self, 'Błąd',
                                'Pusty login lub hasło!', QMessageBox.Ok)
            return

        self.osoba = baza.loguj(login, haslo)
        if self.osoba is None:
            QMessageBox.critical(self, 'Błąd', 'Błędne hasło!', QMessageBox.Ok)
            return

        zadania = baza.czytajDane(self.osoba)
        model.aktualizuj(zadania)
        model.layoutChanged.emit()
        self.odswiezWidok() 
Example #8
Source File: DyStockTradeStrategyBuyDlg.py    From DevilYuan with MIT License 6 votes vote down vote up
def _ok(self):
        try:
            if self._codeLabel.text() != self._tick.code:
                QMessageBox.warning(self, '错误', '没有指定代码的Tick数据!')
                return
        except Exception:
            QMessageBox.warning(self, '错误', '没有指定代码的Tick数据!')
            return

        event = DyEvent(DyEventType.stockStrategyManualBuy)
        event.data['class'] = self._strategyCls
        event.data['tick'] = self._tick
        event.data['volume'] = float(self._buyVolumeLineEdit.text()) * 100

        # 不指定价格,则根据tick买入
        price = self._buyPriceLineEdit.text()
        event.data['price'] = float(price) if price else None

        self._eventEngine.put(event)

        self._unregisterEvent()

        self.accept() 
Example #9
Source File: DyStockTradeStrategySellDlg.py    From DevilYuan with MIT License 6 votes vote down vote up
def _ok(self):
        try:
            if self._codeLabel.text() != self._tick.code:
                QMessageBox.warning(self, '错误', '没有指定代码的Tick数据!')
                return
        except Exception:
            QMessageBox.warning(self, '错误', '没有指定代码的Tick数据!')
            return

        event = DyEvent(DyEventType.stockStrategyManualSell)
        event.data['class'] = self._strategyCls
        event.data['tick'] = self._tick
        event.data['volume'] = float(self._sellVolumeLineEdit.text()) * 100

        # 不指定价格,则根据tick买入
        price = self._sellPriceLineEdit.text()
        event.data['price'] = float(price) if price else None

        self._eventEngine.put(event)

        self._unregisterEvent()

        self._posWidget.close()
        self.accept() 
Example #10
Source File: todopw_z4.py    From python101 with MIT License 6 votes vote down vote up
def loguj(self):
        login, haslo, ok = LoginDialog.getLoginHaslo(self)
        if not ok:
            return

        if not login or not haslo:
            QMessageBox.warning(self, 'Błąd',
                                'Pusty login lub hasło!', QMessageBox.Ok)
            return

        self.osoba = baza.loguj(login, haslo)
        if self.osoba is None:
            QMessageBox.critical(self, 'Błąd', 'Błędne hasło!', QMessageBox.Ok)
            return

        zadania = baza.czytajDane(self.osoba)
        model.aktualizuj(zadania)
        model.layoutChanged.emit()
        self.odswiezWidok()
        self.dodajBtn.setEnabled(True) 
Example #11
Source File: todopw_z6.py    From python101 with MIT License 6 votes vote down vote up
def loguj(self):
        login, haslo, ok = LoginDialog.getLoginHaslo(self)
        if not ok:
            return

        if not login or not haslo:
            QMessageBox.warning(self, 'Błąd',
                                'Pusty login lub hasło!', QMessageBox.Ok)
            return

        self.osoba = baza.loguj(login, haslo)
        if self.osoba is None:
            QMessageBox.critical(self, 'Błąd', 'Błędne hasło!', QMessageBox.Ok)
            return

        zadania = baza.czytajDane(self.osoba)
        model.aktualizuj(zadania)
        model.layoutChanged.emit()
        self.odswiezWidok()
        self.dodajBtn.setEnabled(True)
        self.zapiszBtn.setEnabled(True) 
Example #12
Source File: common.py    From pbtk with GNU General Public License v3.0 6 votes vote down vote up
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 
Example #13
Source File: gui.py    From pbtk with GNU General Public License v3.0 6 votes vote down vote up
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.') 
Example #14
Source File: DyStockTradeStrategySellDlg.py    From DevilYuan with MIT License 6 votes vote down vote up
def _ok(self):
        try:
            if self._codeLabel.text() != self._tick.code:
                QMessageBox.warning(self, '错误', '没有指定代码的Tick数据!')
                return
        except Exception:
            QMessageBox.warning(self, '错误', '没有指定代码的Tick数据!')
            return

        event = DyEvent(DyEventType.stockStrategyManualSell)
        event.data['class'] = self._strategyCls
        event.data['tick'] = self._tick
        event.data['volume'] = float(self._sellVolumeLineEdit.text()) * 100

        # 不指定价格,则根据tick买入
        price = self._sellPriceLineEdit.text()
        event.data['price'] = float(price) if price else None

        self._eventEngine.put(event)

        self._unregisterEvent()

        self._posWidget.close()
        self.accept() 
Example #15
Source File: kalkulator05.py    From python101 with MIT License 6 votes vote down vote up
def dzialanie(self):

        nadawca = self.sender()

        try:
            liczba1 = float(self.liczba1Edt.text())
            liczba2 = float(self.liczba2Edt.text())
            wynik = ""

            if nadawca.text() == "&Dodaj":
                wynik = liczba1 + liczba2
            else:
                pass

            self.wynikEdt.setText(str(wynik))

        except ValueError:
            QMessageBox.warning(self, "Błąd", "Błędne dane", QMessageBox.Ok) 
Example #16
Source File: DyStockTradeStrategyBuyDlg.py    From DevilYuan with MIT License 6 votes vote down vote up
def _ok(self):
        try:
            if self._codeLabel.text() != self._tick.code:
                QMessageBox.warning(self, '错误', '没有指定代码的Tick数据!')
                return
        except Exception:
            QMessageBox.warning(self, '错误', '没有指定代码的Tick数据!')
            return

        event = DyEvent(DyEventType.stockStrategyManualBuy)
        event.data['class'] = self._strategyCls
        event.data['tick'] = self._tick
        event.data['volume'] = float(self._buyVolumeLineEdit.text()) * 100

        # 不指定价格,则根据tick买入
        price = self._buyPriceLineEdit.text()
        event.data['price'] = float(price) if price else None

        self._eventEngine.put(event)

        self._unregisterEvent()

        self.accept() 
Example #17
Source File: Ui_MakupGUI.py    From AIMakeup with Apache License 2.0 6 votes vote down vote up
def _open_img(self):
        '''
        打开图片
        '''
        self.path_img,_=QFileDialog.getOpenFileName(self.centralWidget,'打开图片文件','./','Image Files(*.png *.jpg *.bmp)')
        if self.path_img and os.path.exists(self.path_img):
            print(self.path_img)
            self.im_bgr,self.temp_bgr,self.faces=self.mu.read_and_mark(self.path_img)
            self.im_ori,self.previous_bgr=self.im_bgr.copy(),self.im_bgr.copy()
            self._set_statu(self.bg_edit,True)
            self._set_statu(self.bg_op,True)
            self._set_statu(self.bg_result,True)
            self._set_statu(self.sls,True)
            self._set_img()
        else:
            QMessageBox.warning(self.centralWidget,'无效路径','无效路径,请重新选择!') 
Example #18
Source File: lab8.py    From Computer-graphics with MIT License 6 votes vote down vote up
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) 
Example #19
Source File: DyTableWidget.py    From DevilYuan with MIT License 5 votes vote down vote up
def keyPressEvent(self, event):
        if event.key() == Qt.Key_F3:
            if not self._findItems:
                QMessageBox.warning(self, '警告', '没有找到要查找的内容!')
                return

            self._curFindItemPos += 1
            self._curFindItemPos = self._curFindItemPos%len(self._findItems)

            self.scrollToItem(self._findItems[self._curFindItemPos])
            self.setCurrentItem(self._findItems[self._curFindItemPos]) 
Example #20
Source File: DyStockDataJaccardIndexPlotDlg.py    From DevilYuan with MIT License 5 votes vote down vote up
def _ok(self):
        names = self._jaccardIndexWidget.getCheckedTexts()

        if not names:
           QMessageBox.warning(self, '错误', '没有选择杰卡德指数!')
           return

        self._data['data'] = names

        self.accept() 
Example #21
Source File: DyStockSelectStockInfoDlg.py    From DevilYuan with MIT License 5 votes vote down vote up
def _ok(self):
        indicators = self._stockInfoWidget.getCheckedTexts()

        if not indicators:
           QMessageBox.warning(self, '错误', '没有选择指标!')
           return

        self._data['indicators'] = indicators

        self.accept() 
Example #22
Source File: DyStockInfoDlg.py    From DevilYuan with MIT License 5 votes vote down vote up
def _ok(self):
        indicators = self._stockInfoWidget.getCheckedTexts()

        if not indicators:
           QMessageBox.warning(self, '错误', '没有选择指标!')
           return

        self._data['indicators'] = indicators

        self.accept() 
Example #23
Source File: Ui_MakupGUI.py    From AIMakeup with Apache License 2.0 5 votes vote down vote up
def __init__(self, MainWindow):
        self.window=MainWindow
        self._setupUi()
        #控件分组
        self.bg_edit=[self.bt_brightening,self.bt_whitening,self.bt_sharpen,self.bt_smooth]
        self.bg_op=[self.bt_confirm,self.bt_cancel,self.bt_reset]
        self.bg_result=[self.bt_view_compare,self.bt_save,self.bt_save_compare]
        self.sls=[self.sl_brightening,self.sl_sharpen,self.sl_whitening,self.sl_smooth]
        #用于显示图片的标签
        self.label=QtWidgets.QLabel(self.window)
        self.sa.setWidget(self.label)
        #批量设置状态
        self._set_statu(self.bg_edit,False)
        self._set_statu(self.bg_op,False)
        self._set_statu(self.bg_result,False)
        self._set_statu(self.sls,False)
        #导入dlib模型文件
        if os.path.exists("./data/shape_predictor_68_face_landmarks.dat"):
            self.path_predictor=os.path.abspath("./data/shape_predictor_68_face_landmarks.dat")
        else:
            QMessageBox.warning(self.centralWidget,'警告','默认的dlib模型文件路径不存在,请指定文件位置。\
                                \n或从http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2下载')
            self.path_predictor,_=QFileDialog.getOpenFileName(self.centralWidget,'选择dlib模型文件','./','Data Files(*.dat)')
        #实例化化妆器
        self.mu=Makeup(self.path_predictor)
        
        self.path_img=''
        self._set_connect() 
Example #24
Source File: SqlQuery.py    From PyQt with GNU General Public License v3.0 5 votes vote down vote up
def on_pushButtonQuery_clicked(self):
        """查询按钮"""
        self.applyName()
        self.applySeat()
        self.applyLicense()
        self.applyPort()
        if not self.sql:
            return QMessageBox.warning(self, '提示', '没有进行任何输入')
        # 清空数据
        self.tableWidget.clear()
        # 重新设置表头
        self.tableWidget.setHorizontalHeaderLabels(
            ['编号', '姓名', '证件号', '航班号', '航班日期', '座位号', '登机口', '序号', '出发地', '目的地'])
        # 根据选择的字段进行并列查询
        rets = self.session.query(Tourist).filter(
            and_(*(key == value for key, value in self.sql.items()))).all()
        if not rets:
            return QMessageBox.information(self, '提示', '未查询到结果')
        self.tableWidget.setRowCount(len(rets))
        # 根据查询结果添加到表格中
        for row, tourist in enumerate(rets):
            self.tableWidget.setItem(row, 0, QTableWidgetItem(str(tourist.id)))
            self.tableWidget.setItem(
                row, 1, QTableWidgetItem(str(tourist.name)))
            self.tableWidget.setItem(
                row, 2, QTableWidgetItem(str(tourist.license)))
            self.tableWidget.setItem(
                row, 3, QTableWidgetItem(str(tourist.flightnumber)))
            self.tableWidget.setItem(
                row, 4, QTableWidgetItem(str(tourist.flightdate)))
            self.tableWidget.setItem(
                row, 5, QTableWidgetItem(str(tourist.seatnumber)))
            self.tableWidget.setItem(
                row, 6, QTableWidgetItem(str(tourist.boardingport)))
            self.tableWidget.setItem(row, 7, QTableWidgetItem(str(tourist.no)))
            self.tableWidget.setItem(
                row, 8, QTableWidgetItem(str(tourist.departurestation)))
            self.tableWidget.setItem(
                row, 9, QTableWidgetItem(str(tourist.destinationstation))) 
Example #25
Source File: pmf_myjson.py    From PyQt with GNU General Public License v3.0 5 votes vote down vote up
def mfunc_initJson( setting_flie ,self=None)->"datas":
    '''
    初始化创建json。
    
    @param setting_flie json路径
    @type str
    '''
    with open( setting_flie ,'a+' , encoding='utf-8') as f:
        
        if self == None:
            self = QWidget()

        try:
            #存在 .json 才能成功;即第二次以后
            datas = mfunc_readJson(f)
        except:
            #首次创建 , 数据默认为name;
            json.dump( name , f  ,  ensure_ascii=False, indent=1)
            
            try:
                datas = mfunc_readJson(f)
            except:
                QMessageBox.warning(self, 
                        '配置文件格式错误', 
                        '请严格按照JSON格式,\
                        \n解决不了请联系程序员:QQ62578186',
                         QMessageBox.Yes|QMessageBox.No, 
                         QMessageBox.No)
                         
                Popen(["write ", setting_flie])                  
        finally:
            return datas 
Example #26
Source File: todopw_z1.py    From python101 with MIT License 5 votes vote down vote up
def loguj(self):
        login, haslo, ok = LoginDialog.getLoginHaslo(self)
        if not ok:
            return

        if not login or not haslo:
            QMessageBox.warning(self, 'Błąd',
                                'Pusty login lub hasło!', QMessageBox.Ok)
            return

        QMessageBox.information(self,
            'Dane logowania', 'Podano: ' + login + ' ' + haslo, QMessageBox.Ok) 
Example #27
Source File: kalkulator06a.py    From python101 with MIT License 5 votes vote down vote up
def dzialanie(self):

        nadawca = self.sender()

        try:
            liczba1 = float(self.liczba1Edt.text())
            liczba2 = float(self.liczba2Edt.text())
            wynik = ""

            if nadawca.text() == "&Dodaj":
                wynik = liczba1 + liczba2
            elif nadawca.text() == "&Odejmij":
                wynik = liczba1 - liczba2
            elif nadawca.text() == "&Mnóż":
                wynik = liczba1 * liczba2
            else:  # dzielenie
                try:
                    wynik = round(liczba1 / liczba2, 9)
                except ZeroDivisionError:
                    QMessageBox.critical(
                        self, "Błąd", "Nie można dzielić przez zero!")
                    return

            self.wynikEdt.setText(str(wynik))

        except ValueError:
            QMessageBox.warning(self, "Błąd", "Błędne dane", QMessageBox.Ok) 
Example #28
Source File: todopw_z0.py    From python101 with MIT License 5 votes vote down vote up
def loguj(self):
        login, ok = QInputDialog.getText(self, 'Logowanie', 'Podaj login:')
        if ok:
            haslo, ok = QInputDialog.getText(self, 'Logowanie', 'Podaj haslo:')
            if ok:
                if not login or not haslo:
                    QMessageBox.warning(
                        self, 'Błąd', 'Pusty login lub hasło!', QMessageBox.Ok)
                    return
                QMessageBox.information(
                    self, 'Dane logowania',
                    'Podano: ' + login + ' ' + haslo, QMessageBox.Ok) 
Example #29
Source File: kalkulator06.py    From python101 with MIT License 5 votes vote down vote up
def dzialanie(self):

        nadawca = self.sender()

        try:
            liczba1 = float(self.liczba1Edt.text())
            liczba2 = float(self.liczba2Edt.text())
            wynik = ""

            if nadawca.text() == "&Dodaj":
                wynik = liczba1 + liczba2
            elif nadawca.text() == "&Odejmij":
                wynik = liczba1 - liczba2
            elif nadawca.text() == "&Mnóż":
                wynik = liczba1 * liczba2
            else:  # dzielenie
                try:
                    wynik = round(liczba1 / liczba2, 9)
                except ZeroDivisionError:
                    QMessageBox.critical(
                        self, "Błąd", "Nie można dzielić przez zero!")
                    return

            self.wynikEdt.setText(str(wynik))

        except ValueError:
            QMessageBox.warning(self, "Błąd", "Błędne dane", QMessageBox.Ok) 
Example #30
Source File: main_win.py    From BlindWatermark with GNU General Public License v3.0 5 votes vote down vote up
def on_pushButton_7_clicked(self):
        """
        从文件导入密钥
        """
        work_path = self.my_bwm_parameter.get('work_path','.')
        key_path,_ = QFileDialog.getOpenFileName(self, '选择key文件', work_path,"json File (*.json);;All Files (*)")
        try:
            with open(key_path,'r') as f:
                key = json.load(f)
                self.refresh_UI(key)
        except json.decoder.JSONDecodeError:
            QMessageBox.warning(self,"警告",'key文件的文本不符合key的格式(即json格式)',QMessageBox.Ok)