コード例 #1
0
 def btn_click(self):
     """
     Handles the click on the OK button, changes the flag to True.
     """
     if self.nickname.text():
         self.ok_flag = True
         qApp.exit()
コード例 #2
0
ファイル: __main__.py プロジェクト: Tydus/vidcutter
 def __init__(self):
     super(MainWindow, self).__init__()
     self.video, self.devmode = '', False
     self.parse_cmdline()
     self.init_logger()
     self.init_settings()
     self.init_scale()
     self.init_cutter()
     self.setWindowTitle('%s' % qApp.applicationName())
     self.setContentsMargins(0, 0, 0, 0)
     self.statusBar().showMessage('Ready')
     self.statusBar().setStyleSheet('border: none; padding: 0; margin: 0;')
     self.setAcceptDrops(True)
     self.show()
     self.console.setGeometry(int(self.x() - (self.width() / 2)), self.y() + int(self.height() / 3), 750, 300)
     try:
         if len(self.video):
             if QFileInfo(self.video).suffix() == 'vcp':
                 self.cutter.openProject(project_file=self.video)
             else:
                 self.cutter.loadMedia(self.video)
     except (FileNotFoundError, PermissionError) as e:
         QMessageBox.critical(self, 'Error loading file', sys.exc_info()[0])
         logging.exception('Error loading file')
         qApp.restoreOverrideCursor()
         self.restart()
     if not self.cutter.ffmpeg_check():
         qApp.exit(1)
コード例 #3
0
ファイル: Terminal.py プロジェクト: fadam003/PyPad
    def handle(self, command):

        """Split a command into list so command echo hi would appear as ['echo', 'hi']"""
        real_command = command.replace(self.editor.name, "")

        if command == "True":
            if self.process.state() == 2:
                self.process.kill()
                self.editor.appendPlainText("Program execution killed, press enter")
        if real_command.startswith("python"):
            # TODO: start a python thread....
            pass

        if real_command != "":
            command_list = real_command.split()
        else:
            command_list = None
        """Now we start implementing some commands"""
        if real_command == "clear":
            self.editor.clear()

        elif "&&" in command_list:
            pass
            # print(command_list)
            # print(command_list.index("&&"))
            # print(command_list[command_list.index("&&")+1:])

        elif command_list is not None and command_list[0] == "echo":
            self.editor.appendPlainText(" ".join(command_list[1:]))

        elif real_command == "exit":
            qApp.exit()

        elif command_list is not None and command_list[0] == "cd" and len(command_list) > 1:
            try:
                os.chdir(" ".join(command_list[1:]))
                self.editor.name = "[" + str(getpass.getuser()) + "@" + str(socket.gethostname()) + "]" + "  ~" + str(
                    os.getcwd()) + " >$ "
                if self.highlighter:
                    del self.highlighter
                self.highlighter = name_highlighter(self.editor.document(), str(getpass.getuser()),
                                                    str(socket.gethostname()), str(os.getcwd()))

            except FileNotFoundError as E:
                self.editor.appendPlainText(str(E))

        elif len(command_list) == 1 and command_list[0] == "cd":
            os.chdir(str(Path.home()))
            self.editor.name = "[" + str(getpass.getuser()) + "@" + str(socket.gethostname()) + "]" + "  ~" + str(
                os.getcwd()) + " >$ "

        elif self.process.state() == 2:
            self.process.write(real_command.encode())
            self.process.closeWriteChannel()

        elif command == self.editor.name + real_command:
            self.run(real_command)

        else:
            pass  # When the user does a command like ls and then presses enter then it wont read the line where the cursor is on as a command
コード例 #4
0
ファイル: mainwin.py プロジェクト: gonboy/QssStylesheetEditor
 def closeEvent(self, e):
     if (self.editor.isModified()):
         if (self.lastSavedText != self.editor.text()):
             msg = QMessageBox(
                 QMessageBox.Question, self.title,
                 self.tr(
                     self.tr("Save before close?") +
                     os.path.basename(self.file)), QMessageBox.Save
                 | QMessageBox.Discard | QMessageBox.Cancel)
             msg.setDefaultButton(QMessageBox.Cancel)
             msg.button(QMessageBox.Save).setText(self.tr("Save"))
             msg.button(QMessageBox.Discard).setText(self.tr("Discard"))
             msg.button(QMessageBox.Cancel).setText(self.tr("Cancel"))
             ret = msg.exec_()
             # ret=QMessageBox.information(self,"Qss Style Editor",self.tr("是否将更改保存到"+os.path.basename(self.file)),
             #                             QMessageBox.Yes|QMessageBox.No|QMessageBox.Cancel,QMessageBox.Yes)
             if (ret == QMessageBox.Save or ret == QMessageBox.Yes):
                 self.save()
                 e.ignore()
             elif (ret == QMessageBox.Discard or ret == QMessageBox.No):
                 self.updateConfig()
                 self.config.save()
                 qApp.exit()
             else:
                 e.ignore()
     else:
         self.updateConfig()
         self.config.save()
