def on_btn_Recognize_Clicked(self):
     save_path = "./written_digit.jpg"
     self.__paintBoard.GetContentAsQImage().save(save_path)
     ans, pred = image.predict(model=self.model,
                               image=image.get_image(save_path))
     QMessageBox.question(self, u"识别结果", u"手写数字识别为:" + str(ans),
                          QMessageBox.Yes)
예제 #2
0
 def start_action(self):
     only_files = self.is_only_files()
     type = self.get_user_type()
     name = self.get_user_name()
     try:
         if self.current_action == 'Переименовать':
             lambda_name = self.comboBox.currentText()
             lambda_template = auto.get_lambda_rename(lambda_name)
             auto.rename_certian_things(type=type,
                                        only_files=only_files,
                                        name=name,
                                        function=lambda_template)
         elif self.current_action == 'Удалить':
             auto.delete_certain_things(type=type,
                                        name=name,
                                        only_files=only_files)
         elif self.current_action == 'Оставить':
             auto.keep_only_certain_files(type=type, name=name)
         elif self.current_action == 'Скрыть':
             auto.hide_certain_things(type=type,
                                      name=name,
                                      only_files=only_files)
         elif self.current_action == 'Показать':
             auto.unhide_certain_things(type=type,
                                        name=name,
                                        only_files=only_files)
     except Exception:
         QMessageBox.question(self, 'Ошибка', 'Программа ошиблась',
                              QMessageBox.Ok)
     finally:
         self.find_user_run()
    def SetOk(self):
        if not self.HandlingCondtion():
            return
        if self.radioButtonEncrypt.isChecked():
            if os.path.isfile(self.lineEditSelected.text(
            )) and self.lineEditSelected.text().split(".")[-1] == 'Haies':
                QMessageBox.warning(self, "خطأ", "هذا الملف مشفر من قبل")
                return
            quiz = QMessageBox.question(
                self, "تشفير",
                "هل تريد تشفير {0}".format(self.lineEditSelected.text()),
                QMessageBox.Yes | QMessageBox.No)
            if quiz == QMessageBox.No:
                return
            self.pushButtonOk.setEnabled(False)
            self.StartDecryptOrEncrypt = HaiesThread(
                self, self.lineEditSelected.text(), 1,
                self.lineEditPassword.text())
            self.StartDecryptOrEncrypt.progress_update.connect(
                self.PrograssBarUpdate)
            self.StartDecryptOrEncrypt.progress_updateForEncDec.connect(
                self.PrograssBarForEncOrDecUpdate)
            self.StartDecryptOrEncrypt.start()

        elif self.radioButtonDecrypt.isChecked():
            if os.path.isfile(self.lineEditSelected.text(
            )) and self.lineEditSelected.text().split(".")[-1] != 'Haies':
                QMessageBox.warning(self, "خطأ", "هذا الملف غير مشفر")
                return

            quiz = QMessageBox.question(
                self, "فك التشفير",
                "هل تريد فك تشفير {0}".format(self.lineEditSelected.text()),
                QMessageBox.Yes | QMessageBox.No)
            if quiz == QMessageBox.No:
                return
            self.pushButtonOk.setEnabled(False)
            self.StartDecryptOrEncrypt = HaiesThread(
                self, self.lineEditSelected.text(), 2,
                self.lineEditPassword.text())
            self.StartDecryptOrEncrypt.progress_update.connect(
                self.PrograssBarUpdate)
            self.StartDecryptOrEncrypt.progress_updateForEncDec.connect(
                self.PrograssBarForEncOrDecUpdate)
            self.StartDecryptOrEncrypt.start()
        else:
            QMessageBox.warning(self, "خطأ",
                                "يجب أن تختار من بين تشفير أو فك التشفير")
예제 #4
0
def borrar_pelicula(id):
    res = QMessageBox.question(
        MainWindow, "Info",
        "¿Desea borrar el registro de id: " + str(id) + "?")
    if res == QMessageBox.Yes:
        operaciones_bd.borrar_pelicula(id)
        mostrar_table_widget()
