Python PyQt5.QtWidgets.QApplication 模块,__init__() 实例源码

我们从Python开源项目中,提取了以下8个代码示例,用于说明如何使用PyQt5.QtWidgets.QApplication.__init__()

项目:BigBrotherBot-For-UrT43    作者:ptitbigorneau    | 项目源码 | 文件源码
def __init__(self, id=None, config=None, lastrun=-1):
        """
        Initialize a new B3 instance.
        :param id: the B3 instance id :type int:
        :param config: the B3 configuration file path :type MainConfig: || :type str:
        :param lastrun: the B3 last run timestamp :type int:
        """
        QProcess.__init__(self)
        self.id = id
        self.config = config
        self.lastrun = lastrun

        # create the console window (hidden by default)
        self.stdout = STDOutDialog(process=self)
        self.setProcessChannelMode(QProcess.MergedChannels)
        self.readyReadStandardOutput.connect(self.stdout.read_stdout)
        self.readyReadStandardError.connect(self.stdout.read_stdout)
        # configure signal handlers
        self.error.connect(self.process_errored)
        self.finished.connect(self.process_finished)
        self.started.connect(self.process_started)

    ############################################### PROPERTIES #########################################################
项目:pyopenvr    作者:cmbruns    | 项目源码 | 文件源码
def __init__(self, renderer, glformat, app):
        "Creates an OpenGL context and a window, and acquires OpenGL resources"
        super(MyGlWidget, self).__init__(glformat)
        self.renderer = renderer
        self.app = app
        # Use a timer to rerender as fast as possible
        self.timer = QTimer(self)
        self.timer.setSingleShot(True)
        self.timer.setInterval(0)
        self.timer.timeout.connect(self.render_vr)
        # Accept keyboard events
        self.setFocusPolicy(Qt.StrongFocus)
项目:pyopenvr    作者:cmbruns    | 项目源码 | 文件源码
def __init__(self, renderer, title):
        QApplication.__init__(self, sys.argv)
        self.window = QMainWindow()
        self.window.setWindowTitle(title)
        self.window.resize(800,600)
        # Get OpenGL 4.1 context
        glformat = QGLFormat()
        glformat.setVersion(4, 1)
        glformat.setProfile(QGLFormat.CoreProfile)
        glformat.setDoubleBuffer(False)
        self.glwidget = MyGlWidget(renderer, glformat, self)
        self.window.setCentralWidget(self.glwidget)
        self.window.show()
项目:HearthPacks    作者:Arzaroth    | 项目源码 | 文件源码
def __init__(self, opts):
        QApplication.__init__(self, [])
        self.opts = opts
        self.initUI()
项目:Linalfred    作者:PeterHo    | 项目源码 | 文件源码
def __init__(self, argv, application_id=None):
        QApplication.__init__(self, argv)

        self.socket_filename = os.path.expanduser("~/.ipc_%s" % self.generate_ipc_id())
        self.shared_mem = QSharedMemory()
        self.shared_mem.setKey(self.socket_filename)

        if self.shared_mem.attach():
            self.is_running = True
            return

        self.is_running = False
        if not self.shared_mem.create(1):
            print("Unable to create single instance")
            return
        # start local server
        self.server = QLocalServer(self)
        # connect signal for incoming connections
        self.server.newConnection.connect(self.receive_message)
        # if socket file exists, delete it
        if os.path.exists(self.socket_filename):
            os.remove(self.socket_filename)
        # listen
        self.server.listen(self.socket_filename)

        SingletonApp.instance = self

        # ??????
        signal.signal(signal.SIGINT, self.onExit)
        # signal.signal(signal.SIGKILL, onExit)
        signal.signal(signal.SIGTERM, self.onExit)
        self.timer = QTimer()
        self.timer.start(500)
        self.timer.timeout.connect(lambda: None)
项目:Pesterchum-Discord    作者:henry232323    | 项目源码 | 文件源码
def __init__(self):
        QApplication.__init__(self, sys.argv)
        # Establish loop as Quamash Event Loop
        loop = QEventLoop(self)
        self.loop = loop
        asyncio.set_event_loop(loop)

        self.idle = False
        self.trayIcon = None

        self.themes = themes
        self.options = Options
        try:
            self.theme = themes[self.options["theme"]["theme"]]
        except KeyError:
            self.theme = themes["Pesterchum 2.5"]
        self.theme_name = self.theme["name"]
        self.moods = Moods
        self.emojis = Emojis
        self.mentions = Mentions
        self.setStyleSheet(self.theme["styles"])

        self.nick = None
        self.client = DiscordClient(app=self, loop=self.loop)

        self.user, self.passwd, self.token, self.botAccount = UserAuth

        if not UserAuth[0] and not UserAuth[1] and not UserAuth[2]:
            self.openAuth(i=True)
            save_auth((self.user, self.passwd, self.token, self.botAccount,))

        asyncio.ensure_future(self.connecting())
        asyncio.ensure_future(self.runbot())
        self.gui = Gui(self.loop, self)
        loop.run_forever()
项目:BigBrotherBot-For-UrT43    作者:ptitbigorneau    | 项目源码 | 文件源码
def __init__(self, *args, **kwargs):
        """
        Initialize a new application.
        """
        QApplication.__init__(self, *args, **kwargs)
项目:BigBrotherBot-For-UrT43    作者:ptitbigorneau    | 项目源码 | 文件源码
def __init_log():
        """
        Initialize the GUI log.
        """
        global LOG

        class CustomHandler(logging.Logger):

            def __init__(self, name, level=logging.NOTSET):
                """
                Object constructor.
                :param name: The logger name
                :param level: The default logging level
                """
                logging.Logger.__init__(self, name, level)

            def critical(self, msg, *args, **kwargs):
                """
                Log 'msg % args' with severity 'CRITICAL' and raise an Exception.
                """
                logging.Logger.critical(self, msg, *args, **kwargs)
                raise Exception(msg % args)

        logging.setLoggerClass(CustomHandler)

        LOG = logging.getLogger('B3')
        handler = logging.FileHandler(B3_LOG, mode='w')
        handler.setFormatter(logging.Formatter('%(asctime)s\t%(levelname)s\t%(message)r', '%y%m%d %H:%M:%S'))
        LOG.addHandler(handler)
        LOG.setLevel(logging.DEBUG)