コード例 #5
0
    def render(self):
        app = QApplication(sys.argv)

        self.set_up_login_window()
        self.set_up_signup_window()
        self.set_up_add_contact_window()
        self.set_up_del_contact_window()

        if self.client.client_name:
            max_waiting_time = 0
            while True:  # TODO: переделать этот костыль
                if self.client.token:
                    last_visit_date = get_client_last_visit_date(self.client.client_name)
                    set_client_to_active(self.client.client_name)
                    self.get_new_messages_from_server(last_visit_date)
                    break

                sleep(0.5)
                max_waiting_time += 0.5

                if max_waiting_time == 10:
                    QMessageBox.critical(
                        self.main_window, 'Error', 'Server timed out.'
                    )
                    # TODO: не доходит до exit, виснет на сообщении
                    qApp.exit()

            self.show_main_window()
        else:
            self.show_login_window()

        sys.exit(app.exec_())
コード例 #6
0
 def closeEvent(self, e):
     if self.editor.isModified():
         if self.lastSavedText != self.editor.text():
             msg = QMessageBox(
                 QMessageBox.Question, self.title,
                 self.
                 tr("Current file hasn't been saved, do you want to save?"),
                 QMessageBox.Save | QMessageBox.Discard
                 | QMessageBox.Cancel)
             msg.setDefaultButton(QMessageBox.Cancel)
             msg.button(QMessageBox.Save).setText(self.tr("Save"))
             msg.button(QMessageBox.Discard).setText(self.tr("Discard"))
             msg.button(QMessageBox.Cancel).setText(self.tr("Cancel"))
             ret = msg.exec_()
             # ret=QMessageBox.information(self,"Qss Style Editor",self.tr("是否将更改保存到"+os.path.basename(self.file)),
             #                             QMessageBox.Yes|QMessageBox.No|QMessageBox.Cancel,QMessageBox.Yes)
             if ret in (QMessageBox.Save, QMessageBox.Yes):
                 self.save()
                 e.ignore()
             elif ret in (QMessageBox.Discard, QMessageBox.No):
                 self.updateSpecialConfig()
                 self.config.save()
                 qApp.exit()
             else:
                 e.ignore()
     else:
         self.updateSpecialConfig()
         self.config.saveDefault()
コード例 #7
0
 def Video_UI(self, msm):
     # print(f"video: {msm}")
     if msm.get("error", 0) == 1:
         reply = QtWidgets.QMessageBox.question(
             self, '视频稿件线程出错', "视频稿件模块停止了工作(不影响主程序),是否重启软件尝试恢复",
             QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No,
             QtWidgets.QMessageBox.No)
         if reply == QtWidgets.QMessageBox.Yes:
             self.tray.hide()
             self.destroy()
             qApp.exit(101)
         else:
             pass
     else:
         a = time.time()
         try:
             self.listWidget.clear()
         except Exception as e:
             print(e)
             pass
         if msm["video_url"]:
             self.video_url = msm["video_url"]
             self.label_vtot.setText(f"共有 {len(self.video_url)} 个视频稿件")
             for i in msm["widgets"]:
                 item = QListWidgetItem()  # 创建QListWidgetItem对象
                 item.setSizeHint(QSize(200, 100))  # 设置QListWidgetItem大小
                 QApplication.processEvents()
                 widget = self.get_item_wight(i)  # 调用上面的函数获取对应
                 QApplication.processEvents()
                 self.listWidget.addItem(item)  # 添加item
                 self.listWidget.setItemWidget(item, widget)
         else:
             self.label_vtot.setText(f"暂时没有视频稿件")
         self.pushButton_vrenew.setText("")
