Beispiel #1
0
def input_text(prompt, width, initial=None, **kwds):
    box = Dialog(**kwds)
    d = box.margin

    def ok():
        box.dismiss(True)

    def cancel():
        box.dismiss(False)

    lb = Label(prompt)
    lb.topleft = (d, d)
    tf = TextFieldWrapped(width)
    if initial:
        tf.set_text(initial)
    tf.enter_action = ok
    tf.escape_action = cancel
    tf.top = lb.top
    tf.left = lb.right + 5
    box.add(lb)
    box.add(tf)
    tf.focus()
    box.shrink_wrap()
    if box.present():
        return tf.get_text()
    else:
        return None
Beispiel #2
0
def input_text(prompt, width, initial=None, **kwds):
    box = Dialog(**kwds)
    d = box.margin

    def ok():
        box.dismiss(True)

    def cancel():
        box.dismiss(False)

    lb = Label(prompt)
    lb.topleft = (d, d)
    tf = TextFieldWrapped(width)
    if initial:
        tf.set_text(initial)
    tf.enter_action = ok
    tf.escape_action = cancel
    tf.top = lb.top
    tf.left = lb.right + 5
    box.add(lb)
    box.add(tf)
    tf.focus()
    box.shrink_wrap()
    if box.present():
        return tf.get_text()
    else:
        return None
Beispiel #3
0
def input_text_buttons(prompt,
                       width,
                       initial=None,
                       allowed_chars=None,
                       **kwds):
    box = Dialog(**kwds)
    d = box.margin

    def ok():
        box.dismiss(True)

    def cancel():
        box.dismiss(False)

    buts = [Button("OK", action=ok), Button("Cancel", action=cancel)]

    brow = Row(buts, spacing=d)

    lb = Label(prompt)
    lb.topleft = (d, d)
    tf = TextFieldWrapped(width, allowed_chars=allowed_chars)
    if initial:
        tf.set_text(initial)
    tf.enter_action = ok
    tf.escape_action = cancel
    tf.top = lb.top
    tf.left = lb.right + 5

    trow = Row([lb, tf], spacing=d)

    col = Column([trow, brow], spacing=d, align='c')

    col.topleft = (d, d)

    box.add(col)
    tf.focus()
    box.shrink_wrap()
    if box.present():
        return tf.get_text()
    else:
        return None
Beispiel #4
0
def input_text_buttons(prompt, width, initial=None, allowed_chars=None, **kwds):
    box = Dialog(**kwds)
    d = box.margin

    def ok():
        box.dismiss(True)

    def cancel():
        box.dismiss(False)

    buts = [Button("OK", action=ok), Button("Cancel", action=cancel)]

    brow = Row(buts, spacing=d)

    lb = Label(prompt)
    lb.topleft = (d, d)
    tf = TextFieldWrapped(width,allowed_chars=allowed_chars)
    if initial:
        tf.set_text(initial)
    tf.enter_action = ok
    tf.escape_action = cancel
    tf.top = lb.top
    tf.left = lb.right + 5

    trow = Row([lb, tf], spacing=d)

    col = Column([trow, brow], spacing=d, align='c')

    col.topleft = (d, d)

    box.add(col)
    tf.focus()
    box.shrink_wrap()
    if box.present():
        return tf.get_text()
    else:
        return None