§
    Ètºf•  ã                   óÆ   — d Z ddlmZmZ 	 ddlmZmZm	Z
 n# e$ r ddlmZmZm
Z
 Y nw xY wddlmZ ddlmZmZ  G d„ de
¦  «        Z G d	„ d
ej        ¦  «        Zd„ ZdgZd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)Ú	CallAfterÚPySimpleAppÚTimer)ÚwxPySimpleAppÚwxCallAfterÚwxTimer)Ú_threadedselect)ÚlogÚruntimec                   ó   — e Zd ZdZd„ Zd„ ZdS )Ú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                 ó<   — t          j        | ¦  «         || _        d S ©N)r
   Ú__init__Úwxapp©Úselfr   s     úY/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/twisted/internet/wxreactor.pyr   zProcessEventsTimer.__init__2   s   € ÝÔ˜ÑÔÐØˆŒ
ˆ
ˆ
ó    c                 ó8   — | j                              ¦   «          dS )z5
        Called repeatedly by wx event loop.
        N)r   ÚProcessPendingEvents©r   s    r   ÚNotifyzProcessEventsTimer.Notify6   s   € ð 	Œ
×'Ò'Ñ)Ô)Ð)Ð)Ð)r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   © r   r   r   r   *   s<   € € € € € ðð ðð ð ð*ð *ð *ð *ð *r   r   c                   ó<   — e Zd ZdZdZd„ Zd„ Zd„ Zd„ Zd„ Z	dd	„Z
d
S )Ú	WxReactorz[
    wxPython reactor.

    wxPython drives the event loop, select() runs in a thread.
    Fc                 ó   — || _         dS )z;
        Register wxApp instance with the reactor.
        N)r   r   s     r   ÚregisterWxAppzWxReactor.registerWxAppF   s   € ð ˆŒ
ˆ
ˆ
r   c                 ó¦   — 	 ddl }|                      |j        |j        ¦  «         n# t          $ r Y dS w xY w| j                             ¦   «          dS )zO
        wx sometimes removes our own signal handlers, so re-add them.
        r   N)ÚsignalÚSIGINTÚdefault_int_handlerÚImportErrorÚ_signalsÚinstall)r   r&   s     r   Ú_installSignalHandlersAgainz%WxReactor._installSignalHandlersAgainL   sh   € ð	àˆMˆMˆMà�MŠM˜&œ-¨Ô)CÑDÔDÐDÐDøÝð 	ð 	ð 	ØˆFˆFð	øøøàŒ×ÒÑÔÐÐÐs   ‚$' §
5´5c                 ód   — | j         rdS d| _         t          j                             | ¦  «         dS )z#
        Stop the reactor.
        NT)Ú	_stoppingr   ÚThreadedSelectReactorÚstopr   s    r   r0   zWxReactor.stopY   s7   € ð Œ>ð 	ØˆFØˆŒÝÔ-×2Ò2°4Ñ8Ô8Ð8Ð8Ð8r   c                 ó|   — t          | d¦  «        rt          |¦  «         dS | j                             |¦  «         dS )zm
        Schedule function to run in main wx/Twisted thread.

        Called by the select() thread.
        r   N)Úhasattrr	   Ú
_postQueueÚput)r   Úfs     r   Ú_runInMainThreadzWxReactor._runInMainThreadb   sC   € õ �4˜Ñ!Ô!ð 	#Ý˜‰NŒNˆNˆNˆNð ŒO×Ò Ñ"Ô"Ð"Ð"Ð"r   c                 ó\   — t          | d¦  «        r| j                             ¦   «          dS dS )z
        Stop the wx event loop if it hasn't already been stopped.

        Called during Twisted event loop shutdown.
        r   N)r2   r   ÚExitMainLoopr   s    r   Ú_stopWxzWxReactor._stopWxn   s:   € õ �4˜Ñ!Ô!ð 	&ØŒJ×#Ò#Ñ%Ô%Ð%Ð%Ð%ð	&ð 	&r   Tc                 óˆ  ‡ — t          ¦   «         ‰ _        t          ‰ d¦  «        s5t          j        d¦  «         ‰                      t          ¦   «         ¦  «         ‰                      ‰ j        |¬¦  «         |r‰  	                    d‰ j
        ¦  «         ‰                      dd‰ j        ¦  «         ‰                      ddˆ fd„¦  «         t          j                             ¦   «         r)t!          ‰ j        ¦  «        }|                     d¦  «         ‰ j                             ¦   «          ‰ j        }‰ `‰ j        s‰‰                      ¦   «          |                     ¦   «          	 	 ‰ j                             d
¬¦  «        }|€dS 	  |¦   «          n3# t0          $ r t          j        ¦   «          Y nw xY w# t4          $ r Y Œ\w xY wŒ`dS )z$
        Start the reactor.
        r   zMregisterWxApp() was not called on reactor, registering my own wxApp instance.)ÚinstallSignalHandlersr   ÚafterÚshutdownc                  ó8   •— ‰ j                              d ¦  «        S r   )r3   r4   r   s   €r   ú<lambda>zWxReactor.run.<locals>.<lambda>�   s   ø€ ¨¬×)<Ò)<¸TÑ)BÔ)B€ r   é   é   g{®Gáz„?)ÚtimeoutN)r   r3   r2   r   Úmsgr$   r   Ú