コード例 #8
0
 def Reply_UI(self, msm):
     if msm.get("error", 0) == 1:
         reply = QtWidgets.QMessageBox.question(
             self, '评论线程出错', "已经停止使用评论功能(不影响主程序),是否重启软件尝试恢复",
             QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No,
             QtWidgets.QMessageBox.No)
         if reply == QtWidgets.QMessageBox.Yes:
             self.tray.hide()
             self.destroy()
             qApp.exit(101)
         else:
             pass
     else:
         try:
             self.listWidget_reply.clear()
         except Exception as e:
             print(e)
             pass
         if msm["reply_url"]:
             self.reply_url = msm["reply_url"]
             self.label_rtot.setText(f"共有 {len(self.reply_url)} 条评论")
             for i in msm["widgets"]:
                 item = QListWidgetItem()  # 创建QListWidgetItem对象
                 QApplication.processEvents()
                 widget = self.get_item_wight_reply(i)  # 调用上面的函数获取对应
                 item.setSizeHint(
                     QSize(widget.width(),
                           widget.height()))  # 设置QListWidgetItem大小与widget相同
                 QApplication.processEvents()
                 self.listWidget_reply.addItem(item)  # 添加item
                 self.listWidget_reply.setItemWidget(item, widget)
         else:
             self.label_rtot.setText(f"暂时没有评论")
         self.pushButton_rrenew.setText("")
コード例 #9
0
        def set_graph(self, data, selected_menu):
            x = []  #nations
            y = []  #show y data

            for nation in data:
                x.append(nation['cc'])

                if selected_menu == MENU_CODE['CONFIRMED']:
                    y.append(nation['confirmed'])
                elif selected_menu == MENU_CODE['ACTIVE']:
                    y.append(nation['active'])
                elif selected_menu == MENU_CODE['DEATH']:
                    y.append(nation['death'])
                elif selected_menu == MENU_CODE['RELEASED']:
                    y.append(nation['released'])
                elif selected_menu == MENU_CODE['INCREASEMENT']:
                    y.append(nation['confirmed'] - nation['confirmed_prev']
                             ) if 'confirmed_prev' in nation else y.append(
                                 nation['confirmed'])
                elif selected_menu == MENU_CODE['RELEASED_RATE']:
                    y.append(float(nation['releasedRate']))
                elif selected_menu == MENU_CODE['DEATH_RATE']:
                    y.append(float(nation['deathRate']))
                else:
                    print('Invalid Selected Menu')
                    qApp.exit()

            self.graph.draw_bar_graph(x, y)
コード例 #10
0
 def parse_cmdline(self) -> None:
     self.parser = QCommandLineParser()
     self.parser.setApplicationDescription(
         '\nVidCutter - the simplest + fastest media cutter & joiner')
     self.parser.addPositionalArgument('video', 'Preload video file',
                                       '[video]')
     self.parser.addPositionalArgument(
         'project', 'Open VidCutter project file (.vcp)', '[project]')
     self.debug_option = QCommandLineOption(
         ['debug'], 'debug mode; verbose console output & logging. '
         'This will basically output what is being logged to file to the '
         'console stdout. Mainly useful for debugging problems with your '
         'system video and/or audio stack and codec configuration.')
     self.parser.addOption(self.debug_option)
     self.parser.addVersionOption()
     self.parser.addHelpOption()
     self.parser.process(qApp)
     self.args = self.parser.positionalArguments()
     if self.parser.isSet(self.debug_option):
         os.environ['DEBUG'] = '1'
     if len(self.args) > 0:
         file_path = QFileInfo(self.args[0]).absoluteFilePath()
         if not os.path.exists(file_path):
             sys.stderr.write('\nERROR: File not found: %s\n' % file_path)
             self.close()
             qApp.exit(1)
         self.video = file_path
コード例 #11
0
 def logout(self):
     with open("config.json", "w") as f:
         f.write("{}")
     QMessageBox.information(self, '小助手提示', '退出登录成功,请重新登录')
     self.tray.hide()
     self.destroy()
     qApp.exit(101)
