PageRenderTime 25ms CodeModel.GetById 34ms RepoModel.GetById 0ms app.codeStats 0ms

/Library/Formula/pygtk.rb

https://github.com/aaroncm/homebrew
Ruby | 79 lines | 65 code | 13 blank | 1 comment | 3 complexity | eceff6af66c2e730371de2f71725c77a MD5 | raw file
  1. require 'formula'
  2. class Pygtk < Formula
  3. url 'http://ftp.acc.umu.se/pub/GNOME/sources/pygtk/2.24/pygtk-2.24.0.tar.bz2'
  4. homepage 'http://www.pygtk.org/'
  5. md5 'a1051d5794fd7696d3c1af6422d17a49'
  6. depends_on :x11
  7. depends_on 'glib'
  8. depends_on 'gtk+'
  9. depends_on 'pygobject'
  10. depends_on 'py2cairo'
  11. def options
  12. [["--universal", "Builds a universal binary"]]
  13. end
  14. def install
  15. ENV.append 'CFLAGS', '-ObjC'
  16. ENV.universal_binary if ARGV.build_universal?
  17. system "./configure", "--disable-dependency-tracking",
  18. "--prefix=#{prefix}"
  19. system "make install"
  20. end
  21. def caveats; <<-EOS.undent
  22. For non-Homebrew Python, you need to amend your PYTHONPATH like so:
  23. export PYTHONPATH=#{HOMEBREW_PREFIX}/lib/#{which_python}/site-packages:$PYTHONPATH
  24. EOS
  25. end
  26. def which_python
  27. "python" + `python -c 'import sys;print(sys.version[:3])'`.strip
  28. end
  29. def test
  30. mktemp do
  31. (Pathname.pwd+'test.py').write <<-EOS.undent
  32. #!/usr/bin/env python
  33. import pygtk
  34. pygtk.require('2.0')
  35. import gtk
  36. class HelloWorld(object):
  37. def hello(self, widget, data=None):
  38. print "Hello World"
  39. def delete_event(self, widget, event, data=None):
  40. print "delete event occurred"
  41. return False
  42. def destroy(self, widget, data=None):
  43. print "destroy signal occurred"
  44. gtk.main_quit()
  45. def __init__(self):
  46. self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
  47. self.window.connect("delete_event", self.delete_event)
  48. self.window.connect("destroy", self.destroy)
  49. self.window.set_border_width(10)
  50. self.button = gtk.Button("Hello World")
  51. self.button.connect("clicked", self.hello, None)
  52. self.button.connect_object("clicked", gtk.Widget.destroy, self.window)
  53. self.window.add(self.button)
  54. self.button.show()
  55. self.window.show()
  56. def main(self):
  57. gtk.main()
  58. if __name__ == "__main__":
  59. hello = HelloWorld()
  60. hello.main()
  61. EOS
  62. system "chmod +x test.py"
  63. system "./test.py"
  64. end
  65. end
  66. end