Exemplo n.º 1
0
import etk

counter = 0

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()

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()
Exemplo n.º 2
0
def on_destroyed(obj):
    etk.main_quit()
Exemplo n.º 3
0
def quit(obj):
    etk.main_quit()
Exemplo n.º 4
0
rows = 3

t = etk.Table(cols=cols, rows=rows, homogeneous=etk.Table.HOMOGENEOUS)

def on_clicked(button):
    print button.label
    return True

pos = 0
for name in ['One', 'Two', 'Three', 'Four', 'Five', 'Six']:
    b = etk.Button(label=name)
    b.connect("clicked", on_clicked)
    row = pos / cols
    col = pos % cols
    t.attach_default(b, col, col, row, row)
    pos += 1

bye = etk.Button(label="Hello World")
bye.connect("clicked", lambda x: etk.main_quit())
t.attach_default(bye, 0, 2, 2, 2)

w = etk.Window(title="Hello World", size_request=(300, 300), child=t)
w.show_all()

def on_destroyed(obj):
    etk.main_quit()
w.connect("destroyed", on_destroyed)


etk.main()
Exemplo n.º 5
0
        return True

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
Exemplo n.º 6
0
# File chooser
filechooser = etk.FilechooserWidget()

# Dialog
dialog = etk.Dialog(title="FilechooserWidget Test Python-Etk")

# Check boxes
select_multiple = etk.CheckButton(label="Select Multiple")
show_hidden = etk.CheckButton(label="Show hidden")
is_save = etk.CheckButton(label="Is save")

# Place the elements into the dialog
dialog.pack_in_main_area(filechooser, etk.VBox.START, etk.VBox.EXPAND_FILL, 0)
dialog.pack_widget_in_action_area(select_multiple, etk.VBox.START, etk.VBox.NONE, 0)
dialog.pack_widget_in_action_area(show_hidden, etk.VBox.START, etk.VBox.NONE, 0)
dialog.pack_widget_in_action_area(is_save, etk.VBox.START, etk.VBox.NONE, 0)
open = dialog.button_add_from_stock(etk.c_etk.StockEnums.DOCUMENT_OPEN, 1)
close = dialog.button_add_from_stock(etk.c_etk.StockEnums.DIALOG_CLOSE, 2)

# Events catchers
select_multiple.connect("toggled", chk_btns, "multiple")
show_hidden.connect("toggled", chk_btns, "hidden")
is_save.connect("toggled", chk_btns, "save")
open.connect("clicked", print_selected)
close.connect("clicked", lambda x: etk.main_quit())

dialog.on_destroyed(lambda x: etk.main_quit())
dialog.show_all()

etk.main()