예제 #5
0
 def get_servo_addr_32(self, event):
     try:
         addr = self.lnt_servo_addr.text().strip()
         try:
             if addr.lower().startswith('0x'):
                 addr = int(addr, base=16)
             else:
                 addr = int(addr)
         except:
             QMessageBox.warning(self.main_ui.window, '错误',
                                 '请输入正确的地址, 地址必须是u16类型')
             return
         text = self.combobox_servo.currentText()
         if text == 'axis-all':
             QMessageBox.warning(self.main_ui.window, '警告',
                                 '请选择其中一个电机,不能选择所有电机')
             return
         else:
             servo_id = int(text.split('-')[-1])
         tmp = '你确定要获取电机{}的地址{}的值吗?'.format(servo_id, addr)
         if QMessageBox.question(self.main_ui.window, '警告',
                                 tmp) == QMessageBox.Yes:
             item = {
                 'cmd': 'get_servo_addr_32',
                 'kwargs': {
                     'servo_id': servo_id,
                     'addr': addr
                 }
             }
             self.handler.put_cmd_que(item)
     except Exception as e:
         print(e)
예제 #6
0
 def get_zerro_and_one(self):
     if type(game.map.get_elem_xy(int(round(self._x)),
                                  int(round(self._y)))) in [Zerro, One]:
         game.map.set_elem_xy(int(round(self._x)), int(round(self._y)),
                              Empty())
         game.set_score(game.get_score() + 5)
         flag = False
         for i in range(game.map.get_col()):
             for j in range(game.map.get_row()):
                 if type(game.map.get_elem_xy(i, j)) in [Zerro, One]:
                     flag = True
         if not flag:
             for elem in game.map._stairs_game_end:
                 game.map.set_elem_xy(elem[0], elem[1], Stairs())
     if type(game.map.get_elem_xy(int(round(self._x)), int(round(
             self._y)))) == Stairs and round(self._y) == 0:
         game.player.pause()
         game.hero.timer.stop()
         for enemy in game.enemies:
             enemy.timer.stop()
         game.timer_game.stop()
         buttonReply = QMessageBox.question(
             game, 'ВЫ ВЫИГРАЛИ', "Перейти на следующий уровень?",
             QMessageBox.Yes | QMessageBox.Close, QMessageBox.Yes)
         if buttonReply == QMessageBox.Yes:
             game.set_score(game.get_score())
             game.file_number += 1
             game.reload_game()
             game.timer_game.start(200)
         else:
             game.show_menu()
    def load_data_generator(self, generator_json, config_json):
        new_data_generator = DataGenerator2D.DataGenerator2D()
        new_data_generator.from_json(generator_json)
        if self.check_if_config_exist(new_data_generator.name):
            if QMessageBox.Cancel == QMessageBox.question(
                    self, "Question",
                    "Config name exist, still load and rename? ",
                    QMessageBox.Yes | QMessageBox.Cancel):
                return
            else:
                new_data_generator.name = self.update_config_name(
                    new_data_generator.name)

        if config_json is None:
            self.generator_name_to_inputs[
                new_data_generator.name] = GenerateConfig()
        elif not 'generate_image_num' in config_json:
            self.generator_name_to_inputs[
                new_data_generator.name] = GenerateConfig(
                    generate_image_num=self.ui.generate_num.value())
        else:
            self.generator_name_to_inputs[
                new_data_generator.name] = GenerateConfig(config_json)

        self.data_generators.append(
            copy.deepcopy(new_data_generator))  # add generator

        self.create_image_attachment_gallery(new_data_generator.name)

        self.bind_widgets_to_generator(
            self.find_data_generator(new_data_generator.name)
        )  # bind object list and algo list widget
        self.ui.configList.addItem(new_data_generator.name)
        self.ui.configList.setCurrentRow(self.ui.configList.count() - 1)
