Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def clear(e):
print "Text was: \"%s\"" % e.text
e.text = ""
def click(b, e):
clear(e)
entry.text = 'some text'
entry.on_text_activated(clear)
bye = etk.Button(label="Click")
bye.on_clicked(click, entry)
box = etk.VBox()
box.append(entry, etk.VBox.START, etk.VBox.FILL, 0)
box.append(bye, etk.VBox.END, etk.VBox.NONE, 0)
w = etk.Window(title="Hello World", size_request=(300, 300), child=box)
w.on_destroyed(lambda x: etk.main_quit())
w.show_all()
etk.main()
#!/usr/bin/python
import etk
icon = etk.Image()
icon.set_from_file('icon.png')
box = etk.VBox()
box.append(icon, etk.VBox.START, etk.VBox.FILL, 0)
w = etk.Window(title="Hello World", size_request=(300, 300), child=box)
w.on_destroyed(lambda x: etk.main_quit())
w.show_all()
etk.main()
rows = l.model.elements
l.model.remove(rows[n])
return True
make_button("Remove first", remove, lst, 0)
make_button("Remove last", remove, lst, -1)
def remove_selected(b, l):
rows = l.selected_rows
if rows:
l.model.remove(rows[0])
return True
make_button("Remove selected", remove_selected, lst)
bsbox = etk.VBox()
for b in bs:
bsbox.append(b, etk.VBox.START, etk.VBox.FILL, 0)
# Main
box = etk.HBox()
box.append(bsbox, etk.HBox.START, etk.HBox.FILL, 0)
box.append(lst, etk.HBox.START, etk.HBox.EXPAND_FILL, 0)
w = etk.Window(title="Hello World", child=box)
w.on_destroyed(lambda x: etk.main_quit())
w.show_all()
etk.main()
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)
w.connect_after("delete-event", delete, 3)
w.show_all()
f = bar.fraction
if math.fabs(f - sli.value) < 0.01:
return True
if f < sli.value:
f += 0.005
else:
f -= 0.005
bar.fraction = f
return True
ecore.timer_add(0.02, stepper, my_bar, my_slider)
box = etk.VBox()
box.append(my_bar, etk.VBox.START, etk.VBox.FILL, 0)
box.append(my_slider, etk.VBox.END, etk.VBox.FILL, 0)
w = etk.Window(title="Hello World", size_request=(300, 100), child=box)
w.on_destroyed(lambda x: etk.main_quit())
w.show_all()
etk.main()
# ComboboxEntry
ce = etk.ComboboxEntry()
for t in ["Alpha", "Beta", "Gamma"]:
ce.item_append(t)
def show_active_item(c):
print c.active_item.field_get(0)
ce.on_active_item_changed(show_active_item)
# Main
box = etk.VBox()
box.append(combo, etk.VBox.START, etk.VBox.FILL, 0)
box.append(ce, etk.VBox.END, etk.VBox.FILL, 0)
w = etk.Window(title="Hello World", size_request=(300, 200), child=box)
w.on_destroyed(lambda x: etk.main_quit())
w.show_all()
etk.main()
def do_add(b, box):
global counter
counter += 1
x = etk.Button(label="Yet another button #%d" % counter)
box.append(x, etk.VBox.START, etk.VBox.FILL, 0)
x.show()