2011-12-19 17:49:29 +00:00
|
|
|
require 'formula'
|
|
|
|
|
|
|
|
class Pygtk < Formula
|
|
|
|
homepage 'http://www.pygtk.org/'
|
2013-01-29 03:44:21 +00:00
|
|
|
url 'http://ftp.acc.umu.se/pub/GNOME/sources/pygtk/2.24/pygtk-2.24.0.tar.bz2'
|
2012-09-03 18:33:56 +00:00
|
|
|
sha1 '344e6a32a5e8c7e0aaeb807e0636a163095231c2'
|
2011-12-19 17:49:29 +00:00
|
|
|
|
2012-07-07 04:45:40 +00:00
|
|
|
depends_on :x11
|
2011-12-19 17:49:29 +00:00
|
|
|
depends_on 'glib'
|
|
|
|
depends_on 'gtk+'
|
|
|
|
depends_on 'pygobject'
|
|
|
|
depends_on 'py2cairo'
|
2012-12-04 16:41:03 +00:00
|
|
|
depends_on 'libglade' if build.include? 'glade'
|
2011-12-19 17:49:29 +00:00
|
|
|
|
2012-08-12 17:59:20 +00:00
|
|
|
option :universal
|
2012-12-05 08:59:17 +00:00
|
|
|
option 'glade', 'Python bindigs for glade. (to `import gtk.glade`)'
|
2011-12-19 17:49:29 +00:00
|
|
|
|
|
|
|
def install
|
|
|
|
ENV.append 'CFLAGS', '-ObjC'
|
2012-08-12 17:59:20 +00:00
|
|
|
ENV.universal_binary if build.universal?
|
2011-12-19 17:49:29 +00:00
|
|
|
system "./configure", "--disable-dependency-tracking",
|
|
|
|
"--prefix=#{prefix}"
|
|
|
|
system "make install"
|
2012-12-05 08:59:17 +00:00
|
|
|
|
|
|
|
# Fixing the pkgconfig file to find codegen, because it was moved from
|
|
|
|
# pygtk to pygobject. But our pkgfiles point into the cellar and in the
|
|
|
|
# pygtk-cellar there is no pygobject.
|
|
|
|
inreplace lib/'pkgconfig/pygtk-2.0.pc', 'codegendir=${datadir}/pygobject/2.0/codegen', "codegendir=#{HOMEBREW_PREFIX}/share/pygobject/2.0/codegen"
|
2011-12-19 17:49:29 +00:00
|
|
|
end
|
|
|
|
|
2012-05-17 00:55:06 +00:00
|
|
|
def caveats; <<-EOS.undent
|
|
|
|
For non-Homebrew Python, you need to amend your PYTHONPATH like so:
|
|
|
|
export PYTHONPATH=#{HOMEBREW_PREFIX}/lib/#{which_python}/site-packages:$PYTHONPATH
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
|
|
|
def which_python
|
|
|
|
"python" + `python -c 'import sys;print(sys.version[:3])'`.strip
|
|
|
|
end
|
|
|
|
|
2013-01-07 03:23:33 +00:00
|
|
|
test do
|
|
|
|
(testpath/'test.py').write <<-EOS.undent
|
|
|
|
#!/usr/bin/env python
|
|
|
|
import pygtk
|
|
|
|
pygtk.require('2.0')
|
|
|
|
import gtk
|
2011-12-19 17:49:29 +00:00
|
|
|
|
2013-01-07 03:23:33 +00:00
|
|
|
class HelloWorld(object):
|
|
|
|
def hello(self, widget, data=None):
|
|
|
|
print "Hello World"
|
2011-12-19 17:49:29 +00:00
|
|
|
|
2013-01-07 03:23:33 +00:00
|
|
|
def delete_event(self, widget, event, data=None):
|
|
|
|
print "delete event occurred"
|
|
|
|
return False
|
2011-12-19 17:49:29 +00:00
|
|
|
|
2013-01-07 03:23:33 +00:00
|
|
|
def destroy(self, widget, data=None):
|
|
|
|
print "destroy signal occurred"
|
|
|
|
gtk.main_quit()
|
2011-12-19 17:49:29 +00:00
|
|
|
|
2013-01-07 03:23:33 +00:00
|
|
|
def __init__(self):
|
|
|
|
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
|
|
|
|
self.window.connect("delete_event", self.delete_event)
|
|
|
|
self.window.connect("destroy", self.destroy)
|
|
|
|
self.window.set_border_width(10)
|
|
|
|
self.button = gtk.Button("Hello World")
|
|
|
|
self.button.connect("clicked", self.hello, None)
|
|
|
|
self.button.connect_object("clicked", gtk.Widget.destroy, self.window)
|
|
|
|
self.window.add(self.button)
|
|
|
|
self.button.show()
|
|
|
|
self.window.show()
|
2011-12-19 17:49:29 +00:00
|
|
|
|
2013-01-07 03:23:33 +00:00
|
|
|
def main(self):
|
|
|
|
gtk.main()
|
2011-12-19 17:49:29 +00:00
|
|
|
|
2013-01-07 03:23:33 +00:00
|
|
|
if __name__ == "__main__":
|
|
|
|
hello = HelloWorld()
|
|
|
|
hello.main()
|
|
|
|
EOS
|
|
|
|
chmod '+x', 'test.py'
|
|
|
|
system "./test.py"
|
2011-12-19 17:49:29 +00:00
|
|
|
end
|
|
|
|
end
|