Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import c4d
- import draw
- DATA = [ 'I am the first row.',
- 'And I am the second one.',
- 'Some data here ..',
- '.. some data there.' ]
- class Source(draw.ListViewSource):
- def getCount(self):
- # return the number of sections in the list
- return len(DATA)
- def getSection(self, master, index):
- # return a section that is shown in the list
- title = DATA[index]
- return ListSection(master, index, title)
- class ListSection(draw.ListViewSection):
- def __init__(self, master, index, title):
- super(ListSection, self).__init__(master)
- # set the background color
- if not index % 2:
- self.color = [.34, .34, .34]
- else:
- self.color = [.38, .38, .38]
- # create the text-label
- label = draw.Label(master, text = title, x = 10, y = 0.5,
- absX = True, alignV = draw.ALIGN_V_CENTER,
- fgColor = [.85, .85, .85])
- self.label = label
- self.addChild(label)
- def main():
- master = draw.Master()
- area = draw.C4dDrawArea(master)
- area.minSize = 250, 120
- source = Source()
- listview= draw.ListView(master, source, x = 0, y = 0, w = 1, h = 1,
- absX = False, absY = False, absW = False, absH = False)
- listview.reloadData()
- area.addChild(listview)
- dlg = draw.C4dQuickDialog('My Listview', area)
- dlg.Open()
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement