Python PyQt5.QtWidgets.QApplication.quit() Examples

The following are 13 code examples for showing how to use PyQt5.QtWidgets.QApplication.quit(). They are from open source Python projects. You can vote up the examples you like or vote down the ones you don't like.

You may also check out all available functions/classes of the module PyQt5.QtWidgets.QApplication , or try the search function .

Example 1
Project: parsec-cloud   Author: Scille   File: main_window.py    License: GNU Affero General Public License v3.0 6 votes vote down vote up
def closeEvent(self, event):
        if self.minimize_on_close and not self.need_close:
            self.hide()
            event.ignore()
            self.systray_notification.emit("Parsec", _("TEXT_TRAY_PARSEC_STILL_RUNNING_MESSAGE"))
        else:
            if self.config.gui_confirmation_before_close and not self.force_close:
                result = ask_question(
                    self if self.isVisible() else None,
                    _("TEXT_PARSEC_QUIT_TITLE"),
                    _("TEXT_PARSEC_QUIT_INSTRUCTIONS"),
                    [_("ACTION_PARSEC_QUIT_CONFIRM"), _("ACTION_CANCEL")],
                )
                if result != _("ACTION_PARSEC_QUIT_CONFIRM"):
                    event.ignore()
                    self.force_close = False
                    self.need_close = False
                    return

            self.close_all_tabs()
            event.accept()
            QApplication.quit() 
Example 2
Project: 3D-Human-Body-Shape   Author: 1900zyh   File: demo.py    License: MIT License 6 votes vote down vote up
def set_menu(self):
    menubar = self.menuBar()
    fileMenu = menubar.addMenu('&File')

    exit = QtWidgets.QAction("Exit", self)
    exit.setShortcut("Ctrl+Q")
    exit.setStatusTip('Exit application')
    exit.triggered.connect(qApp.quit)
    fileMenu.addAction(exit)

    save = QtWidgets.QAction("Save", self)
    save.setShortcut("Ctrl+S")
    save.setStatusTip('save obj file')
    save.triggered.connect(self.viewer3D.save)
    fileMenu.addAction(save)

    self.flag_ = 0
    self.label_ = "female"
    self.mode = {0:"global_mapping", 1:"local_with_mask", 2:"local_with_rfemat"}
    for i in range(0, len(self.mode)):
      mode = myAction(i, self.mode[i], self)
      mode.myact.connect(self.select_mode)
      #self.connect(mode, QtCore.SIGNAL('myact(int)'), self.select_mode)
      fileMenu.addAction(mode)
    self.setToolTip('This is a window, or <b>something</b>') 
Example 3
Project: kw_condition   Author: coreanq   File: main.py    License: MIT License 5 votes vote down vote up
def quit(self):
        print(util.whoami())
        self.commTerminate()
        QApplication.quit()

    # 에러코드의 메시지를 출력한다. 
Example 4
Project: openconnect-sso   Author: vlaci   File: webengine_process.py    License: GNU General Public License v3.0 5 votes vote down vote up
def on_sigterm(signum, frame):
    logger.info("SIGNAL handler")
    QApplication.quit() 
Example 5
Project: Python-notes   Author: tomoncle   File: schdule.py    License: MIT License 5 votes vote down vote up
def qt_schedule():
    import signal
    import sys
    from apscheduler.schedulers.qt import QtScheduler

    try:
        from PyQt5.QtWidgets import QApplication, QLabel
    except ImportError:
        try:
            from PyQt4.QtGui import QApplication, QLabel
        except ImportError:
            from PySide.QtGui import QApplication, QLabel

    def tick():
        label.setText('Tick! The time is: %s' % datetime.now())

    app = QApplication(sys.argv)

    # This enables processing of Ctrl+C keypresses
    signal.signal(signal.SIGINT, lambda *args: QApplication.quit())

    label = QLabel('The timer text will appear here in a moment!')
    label.setWindowTitle('QtScheduler example')
    label.setFixedSize(280, 50)
    label.show()

    scheduler = QtScheduler()
    scheduler.add_job(tick, 'interval', seconds=3)
    scheduler.start()

    # Execution will block here until the user closes the windows or Ctrl+C is pressed.
    app.exec_() 
Example 6
Project: VUT-FIT-IFJ-2017-toolkit   Author: thejoeejoee   File: main.py    License: GNU General Public License v3.0 5 votes vote down vote up
def _interrupt_handler(signum, frame):
    QApplication.quit() 