interleaver6   Ú	callLaterr,   ÚaddSystemEventTriggerr9   r   ÚplatformÚisMacOSXr   r   ÚStartÚMainLoopr.   r0   r   ÚgetÚBaseExceptionÚerrr   )r   r;   Útr   r5   s   `    r   ÚrunzWxReactor.runw   sÿ  ø€ õ  ™'œ'ˆŒÝ�t˜WÑ%Ô%ð 	0ÝŒGð5ñô ð ð ×Ò�}™œÑ/Ô/Ð/ð 	�ŠØÔ!Ð9Nð 	ñ 	
ô 	
ð 	
ð !ð 	@Ø�NŠN˜1˜dÔ>Ñ?Ô?Ð?ð 	×"Ò" 7¨J¸¼ÑEÔEÐEØ×"Ò"Ø�ZÐ!BÐ!BÐ!BÐ!Bñ	
ô 	
ð 	
õ Ô×$Ò$Ñ&Ô&ð 	Ý" 4¤:Ñ.Ô.ˆAØ�GŠG�A‰JŒJˆJàŒ
×ÒÑÔÐØ”
ˆØˆJàŒ~ð 	"ð �IŠI‰KŒKˆKØ×&Ò&Ñ(Ô(Ð(ð"ð
"Øœ×+Ò+°DÐ+Ñ9Ô9�Að �yØ˜ð"Ø˜™œ˜˜øÝ(ð "ð "ð "Ýœ™	œ	˜	˜	˜	ð"øøøøõ ð ð ð Ø�Hðøøøð"ð	"ð 	"s$   Å#F1 Æ
F ÆF.Æ-F.Æ1
F>Æ=F>N)T)r   r   r   r   r.   r$   r,   r0   r6   r9   rO   r    r   r   r"   r"   =   s„   € € € € € ðð ð €Iðð ð ð ð  ð  ð9ð 9ð 9ð
#ð 
#ð 
#ð&ð &ð &ð7"ð 7"ð 7"ð 7"ð 7"ð 7"r   r"   c                  óD   — t          ¦   «         } ddlm}  || ¦  «         | S )zP
    Configure the twisted mainloop to be run inside the wxPython mainloop.
    r   )ÚinstallReactor)r"   Útwisted.internet.mainrQ   )ÚreactorrQ   s     r   r+   r+   ±   s4   € õ ‰kŒk€GØ4Ð4Ð4Ð4Ð4Ð4à€N�7ÑÔÐØ€Nr   r+   N)r   Úqueuer   r   Úwxr   r	   r   r   r   r
   r)   ÚwxPython.wxÚtwisted.internetr   Útwisted.pythonr   r   r   r/   r"   r+   Ú__all__r    r   r   ú<module>rZ      sS  ððð ð, Ð Ð Ð Ð Ð Ð Ð ð@ðð ð ð ð ð ð ð ð ð ð øð
 ð @ð @ð @à?Ð?Ð?Ð?Ð?Ð?Ð?Ð?Ð?Ð?Ð?Ð?ð@øøøð -Ð ,Ð ,Ð ,Ð ,Ð ,Ø 'Ð 'Ð 'Ð 'Ð 'Ð 'Ð 'Ð 'ð*ð *ð *ð *ð *˜ñ *ô *ð *ð&q"ð q"ð q"ð q"ð q"�Ô5ñ q"ô q"ð q"ðhð ð ð ˆ+€€€s   Œ
 —)¨)