Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
w = etk.Window(title="Hello World", child=box)
w.on_destroyed(lambda x: etk.main_quit())
w.show_all()
etk.main()
counter += 1
x = etk.Button(label="Yet another button #%d" % counter)
box.append(x, etk.VBox.START, etk.VBox.FILL, 0)
x.show()
outer_box = etk.VBox()
box = etk.VBox()
adder = etk.Button(label="New Button")
adder.on_clicked(do_add, box)
sv = etk.ScrolledView()
sv.add_with_viewport(box)
outer_box.append(adder, etk.VBox.START, etk.VBox.FILL, 0)
outer_box.append(sv, etk.VBox.START, etk.VBox.EXPAND_FILL, 0)
w = etk.Window(title="Hello World", size_request=(200, 400), child=outer_box)
w.on_destroyed(lambda x: etk.main_quit())
w.show_all()
etk.main()
b1 = etk.Button(label="4 connects")
b1.on_clicked(click, 1)
b1.on_clicked(click, 2)
b1.on_clicked(click, 3)
b1.on_clicked(click, 4)
b2 = etk.Button(label="4 connects w/ a stop in the middle")
b2.on_clicked(click, 1)
b2.on_clicked(click, 2)
b2.on_clicked(click, 3, stop=True)
b2.on_clicked(click, 4)
exit = etk.Button(label="Exit")
exit.on_clicked(lambda x: etk.main_quit())
box = etk.VBox()
box.append(b1, etk.VBox.END, etk.VBox.FILL, 0)
box.append(b2, etk.VBox.END, etk.VBox.FILL, 0)
box.append(exit, etk.VBox.END, etk.VBox.FILL, 0)
w = etk.Window(title="Hello World", child=box)
def delete(o, n, stop=False):
print "delete-event number #%d" % n
if stop:
print "STOP!"
return False
else:
return True
w.on_delete_event(delete, 1)
w.connect_after("delete-event", delete, 2, stop=True)
table.attach(buttons[0], 1, 1, 0, 0, etk.Table.HEXPAND, 0, 0)
for i in range(6):
table.attach(labels[i], 0, 0, 2 + i, 2 + i, etk.Table.HFILL, 0, 0)
table.attach_default(entries[i], 1, 1, 2 + i, 2 + i)
table.attach(labels[6], 0, 0, 8, 8, etk.Table.HFILL, 0, 0)
table.attach_default(buttons[1], 1, 1, 8, 8)
table.attach(labels[7], 0, 0, 9, 9, etk.Table.HFILL, 0, 0)
table.attach_default(buttons[2], 1, 1, 9, 9)
###################################
## Create Widget for the second tab
align = etk.Alignment(0.5, 0.5, 0.2, 0.0)
vbox = etk.VBox(False, 3)
align.add(vbox)
button_normal = etk.Button(label="Normal button")
vbox.append(button_normal, etk.VBox.START, etk.VBox.NONE, 0)
button_toggle = etk.ToggleButton(label="Toggle button")
vbox.append(button_toggle, etk.VBox.START, etk.VBox.NONE, 0)
button_check = etk.CheckButton(label="Check button 1")
vbox.append(etk.CheckButton(label="Check button 1"), etk.VBox.START, etk.VBox.NONE, 0)
button_check = etk.CheckButton(label="Check Button 2")
vbox.append(button_check, etk.VBox.START, etk.VBox.NONE, 0)
############
## Callbacks
table.attach_default(buttons[1], 1, 1, 8, 8)
table.attach(labels[7], 0, 0, 9, 9, etk.Table.HFILL, 0, 0)
table.attach_default(buttons[2], 1, 1, 9, 9)
###################################
## Create Widget for the second tab
align = etk.Alignment(0.5, 0.5, 0.2, 0.0)
vbox = etk.VBox(False, 3)
align.add(vbox)
button_normal = etk.Button(label="Normal button")
vbox.append(button_normal, etk.VBox.START, etk.VBox.NONE, 0)
button_toggle = etk.ToggleButton(label="Toggle button")
vbox.append(button_toggle, etk.VBox.START, etk.VBox.NONE, 0)
button_check = etk.CheckButton(label="Check button 1")
vbox.append(etk.CheckButton(label="Check button 1"), etk.VBox.START, etk.VBox.NONE, 0)
button_check = etk.CheckButton(label="Check Button 2")
vbox.append(button_check, etk.VBox.START, etk.VBox.NONE, 0)
############
## Callbacks
def prev_cb(obj, note):
note.page_prev()
def next_cb(obj, note):
note.page_next()
############
## Callbacks
def prev_cb(obj, note):
note.page_prev()
def next_cb(obj, note):
note.page_next()
def hide_tabs_toggled_cb(obj, note):
note.tabs_visible_set(not obj.active_get())
##############
## Main Window
main_vbox = etk.VBox(False, 3)
## Create notebook and add pages
notebook = etk.Notebook()
main_vbox.append(notebook, etk.HBox.START, etk.HBox.EXPAND_FILL, 0)
notebook.page_append("First Tab", table)
notebook.page_append("Second Tab", align)
## Create the prev/next buttons and the "Hide tabs" toggle button
hbox = etk.HBox(True, 0)
main_vbox.append(hbox, etk.VBox.START, etk.VBox.SHRINK_OPPOSITE, 0)
button = etk.Button(label="Previous")
button.set_from_stock(etk.c_etk.StockEnums.GO_PREVIOUS)
button.on_clicked(prev_cb, notebook)
hbox.append(button, etk.HBox.START, etk.HBox.FILL, 0)
#!/usr/bin/python
import etk
counter = 0
msg = "Button clicked %d times"
b = etk.Button(label=msg % counter)
b_block = etk.Button(label="Block action")
b_block_false = etk.Button(label="Block other action")
b_unblock = etk.Button(label="Unblock action")
v = etk.VBox()
v.append(b, etk.VBox.END, etk.VBox.NONE, 0)
v.append(b_block, etk.VBox.END, etk.VBox.NONE, 0)
v.append(b_block_false, etk.VBox.END, etk.VBox.NONE, 0)
v.append(b_unblock, etk.VBox.END, etk.VBox.NONE, 0)
w = etk.Window(title="Button", size_request=(200, 200), child=v)
w.show_all()
def count(b, a):
global counter
counter += 1
b.label = msg % counter
print "button %s clicked" % b
return True
b.on_clicked(count, 13)