Example 7
Project: qkit   Author: qkitgroup   File: main.py    License: GNU General Public License v2.0 5 votes vote down vote up
def close_all(self):
        QApplication.quit()


# Main entry to program. 
Example 8
Project: aw-qt   Author: ActivityWatch   File: trayicon.py    License: Mozilla Public License 2.0 5 votes vote down vote up
def exit(manager: Manager):
    # TODO: Do cleanup actions
    # TODO: Save state for resume
    print("Shutdown initiated, stopping all services...")
    manager.stop_all()
    # Terminate entire process group, just in case.
    # os.killpg(0, signal.SIGINT)

    QApplication.quit() 
Example 9
Project: aw-qt   Author: ActivityWatch   File: trayicon.py    License: Mozilla Public License 2.0 5 votes vote down vote up
def run(manager, testing=False):
    logger.info("Creating trayicon...")
    # print(QIcon.themeSearchPaths())

    app = QApplication(sys.argv)

    # Without this, Ctrl+C will have no effect
    signal.signal(signal.SIGINT, lambda *args: exit(manager))
    # Ensure cleanup happens on SIGTERM
    signal.signal(signal.SIGTERM, lambda *args: exit(manager))

    timer = QtCore.QTimer()
    timer.start(100)  # You may change this if you wish.
    timer.timeout.connect(lambda: None)  # Let the interpreter run each 500 ms.

    if not QSystemTrayIcon.isSystemTrayAvailable():
        QMessageBox.critical(None, "Systray", "I couldn't detect any system tray on this system. Either get one or run the ActivityWatch modules from the console.")
        sys.exit(1)

    widget = QWidget()
    if sys.platform == "darwin":
        icon = QIcon(":/black-monochrome-logo.png")
        # Allow macOS to use filters for changing the icon's color
        icon.setIsMask(True)
    else:
        icon = QIcon(":/logo.png")

    trayIcon = TrayIcon(manager, icon, widget, testing=testing)
    trayIcon.show()

    QApplication.setQuitOnLastWindowClosed(False)

    # Run the application, blocks until quit
    return app.exec_() 
Example 10
Project: algorithm-trading-webapp   Author: softage0   File: kiwoom.py    License: MIT License 5 votes vote down vote up
def quit(self):
        """ Quit the server """

        self.disconnect_real_data(self.S_SCREEN_NO)
        QApplication.quit() 
Example 11
Project: kw_condition   Author: coreanq   File: main.py    License: MIT License 4 votes vote down vote up
def make_excel(self, file_path, data_dict):
        result = False
        result = os.path.isfile(file_path)

        if( result == False):
            with open( CHEGYEOL_INFO_EXCEL_FILE_PATH, 'w', encoding = 'utf8' ) as f:
                f.write('')

        # excel open 
        wb = xw.Book(file_path)
        sheet_names = [sheet.name for sheet in wb.sheets]
        insert_sheet_names = []
        # print(sheet_names)
        for key, value in data_dict.items():
            # sheet name 이 존재 안하면 sheet add
            sheet_name = key[0:4]
            if( sheet_name not in sheet_names ):
                if( sheet_name not in insert_sheet_names ):
                    insert_sheet_names.append(sheet_name)

        for insert_sheet in insert_sheet_names:
            wb.sheets.add(name = insert_sheet)
        # sheet name 은 YYMM 형식 
        sheet_names = [sheet.name for sheet in wb.sheets]

        for sheet_name in sheet_names:
            # key 값이 match 되는것을 찾음 
            row_count = 1
            excel_row_string = 'A{}'
            for sorted_key in sorted(data_dict):
                input_data_sheet_name = sorted_key[0:4]
                if( input_data_sheet_name == sheet_name ):
                    wb.sheets[sheet_name].activate()
                    xw.Range(excel_row_string.format(row_count)).value = [ sorted_key, '-' * 156 ]
                    row_count += 1

                    for line in data_dict[sorted_key]:
                        items = [ item.strip() for item in line.split('|') ]
                        # 빈칸 두개 추가 
                        items.insert(0, '')
                        items.insert(0, '')
                        wb.sheets[sheet_name].activate()
                        xw.Range(excel_row_string.format(row_count)).value = items 
                        row_count += 1

        # save
        wb.save()
        wb.app.quit()

    # method 
    # 로그인
    # 0 - 성공, 음수값은 실패
    # 단순 API 호출이 되었느냐 안되었느냐만 확인 가능 
