pygtk: use new test DSL
This commit is contained in:
parent
b598da2831
commit
8c673861d4
1 changed files with 34 additions and 36 deletions
|
@ -38,47 +38,45 @@ class Pygtk < Formula
|
|||
"python" + `python -c 'import sys;print(sys.version[:3])'`.strip
|
||||
end
|
||||
|
||||
def test
|
||||
mktemp do
|
||||
(Pathname.pwd+'test.py').write <<-EOS.undent
|
||||
#!/usr/bin/env python
|
||||
import pygtk
|
||||
pygtk.require('2.0')
|
||||
import gtk
|
||||
test do
|
||||
(testpath/'test.py').write <<-EOS.undent
|
||||
#!/usr/bin/env python
|
||||
import pygtk
|
||||
pygtk.require('2.0')
|
||||
import gtk
|
||||
|
||||
class HelloWorld(object):
|
||||
def hello(self, widget, data=None):
|
||||
print "Hello World"
|
||||
class HelloWorld(object):
|
||||
def hello(self, widget, data=None):
|
||||
print "Hello World"
|
||||
|
||||
def delete_event(self, widget, event, data=None):
|
||||
print "delete event occurred"
|
||||
return False
|
||||
def delete_event(self, widget, event, data=None):
|
||||
print "delete event occurred"
|
||||
return False
|
||||
|
||||
def destroy(self, widget, data=None):
|
||||
print "destroy signal occurred"
|
||||
gtk.main_quit()
|
||||
def destroy(self, widget, data=None):
|
||||
print "destroy signal occurred"
|
||||
gtk.main_quit()
|
||||
|
||||
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()
|
||||
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()
|
||||
|
||||
def main(self):
|
||||
gtk.main()
|
||||
def main(self):
|
||||
gtk.main()
|
||||
|
||||
if __name__ == "__main__":
|
||||
hello = HelloWorld()
|
||||
hello.main()
|
||||
EOS
|
||||
system "chmod +x test.py"
|
||||
system "./test.py"
|
||||
end
|
||||
if __name__ == "__main__":
|
||||
hello = HelloWorld()
|
||||
hello.main()
|
||||
EOS
|
||||
chmod '+x', 'test.py'
|
||||
system "./test.py"
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue