How to use the etk.ListModel function in etk

To help you get started, we’ve selected a few etk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kakaroto / e17 / OLD / BINDINGS / python / python-etk / examples / 15-list.py View on Github external
def create_cell(self, canvas):
        return canvas.Rectangle()

    def update_cell(self, cell, row):
        cell.color = (0, 0, row[self.slot], 255)

    def show_cell(self, cell, x, y, w, h):
        cell.resize(w - 22, h - 30)
        cell.move(x + 10, y + 15)
        cell.show()


def button_clicked(row, msg=None, *a, **ka):
    print "%s - %s" % (row[3], msg)

model = etk.ListModel()
model2 = etk.ListModel()


#lst.freeze()
for i in range(1000):
    model.append(["person #%d" % i, ((i+1) * 27) % 256, ((i+1) * 78) % 256,
                 ((i+1) * 101) % 256, "person #%d" % i, i % 2])
#lst.thaw()


lst = etk.List(model=model, selectable=True, animated_changes=True,
               columns=[
        (100, RectRenderer(slot=1), False),
        (100, etk.TextRenderer(slot=2), False),
        (100, etk.ButtonRenderer(label="Edit", click=button_clicked,
                                 msg="test"), False),
github kakaroto / e17 / OLD / BINDINGS / python / python-etk / examples / 16-renderer.py View on Github external
next = (row[2] + 1) % 3
    print "I was in state %d and going to state %d" % (row[2], next)
    row[2] = next

def text_clicked(row):
    print "Clicked in item", row


mir = MyMultiImageRenderer(images=[("07-image/icon.png", None),
                                   ("07-image/icon2.png", None),
                                   ("07-image/icon3.png", None)],
                           state_slot=2, click=action)

ktr = etk.KineticTextRenderer(slot=1, click=text_clicked)

model = etk.ListModel()
lst = etk.List(model=model, selectable=False, animated_changes=False,
               row_height=150, columns=[
        #(100, ImageRenderer(file_slot=0), False),
        (200, ktr, True),
        (175, mir, False),
        ])

lst.freeze()
for i in range(50):
    model.append(["07-image/icon.png", "User #%d" % i, 0])
lst.thaw()

# Main
box = etk.VBox()

box.append(lst, etk.VBox.START, etk.VBox.EXPAND_FILL, 0)
github kakaroto / e17 / OLD / BINDINGS / python / python-etk / examples / 15-list.py View on Github external
return canvas.Rectangle()

    def update_cell(self, cell, row):
        cell.color = (0, 0, row[self.slot], 255)

    def show_cell(self, cell, x, y, w, h):
        cell.resize(w - 22, h - 30)
        cell.move(x + 10, y + 15)
        cell.show()


def button_clicked(row, msg=None, *a, **ka):
    print "%s - %s" % (row[3], msg)

model = etk.ListModel()
model2 = etk.ListModel()


#lst.freeze()
for i in range(1000):
    model.append(["person #%d" % i, ((i+1) * 27) % 256, ((i+1) * 78) % 256,
                 ((i+1) * 101) % 256, "person #%d" % i, i % 2])
#lst.thaw()


lst = etk.List(model=model, selectable=True, animated_changes=True,
               columns=[
        (100, RectRenderer(slot=1), False),
        (100, etk.TextRenderer(slot=2), False),
        (100, etk.ButtonRenderer(label="Edit", click=button_clicked,
                                 msg="test"), False),
        (100, etk.TextRenderer(slot=0), True),