示例#1
0
from manygui import *
from manygui.Utils import log
from manygui.Colors import *

# Not all backends support this -- it is not a part of 0.1:
from manygui import Canvas

app = Application()
win = Window(size=(300,300))
app.add(win)
cvs = Canvas(size=win.size)
win.add(cvs)

#def click(x, y, **kw):
def click(e):
    x = e.x
    y = e.y
    log('[Mouse clicked at (%i, %i)]' % (x, y))
    if 30 <= x <= 100 and 30 <= y <= 100:
        log('Yay! You clicked the round rect!')

link(cvs, Events.LeftClickEvent, click)

# Taken from http://piddle.sourceforge.net/sample1.html

cvs.defaultLineColor = Color(0.7,0.7,1.0)    # light blue
if not backend() in 'text curses'.split():
    cvs.drawLines([(i*10,0,i*10,300) for i in range(30)])
    cvs.drawLines([(0,i*10,300,i*10) for i in range(30)])
cvs.defaultLineColor = black