File: //usr/lib/python3/dist-packages/twisted/internet/__pycache__/wxreactor.cpython-38.pyc
U
s�@g� � @ s� d Z zddlmZmZ W n$ ek
r< ddlmZmZ Y nX zddlmZmZ m
Z W n( ek
r~ ddlmZm Z mZ Y nX ddl
mZmZ ddlmZ G dd� de�ZG d d
� d
ej�Zdd� ZdgZd
S )aa
This module provides wxPython event loop support for Twisted.
In order to use this support, simply do the following::
| from twisted.internet import wxreactor
| wxreactor.install()
Then, when your root wxApp has been created::
| from twisted.internet import reactor
| reactor.registerWxApp(yourApp)
| reactor.run()
Then use twisted.internet APIs as usual. Stop the event loop using
reactor.stop(), not yourApp.ExitMainLoop().
IMPORTANT: tests will fail when run under this reactor. This is
expected and probably does not reflect on the reactor's ability to run
real applications.
� )�Empty�Queue)�App� CallAfter�Timer)�wxApp�wxCallAfter�wxTimer)�log�runtime)�_threadedselectc @ s e Zd ZdZdd� Zdd� ZdS )�ProcessEventsTimerz�
Timer that tells wx to process pending events.
This is necessary on macOS, probably due to a bug in wx, if we want
wxCallAfters to be handled when modal dialogs, menus, etc. are open.
c C s t �| � || _d S �N)r �__init__�wxapp��selfr � r �</usr/lib/python3/dist-packages/twisted/internet/wxreactor.pyr 1 s
zProcessEventsTimer.__init__c C s | j �� dS )z5
Called repeatedly by wx event loop.
N)r �ProcessPendingEvents�r r r r �Notify6 s zProcessEventsTimer.NotifyN)�__name__�
__module__�__qualname__�__doc__r r r r r r r
* s r
c @ sF e Zd ZdZdZdd� Zdd� Zdd� Zd d
� Zdd� Z ddd�Z
dS )� WxReactorz[
wxPython reactor.
wxPython drives the event loop, select() runs in a thread.
Fc C s
|| _ dS )z;
Register wxApp instance with the reactor.
N)r r r r r �
registerWxAppG s zWxReactor.registerWxAppc C s@ zddl }|� |j|j� W n tk
r2 Y dS X | �� dS )zO
wx sometimes removes our own signal handlers, so re-add them.
r N)�signal�SIGINT�default_int_handler�ImportErrorZ_handleSignals)r r r r r �_installSignalHandlersAgainN s z%WxReactor._installSignalHandlersAgainc C s | j r
dS d| _ tj�| � dS )z#
Stop the reactor.
NT)� _stoppingr �ThreadedSelectReactor�stopr r r r r% [ s zWxReactor.stopc C s$ t | d�rt|� n| j�|� dS )zm
Schedule function to run in main wx/Twisted thread.
Called by the select() thread.
r N)�hasattrr �
_postQueue�put)r �fr r r �_runInMainThreade s
zWxReactor._runInMainThreadc C s t | d�r| j�� dS )z
Stop the wx event loop if it hasn't already been stopped.
Called during Twisted event loop shutdown.
r N)r&