コード例 #12
0
 def Article_UI(self, msm):
     if msm.get("error", 0) == 1:
         reply = QtWidgets.QMessageBox.question(
             self, '登录状态失效', "请重新登录",
             QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No,
             QtWidgets.QMessageBox.No)
         if reply == QtWidgets.QMessageBox.Yes:
             self.tray.hide()
             self.destroy()
             qApp.exit(101)
         else:
             self.tray.hide()
             self.destroy()
             qApp.exit(101)
     else:
         a = time.time()
         try:
             self.listWidget_article.clear()
         except Exception as e:
             print(e)
             pass
         if msm["article_url"]:
             self.article_url = msm["article_url"]
             self.label_atot.setText(f"共有 {len(self.article_url)} 个专栏文章")
             for i in msm["widgets"]:
                 item = QListWidgetItem()  # 创建QListWidgetItem对象
                 item.setSizeHint(QSize(200, 100))  # 设置QListWidgetItem大小
                 QApplication.processEvents()
                 widget = self.get_item_wight(i)  # 调用上面的函数获取对应
                 QApplication.processEvents()
                 self.listWidget_article.addItem(item)  # 添加item
                 self.listWidget_article.setItemWidget(item, widget)
         else:
             self.label_atot.setText(f"暂时没有专栏文章")
         self.pushButton_arenew.setText("")
コード例 #13
0
 def click(self):
     """
     Метод обрабтчик кнопки ОК.
     :return: None
     """
     if self.client_name.text():
         self.ok_pressed = True
         qApp.exit()
コード例 #14
0
 def close_win(self):
     res = QMessageBox.question(self, '请再次确认', '更新进行中,请再次确认是否退出',
                                QMessageBox.Yes | QMessageBox.No,
                                QMessageBox.No)
     if res == QMessageBox.Yes:
         qApp.exit(0)
     else:
         pass
コード例 #15
0
 def window_close(self, code):
     res = QMessageBox.question(self, '是否关闭程序', '请确保没有下载任务',
                                QMessageBox.Yes | QMessageBox.No,
                                QMessageBox.No)
     if res == QMessageBox.Yes:
         qApp.exit(code)
     else:
         pass
コード例 #16
0
ファイル: main_window.py プロジェクト: namuan/orkestra
 def closeEvent(self, event: QCloseEvent):
     logging.info("Received close event")
     event.accept()
     self.main_controller.shutdown()
     try:
         qApp.exit(0)
     except:
         pass
コード例 #17
0
 def click(self):
     """
     Метод обрабтчик кнопки ОК, если поле вводе не пустое,
     ставим флаг и завершаем приложение.
     :return:
     """
     if self.client_name.text():
         self.ok_pressed = True
         qApp.exit()
コード例 #18
0
 def window_close(self, code):
     res = QMessageBox.question(self, '是否关闭程序', '请确保没有下载任务',
                                QMessageBox.Yes | QMessageBox.No,
                                QMessageBox.No)
     if res == QMessageBox.Yes:
         self.webDownloader_Thread.stop()
         qApp.exit(code)
     else:
         pass
コード例 #19
0
 def showFileError(self, type):
     if type == "save_error":
         QMessageBox.warning(self, "File Error", "There was an error while "\
             "saving or creating the file.\nMultiSearch will now exit.")
     elif type == "json_error":
         QMessageBox.warning(self, "File Error", "There was an error reading "\
             "JSON from file.\nIf the file was edited manually, ensure proper "\
             "syntax is used.\nExit Multisearch and correct or delete the file.")
     qApp.exit(1)
コード例 #20
0
 def reboot_program(self):
     reply = QMessageBox.question(
         self, "Message",
         "Are you sure you want to reboot? Any unsaved work will be lost.",
         QMessageBox.Ok | QMessageBox.Cancel, QMessageBox.Cancel)
     if reply == QMessageBox.Ok:
         self._stopflag = True
         self._exitflag = True
         qApp.exit(self.EXIT_CODE_REBOOT)
コード例 #21
0
 def check_not_empty(self):
     """
     Button handler login_button.
     If the field is not empty, then change the ok_pressed flag to True and close the window.
     :return:
     """
     if self.auth_name_field.text() and self.password_field.text():
         self.ok_pressed = True
         qApp.exit()
コード例 #22
0
ファイル: settingbar.py プロジェクト: shen962806862/memo
    def updateSetting(self):
        #opacity set
        self.data['set_data']['label_opacity'] = float(
            self.text1.toPlainText())
        self.data['set_data']['touch_opacity'] = float(
            self.text2.toPlainText())
        write(self.data)

        self.close()
        qApp.exit(888)