예제 #8
0
    def game_over(self):
        logger.info(color("bold_cyan") + f"游戏已经结束,共耗时:{datetime.now() - self.game_start_time}")
        self.notify('游戏结束')

        restart = QMessageBox.question(self, "游戏结束", "是否重新开始?") == QMessageBox.Yes
        if restart:
            self.restart(manual=False)
예제 #9
0
 def _inputFileSelected(self, filename):
     if filename:
         try:
             header = pyfits.open(filename)[0].header
         except Exception as err:
             self.qerrmsg.showMessage("Error reading FITS file %s: %s" %
                                      (filename, str(err)))
             self.wfile_in.setFilename("")
             return
         # try to get beam extents
         gx, gy, grot = [
             header.get(x, None) for x in ('BMAJ', 'BMIN', 'BPA')
         ]
         if all([x is not None for x in (gx, gy, grot)]):
             # if beam size is already set, ask before overwriting
             print([
                 str(x.text()) for x in (self.wbmaj, self.wbmin, self.wbpa)
             ])
             if any([bool(str(x.text())) for x in (self.wbmaj, self.wbmin, self.wbpa)]) and \
                     QMessageBox.question(self, "Set restoring beam",
                                          "Also reset restoring beam size from this FITS file?",
                                          QMessageBox.Yes | QMessageBox.No) != QMessageBox.Yes:
                 return
             self.wbmaj.setText("%.2f" % (gx * 3600))
             self.wbmin.setText("%.2f" % (gy * 3600))
             self.wbpa.setText("%.2f" % grot)
예제 #10
0
    def addImages(self):
        self.tweets = []

        for tweet in self.listTweets:
            # Ignore empty tweets
            if tweet != "":
                # Ask if add add image
                message = 'Add an image to the tweet: "' + tweet + '"?'

                yesNo = QMessageBox.question(self,
                                             "Do you want to add an image?",
                                             message,
                                             QMessageBox.Yes | QMessageBox.No)

                # Ask the link of the image
                if yesNo == QMessageBox.Yes:
                    url, ok = QInputDialog.getText(self, "Image URL",
                                                   "Image URL: ",
                                                   QLineEdit.Normal, "")

                    self.tweets.append({"tweet": tweet, "image": url})

                else:
                    self.tweets.append({"tweet": tweet, "image": ""})

        self.publish()
예제 #11
0
def borrar_serie(id_a_borrar):
    res = QMessageBox.question(
        MainWindow, "Alerta!!!",
        "Vas a borrar el registro con id: " + str(id_a_borrar))
    if res == QMessageBox.Yes:
        operaciones_bd.borrar_serie(id_a_borrar)
        mostrar_table_widget_series()
예제 #12
0
    def removeDataPlotWin(self):
        curreSelctPlotWgtName = self.currSelctPlotWgt.getViewBox().name
        if curreSelctPlotWgtName != 'Plot1' and curreSelctPlotWgtName in self.lPlotWindows:  # can't delete plot1
            choice = QMessageBox.question(self, curreSelctPlotWgtName, "Remove the selected plot window?",
                                                QMessageBox.Yes | QMessageBox.No)
            if choice == QMessageBox.Yes:

                for item in self.currSelctPlotWgt.items():   # delete the items of the plot
                    self.currSelctPlotWgt.removeItem(item)

                lstitems = self.listWidget.findItems(curreSelctPlotWgtName, Qt.MatchStartsWith)  # delete the list in the list widget
                if len(lstitems) > 0:
                    for iitem in lstitems:
                        self.listWidget.takeItem(self.listWidget.row(iitem))

                for item in self.currSelctPlotWgt.scene().items():  #  remove everything in the scene including the legend
                    self.currSelctPlotWgt.scene().removeItem(item)



                self.dataPlotLayout.removeWidget(self.currSelctPlotWgt)
                self.currSelctPlotWgt.deleteLater()    #setHidden(True)     # hide the selected widget, should be deleted, to be updated with delect command
                self.currSelctPlotWgt = None
                self.lPlotWindows.remove(curreSelctPlotWgtName)    # remove the plot name from list of plot windows

                self.currSelctPlotWgt = self.dataPlot   # set the current selection to plot1
                self.currSelctPlotWgt.setBackground(0.95)
