Advertisement
nux95

draw-listview example 01

Dec 2nd, 2011
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.48 KB | None | 0 0
  1.  
  2. import c4d
  3. import draw
  4.  
  5. DATA = [ 'I am the first row.',
  6.          'And I am the second one.',
  7.          'Some data here ..',
  8.          '.. some data there.' ]
  9.  
  10. class Source(draw.ListViewSource):
  11.  
  12.     def getCount(self):
  13.         # return the number of sections in the list
  14.         return len(DATA)
  15.  
  16.     def getSection(self, master, index):
  17.         # return a section that is shown in the list
  18.         title = DATA[index]
  19.         return ListSection(master, index, title)
  20.  
  21. class ListSection(draw.ListViewSection):
  22.  
  23.     def __init__(self, master, index, title):
  24.         super(ListSection, self).__init__(master)
  25.  
  26.         # set the background color
  27.         if not index % 2:
  28.             self.color = [.34, .34, .34]
  29.         else:
  30.             self.color = [.38, .38, .38]
  31.  
  32.         # create the text-label
  33.         label = draw.Label(master, text = title, x = 10, y = 0.5,
  34.                            absX = True, alignV = draw.ALIGN_V_CENTER,
  35.                            fgColor = [.85, .85, .85])
  36.         self.label = label
  37.         self.addChild(label)
  38.  
  39. def main():
  40.     master  = draw.Master()
  41.     area    = draw.C4dDrawArea(master)
  42.     area.minSize = 250, 120
  43.  
  44.     source  = Source()
  45.     listview= draw.ListView(master, source, x = 0, y = 0, w = 1, h = 1,
  46.                             absX = False, absY = False, absW = False, absH = False)
  47.     listview.reloadData()
  48.     area.addChild(listview)
  49.  
  50.     dlg     = draw.C4dQuickDialog('My Listview', area)
  51.     dlg.Open()
  52.  
  53. main()
  54.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement