如何在PyQt python窗口的开头调用函数?

时间:2016-08-15 11:38:15

标签: python pyqt5

当应用/表单/窗口启动但我没有调用时,我试图调用我的keypress_request()函数? 我有办法做到吗?

import time
from PyQt5 import QtCore, QtGui, QtWidgets
from screenkeep import Ui_MainWindow
from keypress_m import perform_keypress
from multiprocessing import Process


class ScreenKeepProgram(Ui_MainWindow):
    def __init__(self, parent=None):
        super(ScreenKeepProgram, self).__init__(self)
        self.setupUi(self)

        # This below is the function I want to call
        # at the start of the program, with no success
        self.keypress_request()

    def keypress_action(self):
        while True:
            time.sleep(5)
            perform_keypress('o')

    def keypress_request(self):
        do_keypress = Process(target=self.keypress_action)
        do_keypress.daemon = True
        do_keypress.start()

0 个答案:

没有答案