
    h                         S r SSKJrJr   SSKJrJrJ	r
  SSKJr  SSKJrJr   " S S\
5      r " S	 S
\R&                  5      rS rS/rg! \ a    SSKJrJrJ
r
   NGf = f)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                   $    \ rS rSrSrS rS rSrg)ProcessEventsTimer*   z
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                 <    [         R                  " U 5        Xl        g N)r
   __init__wxappselfr   s     a/root/1688_scrapy/alibaba-scraper/venv/lib/python3.13/site-packages/twisted/internet/wxreactor.pyr   ProcessEventsTimer.__init__2   s    
    c                 8    U R                   R                  5         g)z%
Called repeatedly by wx event loop.
N)r   ProcessPendingEventsr   s    r   NotifyProcessEventsTimer.Notify6   s     	

'')r   r   N)__name__
__module____qualname____firstlineno____doc__r   r   __static_attributes__ r   r   r   r   *   s    *r   r   c                   D    \ rS rSrSrSrS rS rS rS r	S r
SS	 jrS
rg)	WxReactor=   zO
wxPython reactor.

wxPython drives the event loop, select() runs in a thread.
Fc                     Xl         g)z+
Register wxApp instance with the reactor.
Nr   r   s     r   registerWxAppWxReactor.registerWxAppF   s	     
r   c                      SSK nUR                  UR                  UR                  5        U R                  R                  5         g! [         a     gf = f)z?
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   _installSignalHandlersAgain%WxReactor._installSignalHandlersAgainL   sH    	MM&--)C)CD 	  		s   *A 
AAc                 t    U R                   (       a  gSU l         [        R                  R                  U 5        g)z
Stop the reactor.
NT)	_stoppingr   ThreadedSelectReactorstopr   s    r   r9   WxReactor.stopY   s)     >>--2248r   c                 t    [        U S5      (       a  [        U5        gU R                  R                  U5        g)zU
Schedule function to run in main wx/Twisted thread.

Called by the select() thread.
r   N)hasattrr	   
_postQueueput)r   fs     r   _runInMainThreadWxReactor._runInMainThreadb   s,     4!!N OO"r   c                 \    [        U S5      (       a  U R                  R                  5         gg)zg
Stop the wx event loop if it hasn't already been stopped.

Called during Twisted event loop shutdown.
r   N)r<   r   ExitMainLoopr   s    r   _stopWxWxReactor._stopWxn   s&     4!!JJ##% "r   c                   ^  [        5       T l        [        T S5      (       d/  [        R                  " S5        T R                  [        5       5        T R                  T R                  US9  U(       a  T R                  ST R                  5        T R                  SST R                  5        T R                  SSU 4S j5        [        R                  R                  5       (       a&  [!        T R"                  5      nUR%                  S5        T R"                  R'                  5         T R"                  nT ?T R(                  (       dI  T R+                  5         UR-                  5           T R                  R/                  S	S
9nUc  g U" 5         M(  g! [0         a    [        R2                  " 5          N$f = f! [4         a     M\  f = f)z
Start the reactor.
r   zMregisterWxApp() was not called on reactor, registering my own wxApp instance.)installSignalHandlersr   aftershutdownc                  :   > T R                   R                  S 5      $ r   )r=   r>   r   s   r   <lambda>WxReactor.run.<locals>.<lambda>   s    )<)<T)Br      g{Gz?)timeoutN)r   r=   r<   r   msgr+   r   
interleaver@   	callLaterr4   addSystemEventTriggerrD   r   platformisMacOSXr   r   StartMainLoopr7   r9   r   getBaseExceptionerrr   )r   rG   tr   r?   s   `    r   runWxReactor.runw   sz     'tW%%GG5 }/ 	!!9N 	 	
 !NN1d>>? 	""7JE""Z!B	
 $$&&"4::.AGGAJ



J~~ IIK&&(
"++D+9A y"  $ ) "	"  s$   &F3 F F0/F03
G G)r=   r7   r   N)T)r    r!   r"   r#   r$   r7   r+   r4   r9   r@   rD   r[   r%   r&   r   r   r(   r(   =   s,     I 9
#&7"r   r(   c                  6    [        5       n SSKJn  U" U 5        U $ )zH
Configure the twisted mainloop to be run inside the wxPython mainloop.
r   )installReactor)r(   twisted.internet.mainr^   )reactorr^   s     r   r3   r3      s     kG47Nr   r3   N)r$   queuer   r   wxr   r	   r   r   r   r
   r1   wxPython.wxtwisted.internetr   twisted.pythonr   r   r   r8   r(   r3   __all__r&   r   r   <module>rg      sp   , @  - '* *&q"55 q"h +u  @??@s   
A AA