예제 #13
0
    def exportToPDF(self):
        if self.slotsExportedDisabled_:
            return

        util = FLUtil()
        fileName = QFileDialog.getSaveFileName(
            self, util.translate("app", "Exportar a PDF"), "",
            util.translate("app", "Fichero PDF (*.pdf)"))

        if fileName[0] == '':
            return

        if fileName[0].upper().find(".PDF") == -1:
            fileName = fileName[0] + ".pdf"

        if QtCore.QFile.exists(fileName):

            q = QMessageBox.question(
                self,
                util.translate("app", "Sobreescribir {}").format(fileName),
                util.translate(
                    "app",
                    "Ya existe un fichero llamado {}. ¿Desea sobreescribirlo?"
                ).format(fileName), util.translate("app", "&Sí"),
                util.translate("app", "&No"), "", 0, 1)
            if q:
                return

        self.slotPrintReportToPdf(fileName)
예제 #14
0
 def exitAPP(self):
     choice = QMessageBox.question(self, 'Exit', "Close the application?",
                                        QMessageBox.Yes | QMessageBox.No)
     if choice == QMessageBox.Yes:
         sys.exit()
     else:
         pass
예제 #15
0
 def closeEvent(self, event):
     reply = QMessageBox.question(self, '退出', '你确定要退出吗?',
                                  QMessageBox.Yes | QMessageBox.No,
                                  QMessageBox.No)
     if reply == QMessageBox.Yes:
         event.accept()
     else:
         event.ignore()
예제 #16
0
def borrar_producto(id_borrar): 
    alerta = QMessageBox.question(MainWindow, "¡¡¡ ATENCIÓN !!!", "Vas a borrar el producto con ID: " + str(id_borrar))
    if alerta == QMessageBox.Yes:
       
        borrar_item(id_borrar)
        mostrar_table()   
    else:
        mostrar_table()
예제 #17
0
 def exit(self):
     confirm = QMessageBox.question(self.w, 'Quit',
                                    'Are you sure you want to exit?',
                                    QMessageBox.Yes | QMessageBox.No)
     if confirm == QMessageBox.Yes:
         self.close()
     else:
         pass
예제 #18
0
 def editar_eliminar_cancion(self, accion):
     val_id = self.spx_numero_id.value()
     if val_id == 0:
         QMessageBox.about(self.my_win, "Error",
                           "Tienes que seleccionar un ID")
     else:
         if accion == "eliminar":
             eliminar = QMessageBox.question(
                 self.my_win, "Alerta", "¿Quieres eliminar esa canción?")
             if eliminar == QMessageBox.Yes:
                 borrar_cancion(val_id)
                 self.setupUi(self.my_win)
         elif accion == "editar":
             editar = QMessageBox.question(
                 self.my_win, "Alerta", "¿Quieres modificar esa canción?")
             if editar == QMessageBox.Yes:
                 self.editar_cancion(val_id)
예제 #19
0
    def game_over(self):
        self.paint(game_overd=True)
        self.show_game_result()
        self.notify('游戏结束')

        restart = QMessageBox.question(self, "游戏结束",
                                       "是否重新开始?") == QMessageBox.Yes
        if restart:
            self.restart(manual=False)
예제 #20
0
 def closeEvent(self, event):
     #здесь была переопределена функция закрытия интерфейса
     reply = QMessageBox.question(self, "Выход", "вы действительно хотите выйти?",
             QMessageBox.Yes, QMessageBox.No)
     if reply == QMessageBox.Yes:
         create_xml(self.cyclist1, self.cyclist2)
         event.accept()
     else:
         event.ignore()
