home *** CD-ROM | disk | FTP | other *** search
/ Hackers Magazine 57 / CdHackersMagazineNr57.iso / Software / Multimedia / k3d-setup-0.7.11.0.exe / lib / site-packages / gtk-2.0 / gtk / __init__.py next >
Encoding:
Python Source  |  2007-11-01  |  4.9 KB  |  143 lines

  1. # -*- Mode: Python; py-indent-offset: 4 -*-
  2. # pygtk - Python bindings for the GTK toolkit.
  3. # Copyright (C) 1998-2003  James Henstridge
  4. #               2004-2006  Johan Dahlin
  5. #
  6. #   gtk/__init__.py: initialisation file for gtk package.
  7. #
  8. # This library is free software; you can redistribute it and/or
  9. # modify it under the terms of the GNU Lesser General Public
  10. # License as published by the Free Software Foundation; either
  11. # version 2.1 of the License, or (at your option) any later version.
  12. #
  13. # This library is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16. # Lesser General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU Lesser General Public
  19. # License along with this library; if not, write to the Free Software
  20. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  21. # USA
  22.  
  23. import sys
  24.  
  25. # this can go when things are a little further along
  26. try:
  27.     import ltihooks
  28.     # pyflakes
  29.     ltihooks
  30. except ImportError:
  31.     ltihooks = None
  32.  
  33. # For broken embedded programs which forgot to call Sys_SetArgv
  34. if not hasattr(sys, 'argv'):
  35.     sys.argv = []
  36.  
  37. # load the required modules:
  38. import gobject as _gobject
  39.  
  40. ver = getattr(_gobject, 'pygobject_version', ())
  41. if ver < (2, 11, 1):
  42.     raise ImportError(
  43.         "PyGTK requires PyGObject 2.11.1 or higher, but %s was found" % (ver,))
  44.  
  45. if 'gtk._gtk' in sys.modules:
  46.     _gtk = sys.modules['gtk._gtk']
  47. else:
  48.     from gtk import _gtk
  49.  
  50. import gdk
  51.  
  52. if ltihooks:
  53.     try:
  54.         ltihooks.uninstall()
  55.         del ltihooks
  56.     except:
  57.         pass
  58.  
  59. from gtk._lazyutils import LazyNamespace, LazyModule
  60. from gtk.deprecation import _Deprecated, _DeprecatedConstant
  61.  
  62. def _init():
  63.     import sys
  64.  
  65.     try:
  66.         sys_path = sys.path[:]
  67.  
  68.         try:
  69.             _gtk.init_check()
  70.         except RuntimeError, e:
  71.             import warnings
  72.             warnings.warn(str(e), _gtk.Warning)
  73.     finally:
  74.         # init_check calls PySys_SetArgv which calls sys.path.insert(0, ''),
  75.         # which causes problems for pychecker, restore it if modified.
  76.         if sys.path != sys_path:
  77.             sys.path[:] = sys_path
  78.  
  79.     # install the default log handlers
  80.     _gtk.add_log_handlers()
  81.  
  82. keysyms = LazyModule('keysyms', locals())
  83.  
  84. _init()
  85.  
  86. # CAPI
  87. _PyGtk_API = _gtk._PyGtk_API
  88.  
  89. gdk.INPUT_READ      = _gobject.IO_IN | _gobject.IO_HUP | _gobject.IO_ERR
  90. gdk.INPUT_WRITE     = _gobject.IO_OUT | _gobject.IO_HUP
  91. gdk.INPUT_EXCEPTION = _gobject.IO_PRI
  92.  
  93. # old names compatibility ...
  94. idle_add       = _Deprecated(_gobject, 'idle_add', 'idle_add', 'gobject')
  95. idle_remove    = _Deprecated(_gobject, 'source_remove', 'idle_remove', 'gobject')
  96. timeout_add    = _Deprecated(_gobject, 'timeout_add', 'timeout_add', 'gobject')
  97. timeout_remove = _Deprecated(_gobject, 'source_remove', 'timeout_remove',
  98.                              'gobject')
  99. input_add      = _Deprecated(_gobject, 'io_add_watch', 'input_add', 'gobject')
  100. input_add_full = _Deprecated(_gobject, 'io_add_watch', 'input_add_full',
  101.                              'gobject')
  102. input_remove   = _Deprecated(_gobject, 'source_remove', 'input_remove', 'gobject')
  103.  
  104. mainloop                 = _Deprecated('gtk', 'main', 'mainloop')
  105. mainquit                 = _Deprecated('gtk', 'main_quit', 'mainquit')
  106. mainiteration            = _Deprecated('gtk', 'main_iteration',
  107.                                        'mainiteration')
  108. load_font                = _Deprecated(gdk, 'Font', 'load_font', 'gtk.gdk')
  109. load_fontset             = _Deprecated(gdk, 'fontset_load', 'load_fontset',
  110.                                        'gtk.gdk')
  111. create_pixmap            = _Deprecated(gdk, 'Pixmap', 'create_pixmap', 'gtk.gdk')
  112. create_pixmap_from_xpm   = _Deprecated(gdk, 'pixmap_create_from_xpm',
  113.                                        'pixmap_create_from_xpm', 'gtk.gdk')
  114. create_pixmap_from_xpm_d = _Deprecated(gdk, 'pixmap_create_from_xpm_d',
  115.                                        'pixmap_create_from_xpm_d', 'gtk.gdk')
  116.  
  117. threads_init = _Deprecated(gdk, 'threads_init', 'threads_init', 'gtk.gdk')
  118. threads_enter = _Deprecated(gdk, 'threads_enter', 'threads_enter', 'gtk.gdk')
  119. threads_leave = _Deprecated(gdk, 'threads_leave', 'threads_leave', 'gtk.gdk')
  120.  
  121. TRUE = _DeprecatedConstant(True, 'gtk.TRUE', 'True')
  122. FALSE = _DeprecatedConstant(False, 'gtk.FALSE', 'False')
  123.  
  124. # Can't figure out how to deprecate gdk.Warning
  125. gdk.Warning = Warning
  126.  
  127. # We don't want to export this
  128. del _Deprecated, _DeprecatedConstant, _gobject, _init
  129.  
  130. # Do this as late as possible, so programs like pyflakes can check
  131. # everything above
  132. from gtk._gtk import *
  133.  
  134. # # For testing, so you can just turn of dynamicnamespace in gtk.override
  135. # if hasattr(_gtk, '_get_symbol_names'):
  136. #     import gtk
  137. #     ns = LazyNamespace(_gtk, locals())
  138. #     ns.add_submodule('glade', '_glade')
  139. #     ns.add_submodule('_gtk', 'gtk._gtk')
  140. #     sys.modules['gtk'] = ns
  141. #     sys.modules['gtk.glade'] = LazyModule('_glade', {})
  142.  
  143.