Format: application/x-python-code
⬇ Download File (2.9 KB)
   1  o
   2  
   3  �hi
   4  �@sfdZddlZddlZddlZe�dd�e�dd�ddlmZmZejde	dd	�Gd
   5  d�d�Z
   6  dS)zAGUI support for the IPython ZeroMQ kernel - GTK toolkit support.
   7  �NZGdkz3.0�Gtk)�GObjectrz/The Gtk3 event loop for ipykernel is deprecated�)�category�
   8  stacklevelc@s@eZdZdZdd�Zdd�Zdd�Zdd	�Zd
   9  d�Zdd
  10  �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�
  11  gtk_main_quit)�selfr�r�Mc:\Users\shubh\Videos\agent\nova\Lib\site-packages\ipykernel/gui/gtk3embed.py�__init__$s
  12  zGTKEmbed.__init__cCst�|j�t��dS)zCStarts the GTK main event loop and sets our kernel startup routine.N)rZidle_add�_wire_kernelr�main�rrrr
  13  �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_gtkr	r
  18  rZtimeout_add�intrZ_poll_interval�iterate_kernelrrrr
  19  r1szGTKEmbed._wire_kernelcCs|j��dS)z�Run one iteration of the kernel and return True.
  20  
  21          GTK timer functions must return True to be called again, so we make the
  22          call to :meth:`do_one_iteration` and then return True for GTK.
  23          T)rZdo_one_iterationrrrr
  24  r;s
  25  zGTKEmbed.iterate_kernelcCs|jr|��t��dS)zStop the embed.N)r
  26  �sys�exitrrrr
  27  �stopDsz
  28  GTKEmbed.stopcCs,dd�}tj|}t_tj|}t_||fS)a�Hijack a few key functions in GTK for IPython integration.
  29  
  30          Modifies pyGTK's main and main_quit with a dummy so user code does not
  31          block IPython.  This allows us to use %run to run arbitrary pygtk
  32          scripts from a long-lived IPython session, and when they attempt to
  33          start or stop
  34  
  35          Returns
  36          -------
  37          The original functions that have been hijacked:
  38          - Gtk.main
  39          - Gtk.main_quit
  40          c_sdS)zNo-op.Nr)�args�kwrrr
  41  �dummy\sz#GTKEmbed._hijack_gtk.<locals>.dummy)rrZ	main_quit)rrZ	orig_mainZorig_main_quitrrr
  42  rMszGTKEmbed._hijack_gtkN)
  43  �__name__�
  44  __module__�__qualname__�__doc__rrrrrrrrrr
  45  r!s
  46  		r)rr�warnings�giZrequire_versionZ
  47  gi.repositoryrr�warn�DeprecationWarningrrrrr
  48  �<module>s
  49  