Пример #1
0
from manygui import Window,TextField,Application,Button,Label,link
from manygui.Utils import log

app = Application()

def init_field(*args,**kws):
    global tf, lbl
    tf.text = 'This is a TextField test.'
    tf.selection = (10,19)
    update_label()

def update_label(*args,**kws):
    global tf, lbl
    sel = tf.selection
    text = tf.text
    lbl.text = text[:sel[0]] + \
               '[' + text[sel[0]:sel[1]] + ']' + \
                text[sel[1]:]

def print_contents(event):
    global tf
    log('Enter was pressed. Field contents:', tf.text)

tf = TextField(width=150, height=25)
link(tf, print_contents)
tf.text = ''
tf2 = TextField(width=150, height=25, editable=0)
tf2.text = 'Edit me... :P'
lbl = Label(width = 150, height=25, text = 'I Am A LABEL')

update_btn = Button(width=50, height=30, text='Update')
Пример #2
0
    if checkWin():
        return

    l1.text = "Thinking..."
    b = int(uniform(0, 9))
    while btns[b].text != "":
        b = int(uniform(0, 9))
    btns[b].text = "o"

    if checkWin():
        return

    l1.text = "Your move..."


app = Application()

win = Window(width=200, height=400)
win.layout = SimpleGridManager(3, 4)

b1 = Button(height=32, width=32, text="")
link(b1, makeMove(0))
b2 = Button(height=32, width=32, text="")
link(b2, makeMove(1))
b3 = Button(height=32, width=32, text="")
link(b3, makeMove(2))
b4 = Button(height=32, width=32, text="")
link(b4, makeMove(3))
b5 = Button(height=32, width=32, text="")
link(b5, makeMove(4))
b6 = Button(height=32, width=32, text="")