예제 #21
0
 def closeEvent(self, closeEvt):
     reply = QMessageBox.question(self, "", "关闭后,设置将不会保存", QMessageBox.Yes,
                                  QMessageBox.No)
     if reply == QMessageBox.Yes:
         for button in self.checkedList:
             button.setChecked(True)
         self.hide()
     else:
         closeEvt.ignore()
예제 #22
0
    def changeKeys(self):
        # Ask if user wants to continue
        # If true, change credentials and close the app
        yesNo = QMessageBox.question(self, "", "Restart required, continue?",
                                     QMessageBox.Yes | QMessageBox.No)

        if yesNo == QMessageBox.Yes:
            changeKeys(self)
            sys.exit()
예제 #23
0
 def closeEvent(self, event):
     '''
     window close event
     '''
     reply = QMessageBox.question(self, 'Message', 'Do you want to quit?', QMessageBox.Yes | QMessageBox.No,QMessageBox.Yes)
     if reply == QMessageBox.Yes:
         event.accept()
     else:
         event.ignore()
예제 #24
0
 def _remove_clicked(self):
     nickname = self.ui.nicknameEdit.text()
     msg = 'Are you sure you want to remove project ' + nickname + '?'
     reply = QMessageBox.question(QMessageBox(), 'Double check', msg)
     if reply == QMessageBox.Yes:
         rec = Dataset.projects[nickname]
         rec.remove()
         del Dataset.projects[nickname]
         self._load_list(Dataset.projects.keys())
    def closeEvent(self, event):
        reply = QMessageBox.question(self, "Quit",
                                     "Are you sure you want to quit?",
                                     QMessageBox.Yes, QMessageBox.No)

        if reply == QMessageBox.Yes:
            event.accept()
        else:
            event.ignore()
예제 #26
0
    def closeEvent(self, event):
        reply = QMessageBox.question(self, 'Message', 'Are you sure to quit?',
                                     QMessageBox.Yes | QMessageBox.No,
                                     QMessageBox.Yes)

        if reply == QMessageBox.Yes:
            event.accept()
        if reply == QMessageBox.No:
            event.ignore()
예제 #27
0
 def close(self):
     if self._flag_2:
         result = QMessageBox.question(self, "ПРЕДУПРЕЖДЕНИЕ!",
                                       "Сохранить карту?",
                                       QMessageBox.Yes | QMessageBox.No,
                                       QMessageBox.No)
         if result == QMessageBox.Yes:
             edit_map.save_map()
     self.setVisible(False)
     game.setVisible(True)
예제 #28
0
    def should_continue(self, messages: List[str]) -> bool:
        messages.append("\nAre you sure you want to continue?")

        confirm = QMessageBox.question(self._responses_tab, "Confirmation",
                                       "\n".join(messages), QMessageBox.Yes, QMessageBox.No)

        if confirm == QMessageBox.Yes:
            return True
        else:
            return False
예제 #29
0
 def deleteFrame(self, caller):
     if not self.buttons.active == None:
         response = QMessageBox.question(caller, 'Frame Remove Message', "Are you sure you want to delete this frame?", QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes)
         if response == QMessageBox.Yes:
             self.buttons.active.setParent(None)
             del self.buttons[self.buttons.active]
             if self.start_index > 0:
                 self.start_index = self.start_index-1
             self.parent().canvas.hideMessage()
     self.rearrangeButtons()
예제 #30
0
 def maybe_cancel(self):
     if self.worker_thread and self.worker_thread.isRunning():
         reply = QMessageBox.question(
             self, 'BookFusion Sync',
             'Are you sure you want to cancel the currently running process?',
             QMessageBox.No | QMessageBox.Yes, QMessageBox.Yes)
         if reply == QMessageBox.Yes:
             self.cancel()
         else:
             return False
     return True
