summaryrefslogtreecommitdiff
path: root/data/iphone-python/HelloPython.app/HelloPython.py
diff options
context:
space:
mode:
authorJay Freeman <saurik@saurik.com>2008-02-14 11:04:20 +0000
committerJay Freeman <saurik@saurik.com>2008-02-14 11:04:20 +0000
commit62882fc0471895bc1a47c13e22daf35dcaafecd0 (patch)
treec5fb76fc3f64e729fdabeb9c35774e722000fd4e /data/iphone-python/HelloPython.app/HelloPython.py
parent8e60af7ad00762fb8a89ae39c771287f3c5efed4 (diff)
Got PyObjC working.
git-svn-id: http://svn.telesphoreo.org/trunk@74 514c082c-b64e-11dc-b46d-3d985efe055d
Diffstat (limited to 'data/iphone-python/HelloPython.app/HelloPython.py')
-rw-r--r--data/iphone-python/HelloPython.app/HelloPython.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/data/iphone-python/HelloPython.app/HelloPython.py b/data/iphone-python/HelloPython.app/HelloPython.py
new file mode 100644
index 000000000..c78b141e6
--- /dev/null
+++ b/data/iphone-python/HelloPython.app/HelloPython.py
@@ -0,0 +1,42 @@
+import objc
+import _uicaboodle
+from objc import YES, NO
+objc.loadBundle('UIKit', globals(), '/System/Library/Frameworks/UIKit.framework')
+UIApplication = objc.lookUpClass('UIApplication')
+UITable = objc.lookUpClass('UITable')
+UIWindow = objc.lookUpClass('UIWindow')
+UIHardware = objc.lookUpClass('UIHardware')
+
+class PYApplication(UIApplication):
+ def applicationDidFinishLaunching_(self, unused):
+ frame = UIHardware.fullScreenApplicationContentRect()
+ self.window = UIWindow.alloc().initWithFrame_(frame)
+
+ self.view = UIView.alloc().initWithFrame_(self.window.bounds())
+ self.window.setContentView_(self.view)
+
+ self.window.orderFront_(self)
+ self.window.makeKey_(self)
+ self.window._setHidden_(NO)
+
+ navsize = UINavigationBar.defaultSize()
+ navrect = ((0, 0), navsize)
+
+ self.navbar = UINavigationBar.alloc().initWithFrame_(navrect);
+ self.view.addSubview_(self.navbar)
+
+ self.navbar.setBarStyle_(1)
+ self.navbar.setDelegate_(self)
+
+ navitem = UINavigationItem.alloc().initWithTitle_('Contacts')
+ self.navbar.pushNavigationItem_(navitem)
+
+ bounds = self.view.bounds()
+ tblrect = ((0, navsize[0]), (bounds[1][0] - navsize[0], bounds[1][1]))
+
+ self.table = UITable.alloc().initWithFrame_(tblrect)
+ self.view.addSubview_(self.table)
+
+ self.table.reloadData()
+
+_uicaboodle.UIApplicationMain(['HelloPython'], PYApplication)