Exemple #1
0
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')
link(update_btn, update_label)

reset_btn = Button(height=30, text='Reset')
link(reset_btn, init_field)

win = Window(title='TextField test', width=200, height=245)
app.add(win)

win.add([tf, tf2, lbl], left=25, right=25, top=40, hstretch=1,
          direction='down', space=20)

win.add([reset_btn, update_btn], right=25, bottom=25, vmove=1, hmove=1,
          direction='left', space=25)

init_field()
update_label()

app.run()
Exemple #2
0
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="")
link(b6, makeMove(5))
b7 = Button(height=32, width=32, text="")
link(b7, makeMove(6))
b8 = Button(height=32, width=32, text="")
link(b8, makeMove(7))
b9 = Button(height=32, width=32, text="")
link(b9, makeMove(8))

# A frame for the controls:
b10 = Button(height=32, width=32, text="Play Again", geometry=(10, 10, 100, 50))
link(b10, doAgain)
l1 = Label(height=32, text="Your move...", geometry=(10, 70, 100, 50))
f = Frame()
f.layout = SimpleGridManager()

btns = [b1, b2, b3, b4, b5, b6, b7, b8, b9]

win.add(btns)
win.add(f, row=3, col=0, colspan=3)
f.add(b10, insets=(5, 2))
f.add(l1, insets=(5, 5))
# f.add(b10,l1)

app.run()
Exemple #3
0
b6 =  Button(height = 32, width=32, text = "")
link(b6,makeMove(5))
b7 =  Button(height = 32, width=32, text = "")
link(b7,makeMove(6))
b8 =  Button(height = 32, width=32, text = "")
link(b8,makeMove(7))
b9 =  Button(height = 32, width=32, text = "")
link(b9,makeMove(8))
b10 = Button(height = 32, width=32, text = "Play Again")
link(b10,doAgain)
l1 =  Label(height = 32, text = "Your move...")

btns = [b1,b2,b3,b4,b5,b6,b7,b8,b9]

# You can add components either to the layout or to the
# Window, the result is the same:
win.add((b1,b2,b3),row=0,col=0,xweight=1,yweight=1)
win.layout.add((b4,b5,b6),row=1,col=0,xweight=1,yweight=1)
win.add((b7,b8,b9),row=2,col=0,xweight=1,yweight=1)
win.layout.add(b10,row=3,col=0,colspan=3,insets=(20,2),yweight=0)
win.add(l1,row=4,col=0,colspan=2,insets=(20,2),yweight=0)

# Calling add() with no items lets you configure rows
# and columns.
#win.add(col=0,xweight=0)
#win.layout.add(col=2,xweight=0)
#win.layout.add(row=1,yweight=0.5)
#win.add(row=1,minheight=100)

app.run()
Exemple #4
0
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 = "")
link(b6, makeMove(5))
b7 =  Button(height = 32, width=32, text = "")
link(b7, makeMove(6))
b8 =  Button(height = 32, width=32, text = "")
link(b8, makeMove(7))
b9 =  Button(height = 32, width=32, text = "")
link(b9, makeMove(8))

# A frame for the controls:
b10 = Button(height = 32, width=32, text = "Play Again",geometry = (10,10,100,50))
link(b10,doAgain)
l1 =  Label(height = 32, text = "Your move...",geometry=(10,70,100,50))
f = Frame()
f.layout = SimpleGridManager()

btns = [b1,b2,b3,b4,b5,b6,b7,b8,b9]

win.add((b1,b2,b3,b4,b5,b6,b7,b8,b9))
win.add(f,row=3,col=0,colspan=3)
f.add(b10,insets=(5,2))
f.add(l1,insets=(5,5))
#f.add(b10,l1)

app.run()
Exemple #5
0
app = Application()

win = Window(title='Menu Example', geometry=(50,50,100,100))
win.layout = SimpleGridManager(1,2)

# A menubar for the window.
mbar = MenuBar()
win.addMenu(mbar)

# A menu to choose skits.
skitMenu = Menu(text="Skit")
mbar.add(skitMenu)

# Populate the skit menu.
lbl = Label(text="No skit selected")
win.add(lbl)
def chooseSkit(ev):
    # Handle a skit choice. A menu event should have a
    # 'text' property containing the text of the menu item.
    lbl.text = ev.text

# The objects returned by the add...() calls are handles that permit
# us to operate on the menu items later.
dedPrt = skitMenu.addCommand(text="Dead Parrot")
pengTv = skitMenu.addCommand(text="Penguin on the Telly")
link(dedPrt,chooseSkit)
link(pengTv,chooseSkit)

# We can also supply a command to the command adder, which
# does an implicit link() for us. For menu structures
# that don't change much, this lets us build menus
Exemple #6
0
from manygui import Window, Label, Application
from manygui.Utils import log

app = Application()

win = Window(width = 160, height = 100)
app.add(win)
lb1 = Label(x = 30, y = 18, height = 32, text = "Spam!")
lb2 = Label(x = 30, y = 58, height = 32, text = "Glorious Spam!")

win.add(lb1)
win.add(lb2)

app.run()