Example 12
Project: qkit   Author: qkitgroup   File: main.py    License: GNU General Public License v2.0 4 votes vote down vote up
def main(argv):
    """Main function to open a h5 file with qviewkit.

    This function is called via command line. It opens the optional parsed
    h5 file and the optional parsed datasets automatically.
    The DatasetsWindow object creates a Qt based window with some UI buttons
    for file handling and a populated tree of the datasets.

    Args:
        '-f','--file',     type=str, help='hdf filename to open'
        '-ds','--datasets', type=str, help='(optional) datasets opened by default'

        '-rt','--refresh_time', type=float, help='(optional) refresh time'
        '-sp','--save_plot',  default=False,action='store_true', help='(optional) save default plots'
        '-live','--live_plot',default=False,action='store_true', help='(optional) if set, plots are reloaded'
        '-qinfo','--qkit_info',default=False,action='store_true', help='(optional) if set, listen to qkit infos'
    """
    # some configuration boilerplate
    data = DATA()

    parser = argparse.ArgumentParser(
        description="Qviewkit / qkit tool to visualize qkit-hdf files // HR@KIT 2015")


    parser.add_argument('-f','--file',     type=str, help='hdf filename to open')
    parser.add_argument('-ds','--datasets', type=str, help='(optional) datasets opened by default')

    parser.add_argument('-rt','--refresh_time', type=float, help='(optional) refresh time')
    parser.add_argument('-sp','--save_plot',  default=False,action='store_true', help='(optional) save default plots')
    parser.add_argument('-live','--live_plot',default=False,action='store_true', help='(optional) if set, plots are reloaded')
    parser.add_argument('-qinfo','--qkit_info',default=False,action='store_true', help='(optional) if set, listen to qkit infos')
    args=parser.parse_args()
    data.args = args

    # create Qt application
    if in_pyqt5:
        app = QApplication(argv)
    if in_pyqt4:
        app = QApplication(argv,True)

    # if activated, start info thread
    if data.args.qkit_info:
        from qkit.gui.qviewkit.info_subsys import info_thread
        it = info_thread(data)
        it.start()


    # create main window
    from qkit.gui.qviewkit.DatasetsWindow import DatasetsWindow
    #
    dsw = DatasetsWindow(data)
    dsw.show()
    dsw.raise_()

    # Connect signal for app quit
    app.lastWindowClosed.connect(quit)
    app.exec_() 
Example 13
Project: algorithm-trading-webapp   Author: softage0   File: kiwoom.py    License: MIT License 4 votes vote down vote up
def __init__(self, k_queue):
        super().__init__()
        self.S_SCREEN_NO = "0001"
        self.MARKET_LIST = {
            0: '장내',
            3: 'ELW',
            4: '뮤추얼펀드',
            5: '신주인수권',
            6: '리츠',
            8: 'ETF',
            9: '하이일드펀드',
            10: '코스닥',
            30: '제3시장'
        }
        self.ORDER_TYPE = {
            1: '신규매수',
            2: '신규매도',
            3: '매수취소',
            4: '매도취소'
        }
        self.HOGA = {
            '00': '지정가',
            '03': '시장가'
        }

        self.q = k_queue
        self.qs = {
            'OnReceiveTrData': queue.Queue(),
            'OnReceiveRealData': queue.Queue(),
            'OnReceiveMsg': queue.Queue(),
            'OnReceiveChejanData': queue.Queue(),
            'OnEventConnect': queue.Queue(),
            'OnReceiveRealCondition': queue.Queue(),
            'OnReceiveTrCondition': queue.Queue(),
            'OnReceiveConditionVer': queue.Queue()
        }
        self.ocx = QAxWidget("KHOPENAPI.KHOpenAPICtrl.1")
        self.ocx.OnReceiveTrData[str, str, str, str, str, int, str, str, str].connect(self.OnReceiveTrData)
        self.ocx.OnReceiveRealData[str, str, str].connect(self.OnReceiveRealData)
        self.ocx.OnReceiveMsg[str, str, str, str].connect(self.OnReceiveMsg)
        self.ocx.OnReceiveChejanData[str, int, str].connect(self.OnReceiveChejanData)
        self.ocx.OnEventConnect[int].connect(self.OnEventConnect)
        self.ocx.OnReceiveRealCondition[str, str, str, str].connect(self.OnReceiveRealCondition)
        self.ocx.OnReceiveTrCondition[str, str, str, int, int].connect(self.OnReceiveTrCondition)
        self.ocx.OnReceiveConditionVer[int, str].connect(self.OnReceiveConditionVer)
        atexit.register(self.quit)

    ####################################################
    # Interface Methods
    ####################################################