Format: application/x-python-code
⬇ Download File (2.8 KB)
   1  o
   2  
   3  �h
   4  �@sFdZddlZddlZddlZddlZejdedd�Gdd�d�ZdS)zAGUI support for the IPython ZeroMQ kernel - GTK toolkit support.
   5  �Nz/The Gtk3 event loop for ipykernel is deprecated�)�category�
   6  stacklevelc@s@eZdZdZdd�Zdd�Zdd�Zdd	�Zd
   7  d�Zdd
   8  �Z	dS)�GTKEmbedz7A class to embed a kernel into the GTK main event loop.cCs||_d|_d|_dS)zInitialize the embed.N)�kernel�gtk_main�
   9  gtk_main_quit)�selfr�r
  10  �Lc:\Users\shubh\Videos\agent\nova\Lib\site-packages\ipykernel/gui/gtkembed.py�__init__!s
  11  zGTKEmbed.__init__cCst�|j�t��dS)zCStarts the GTK main event loop and sets our kernel startup routine.N)�gobjectZidle_add�_wire_kernel�gtk�main�r	r
  12  r
  13  r�start(szGTKEmbed.startcCs.|��\|_|_t�td|jj�|j�dS)z�Initializes the kernel inside GTK.
  14  
  15          This is meant to run only once at startup, so it does its job and
  16          returns False to ensure it doesn't get run again by GTK.
  17          i�F)	�_hijack_gtkrrr
  18  Ztimeout_add�intrZ_poll_interval�iterate_kernelrr
  19  r
  20  rr.szGTKEmbed._wire_kernelcCs|j��dS)z�Run one iteration of the kernel and return True.
  21  
  22          GTK timer functions must return True to be called again, so we make the
  23          call to :meth:`do_one_iteration` and then return True for GTK.
  24          T)rZdo_one_iterationrr
  25  r
  26  rr8s
  27  zGTKEmbed.iterate_kernelcCs|jr|��t��dS)zStop the embed.N)r�sys�exitrr
  28  r
  29  r�stopAsz
  30  GTKEmbed.stopcCs,dd�}tj|}t_tj|}t_||fS)a�Hijack a few key functions in GTK for IPython integration.
  31  
  32          Modifies pyGTK's main and main_quit with a dummy so user code does not
  33          block IPython.  This allows us to use %run to run arbitrary pygtk
  34          scripts from a long-lived IPython session, and when they attempt to
  35          start or stop
  36  
  37          Returns
  38          -------
  39          The original functions that have been hijacked:
  40          - gtk.main
  41          - gtk.main_quit
  42          c_sdS)zNo-op.Nr
  43  )�args�kwr
  44  r
  45  r�dummyYsz#GTKEmbed._hijack_gtk.<locals>.dummy)rrZ	main_quit)r	rZ	orig_mainZorig_main_quitr
  46  r
  47  rrJszGTKEmbed._hijack_gtkN)
  48  �__name__�
  49  __module__�__qualname__�__doc__rrrrrrr
  50  r
  51  r
  52  rrs
  53  		r)rr�warningsr
  54  r�warn�DeprecationWarningrr
  55  r
  56  r
  57  r�<module>s
  58  