コード例 #1
0
ファイル: test_textfield.py プロジェクト: ProgVal/Manygui
    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')
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,
コード例 #2
0
ファイル: ttt.py プロジェクト: ProgVal/Manygui
        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="")
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="")
コード例 #3
0
ファイル: test_menu.py プロジェクト: ProgVal/Manygui
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
# without having to deal with every menu item proxy.
# This works for checkboxes as well.
lumbrJk = skitMenu.addCommand(text="Lumberjack",command=chooseSkit)

skitMenu.addSeparator()

# Enable or disable skit silliness: a checkable menu item.
def enableSilly(ev):
    #print "Enabling silly:",enSilly.on
    # Enable or disable the silliness selection based
コード例 #4
0
ファイル: Menus.py プロジェクト: ProgVal/Manygui
 def addCheck(self,text="CHECKBOX",enabled=1,index=None,command=None,*args,**kws):
     cmdItem = MenuCheck(text=text,*args,**kws)
     if command:
         link(cmdItem,command)
     self.add(cmdItem,index)
     return cmdItem
コード例 #5
0
ファイル: Menus.py プロジェクト: ProgVal/Manygui
 def addCommand(self,text="COMMAND",enabled=1,index=None,command=None,*args,**kws):
     cmdItem = MenuCommand(text=text,*args,**kws)
     if command:
         link(cmdItem,command)
     self.add(cmdItem,index)
     return cmdItem
コード例 #6
0
ファイル: Menus.py プロジェクト: ProgVal/Manygui
 def __init__(self, *args, **kw):
     Proxy.__init__(self, *args, **kw)
     if 'command' in list(kw.keys()):
         link(self,kw['command'])