コード例 #23
0
    def logout(self):
        action = 'logout'
        self.write(action)

        self.main_window.close()

        self.client.client_name = None
        set_client_to_inactive()

        qApp.exit()     # TODO: Вместо qApp.exit() показать окно логина, удалить connect к текущей db
コード例 #24
0
    def reset_settings(self):
        result = self.alert_message('Warning!',
                                    'Restart required!',
                                    'To reset the settings, '
                                    'the program has to be restarted. '
                                    'Do you want to reset and restart?',
                                    question=True)

        if result == QMessageBox.Yes:
            self.settings = self.file_handler.load_settings(reset=True)
            qApp.exit(GUI.EXIT_CODE_REBOOT)
コード例 #25
0
ファイル: gui.py プロジェクト: realrunner/antixps
 def closeEvent(self, evnt):
     if self.kill:
         self.trayIcon.hide()
         try:
             cherrypy_server.stop_server()
         except Exception as e:
             logging.getLogger(__name__).warn("Problem stopping server! {}".format(e))
         qApp.exit(0)
     else:
         evnt.ignore()
         self.hide()
コード例 #26
0
ファイル: main_window.py プロジェクト: crumpstrr33/spearch
    def _relogin(self):
        """
        Brings up new window to log in as a new user
        """
        # New login window
        login = Login()
        result = login.exec_()

        if result == QDialog.Accepted:
            self.client = login.client
            # Exit current app with code that tells main loop to repeat
            qApp.exit(self.NEW_USER_EXIT_CODE)
コード例 #27
0
 def exit(self):
     if self.flag_save:
         msg_box = QMessageBox()
         msg_box.setInformativeText("Do you want to save your changes?")
         msg_box.setStandardButtons(QMessageBox.Save | QMessageBox.Discard | QMessageBox.Cancel)
         msg_box.setDefaultButton(QMessageBox.Save)
         answer = msg_box.exec()
         if answer == QMessageBox.Save:
             self.save()
         elif answer == QMessageBox.Cancel:
             # Don't close app if user change is <Cancel>
             return
     qApp.exit()
コード例 #28
0
ファイル: demo10.py プロジェクト: zhao-baba/ApiAutoTest
 def action(self):
     # 获取按键的内容
     text = self.sender().text()
     if text == 'Cls':
         self.clear()
     elif text == 'Bck':
         self.backsapce()
     elif text == 'Close':
         qApp.exit()
     elif text == '=':
         self.cacl()
     else:
         self.show_msg(text)
コード例 #29
0
 def Com_UI(self, msm):
     if "jindu" in msm:
         num = int(msm.replace('jindu', ''))
         self.progressBar.setValue(num)
     if "更新失败" in msm:
         self.com_flag = True
         self.show_message(msm)
     elif msm == "更新完成" and self.com_flag == False:
         self.show_message("更新完成,更新程序即将退出")
         subprocess.Popen(f"{self.argv[2]}")
         qApp.exit(0)
     elif not self.com_flag != False:
         self.show_message(msm)
コード例 #30
0
 def setQrcode(self, msm):
     if msm["code"] == -2:
         self.label_qrcode.setPixmap(QPixmap("qrCode.png"))
         self.label_qrcode.setScaledContents(True)
     elif msm["code"] == -5:
         self.label_qrcode.setText("已经扫码\n请在手机确认")
     elif msm["code"] == 0:
         cookies = ""
         for i in msm['cookies']:
             cookies += f"{i}={msm['cookies'][i]};"
         with open("cache/status.json", "w") as f:
             f.write(cookies)
         self.hide()  # 登录界面不会自动消失问题,程序重启前先进行隐藏界面操作
         qApp.exit(-1)
コード例 #31
0
    def __log_out(self):
        """Cierra sesión. Primero pregunta si desea cerrar sesión y luego procede.

        Note:
            Esta función no debe ser llamada desde el exterior, puesto que su uso es interno en la
            clase.
        """
        response = QuestionDialog.open_question(
            "¿Deas cerrar sesión?",
            "¿Realmente deseas cerrar sesión?. La sincronización se detendrá.",
            self)
        if response == 1:
            self.tray_icon.hide()
            self.hide()
            qApp.exit(1)
コード例 #32
0
ファイル: main.py プロジェクト: wolfmankurd/id_book
 def db_close(self):
     """ Close the db connection and commit """
     self.statusBar().showMessage("Commiting to database")
     self.db_conn.commit()
     self.db_conn.close()
     qApp.exit()