PasteBin

Created By davea at 2008/03/04 23:51

https://sucs.org/pb/258 (plain)
  1.  
  2.   import objc
  3.   import _uicaboodle
  4.   from objc import YES, NO, NULL, nil
  5.   objc.loadBundle('UIKit', globals(), '/System/Library/Frameworks/UIKit.framework')
  6.   UIApplication = objc.lookUpClass('UIApplication')
  7.   UITable = objc.lookUpClass('UITable')
  8.   UIWindow = objc.lookUpClass('UIWindow')
  9.   UIHardware = objc.lookUpClass('UIHardware')
  10.   UIView = objc.lookUpClass('UIView')
  11.   UINavigationBar = objc.lookUpClass('UINavigationBar')
  12.   UINavigationItem = objc.lookUpClass('UINavigationItem')
  13.   UIPreferencesTable = objc.lookUpClass('UIPreferencesTable')
  14.   UIPreferencesTextTableCell = objc.lookUpClass('UIPreferencesTextTableCell')
  15.   UIPreferencesTableCell = objc.lookUpClass('UIPreferencesTableCell')
  16.   UISectionList = objc.lookUpClass("UISectionList")
  17.   UIImageAndTextTableCell = objc.lookUpClass("UIImageAndTextTableCell")
  18.  
  19.   class PYApplication(UIApplication):
  20.       def applicationDidFinishLaunching_(self, unused):
  21.           frame = UIHardware.fullScreenApplicationContentRect()
  22.  
  23.           self.window = UIWindow.alloc().initWithFrame_(frame)
  24.  
  25.           self.view = UIView.alloc().initWithFrame_(self.window.bounds())
  26.           self.window._.contentView = self.view
  27.  
  28.           self.window.orderFront_(self)
  29.           self.window.makeKey_(self)
  30.           self.window._setHidden_(NO)
  31.  
  32.           navsize = UINavigationBar.defaultSize()
  33.           navrect = ((0, 0), navsize)
  34.  
  35.           self.navbar = UINavigationBar.alloc().initWithFrame_(navrect)
  36.           self.view.addSubview_(self.navbar)
  37.  
  38.           self.navbar._.barStyle = 1
  39.           self.navbar._.delegate = self
  40.  
  41.           navitem = UINavigationItem.alloc().initWithTitle_(u"Network Information")
  42.           self.navbar.pushNavigationItem_(navitem)
  43.  
  44.           bounds = self.view.bounds()
  45.           tblrect = ((0, navsize[1]), (bounds[1][0], bounds[1][1] - navsize[1]))
  46.  
  47.           self.secList = UISectionList.alloc().initWithFrame_(tblrect)
  48.           self.secList._.dataSource = self
  49.           self.secList.reloadData()
  50.          
  51.           col = UITableColumn.alloc().initWithTitle_identifier_width_(u"Name", u"name", 320.0)
  52.           table = self.secList.table()
  53.           table._.separatorStyle = 1
  54.           table._.delegate = self
  55.           table.addTableColumn_(col)
  56.          
  57.           self.view.addSubview_(self.secList)
  58.      
  59.       @objc.signature("I@:@")
  60.       def numberOfSectionsInSectionList_(self, sectionList):
  61.           print u"numberOfSectionsInSectionList_", sectionList
  62.           return 3
  63.      
  64.       @objc.signature("@@:@I")
  65.       def sectionList_titleForSection_(self, sectionList, section):
  66.           print u"sectionList_titleForSection_", sectionList, section
  67.           return u"Section " + unicode(section)
  68.      
  69.       @objc.signature("I@:@I")
  70.       def sectionList_rowForSection_(self, sectionList, section):
  71.           print u"sectionList_rowForSection_", sectionList, section
  72.           return section
  73.      
  74.       @objc.signature("I@:@")   
  75.       def numberOfRowsInTable_(self, table):
  76.           print u"numberOfRowsInTable_", table
  77.           return 3
  78.      
  79.       @objc.signature("@@:@I@")
  80.       def table_cellForRow_column_(self, table, row, column):
  81.           print u"table_cellForRow_column_", table, row, column
  82.           cell = UIImageAndTextTableCell.alloc().init()
  83.           cell._.title = u"Test " + unicode(row)
  84.           return cell
  85.      
  86.       @objc.signature("B@:@I")
  87.       def table_canSelectRow_(self, table, row):
  88.           return NO
  89.      
  90.      
  91.       @objc.signature("B@::")
  92.       def respondsToSelector_(self, selector):
  93.           responds = dir(self).count(selector.replace(":", "_")) > 0
  94.           if not responds:
  95.               print selector
  96.           return responds
  97.  
  98.   _uicaboodle.UIApplicationMain(['NetInfo'], PYApplication)

You must be logged in to paste new items to the PasteBin