How to use the etk.Button 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 / 01-button.py View on Github external
#!/usr/bin/python

import etk

counter = 0
msg = "Button clicked %d times"
b = etk.Button(label=msg % counter)
w = etk.Window(title="Button", size_request=(200, 200), child=b)
w.show_all()

def count(button):
    global counter
    counter += 1
    b.label = msg % counter
    print "button %s clicked" % button
    return True
b.on_clicked(count)

def quit(obj):
    etk.main_quit()
w.on_destroyed(quit)

etk.main()
github kakaroto / e17 / OLD / BINDINGS / python / python-etk / examples / 10-virtual.py View on Github external
#!/usr/bin/python

import etk

class MyButton(etk.Button):
    def _size_request(self):
        return (500, 500)

    def _theme_signal_emit(self, signal, size_recalc):
        print "signal=\"%s\"    size_recalc=%d" % (signal, size_recalc)

new = MyButton(label="lalalla")

w = etk.Window(title="Hello World", child=new)
w.show_all()

def quit(obj):
    etk.main_quit()
w.on_destroyed(quit)

etk.main()
github kakaroto / e17 / OLD / BINDINGS / python / python-etk / examples / 20-notebook.py View on Github external
## 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)

button = etk.Button(label="Next")
button.set_from_stock(etk.c_etk.StockEnums.GO_NEXT)
button.on_clicked(next_cb, notebook)
hbox.append(button, etk.HBox.START, etk.HBox.FILL, 0)

button = etk.ToggleButton(label="Hide tabs")
button.on_toggled(hide_tabs_toggled_cb, notebook)
hbox.append(button, etk.HBox.START, etk.HBox.FILL, 0)

w = etk.Window(title="Etk Notebook Example", size_request=(300, 300), child=main_vbox)
w.show_all()

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

etk.main()
github kakaroto / e17 / OLD / BINDINGS / python / python-etk / examples / 03-entry.py View on Github external
import etk


entry = etk.Entry()

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()
github kakaroto / e17 / OLD / BINDINGS / python / python-etk / examples / 04-signal_stop.py View on Github external
#!/usr/bin/python

import etk

def click(o, n, stop=False):
    print n
    if stop:
        print "STOP!"
        return False
    else:
        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)
github kakaroto / e17 / OLD / BINDINGS / python / python-etk / examples / 14-scrolled_view.py View on Github external
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()
github kakaroto / e17 / OLD / BINDINGS / python / python-etk / examples / 12-block.py View on Github external
#!/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
github kakaroto / e17 / OLD / BINDINGS / python / python-etk / examples / 19-text.py View on Github external
import etk

v = etk.VPaned()
h = etk.HBox()

out_tv = etk.TextView()
in_tv = etk.TextView()

out_tb = out_tv.textblock_get()
in_tb = in_tv.textblock_get()
iter_out = etk.TextblockIter(out_tb)
iter_out.forward_end()

b = etk.Button(label="Send")

#e = etk.Entry()
h.append(in_tv, etk.HBox.START, etk.HBox.EXPAND_FILL, 0)
#h.append(e, etk.HBox.START, etk.HBox.EXPAND_FILL, 0)
h.append(b, etk.HBox.END, etk.HBox.FILL, 0)


w = etk.Window(title="Testing TextView!", child=v)
v.child2_set(h,1)
v.child1_set(out_tv,1)

def sendButton_cb(button):
    text = in_tb.text_get(0)
    in_tb.clear()
    #text = e.text
    #e.text = ""