예제 #31
0
 def message_yes_no(self, question: str):
     return (
         QMessageBox.question(
             self.widget(),
             "Photocopieuse",
             question,
             QMessageBox.Yes | QMessageBox.No,
             QMessageBox.No,
         )
         == QMessageBox.Yes
     )
예제 #32
0
    def init_logic(self):
        logger.info(f"初始化逻辑数据")

        self.loop_index = 1
        self.invalid_cell_count = 0

        # 先手为蓝
        self.step_cell = cell_blue

        # ai托管,默认不托管
        self.ai_cells = {}
        self.ai_to_avg_stat = {}  # type: Dict[int, AvgStat]

        self.ai_moving = False

        self.game_start_time = datetime.now()
        self.game_restarted = False

        self.ai_dfs_max_depth = 4
        self.ai_min_decision_seconds = 0.5
        self.ai_max_decision_time = timedelta(seconds=26)
        blue_set_ai = True
        red_set_ai = True

        self.ai_dfs_max_depth, _ = QInputDialog.getInt(self, "ai参数设置", f"ai最大搜索层数(越大越强,速度越慢,默认为{self.ai_dfs_max_depth})", self.ai_dfs_max_depth)
        self.ai_min_decision_seconds, _ = QInputDialog.getDouble(self, "ai参数设置", f"ai每步最小等待时间(秒)(太小可能会看不清手动方的落子位置-。-)", self.ai_min_decision_seconds)
        ai_max_decision_time, _ = QInputDialog.getDouble(self, "ai参数设置", f"ai每步最大等待时间(秒)(避免超出30秒)", self.ai_max_decision_time.total_seconds())
        self.ai_max_decision_time = timedelta(seconds=ai_max_decision_time)
        blue_set_ai = QMessageBox.question(self, "AI配置", "蓝方是否启用AI?") == QMessageBox.Yes
        red_set_ai = QMessageBox.question(self, "AI配置", "红方是否启用AI?") == QMessageBox.Yes

        if blue_set_ai:
            self.set_ai(cell_blue, self.ai_min_max)
        if red_set_ai:
            self.set_ai(cell_red, self.ai_min_max)

        logger.info(f"ai最大迭代次数为{self.ai_dfs_max_depth},每次操作至少{self.ai_min_decision_seconds}秒,最大等待时间为{self.ai_max_decision_time}秒")

        self.last_step = (1, 1)

        self.init_board_without_invalid_cells()
예제 #33
0
    def exportToPDF(self):
        if self.slotsExportedDisabled_:
            return

        util = FLUtil()
        fileName = QFileDialog.getSaveFileName(
            self,
            util.translate("app", "Exportar a PDF"),
            "",
            util.translate("app", "Fichero PDF (*.pdf)")
        )

        if fileName[0] == '':
            return

        if fileName[0].upper().find(".PDF") == -1:
            fileName = fileName[0] + ".pdf"

        if QtCore.QFile.exists(fileName):

            q = QMessageBox.question(
                self,
                util.translate("app", "Sobreescribir {}").format(fileName),
                util.translate(
                    "app",
                    "Ya existe un fichero llamado {}. ¿Desea sobreescribirlo?"
                ).format(fileName),
                util.translate("app", "&Sí"),
                util.translate("app", "&No"),
                "",
                0,
                1
            )
            if q:
                return

        self.slotPrintReportToPdf(fileName)
예제 #34
0
파일: webpage.py 프로젝트: Fe-ver/hae
	def javaScriptConfirm(self, frame, msg):
		return QMessageBox.question(self.view().parentWidget(), None, msg) == QMessageBox.Yes
예제 #35
0
 def _remove_clicked(self):
     # nickname = self.ui.nicknameEdit.text()
     msg = 'Are you sure you want to remove assignment ?'
     reply = QMessageBox.question(QMessageBox(), 'Double check', msg)