Beispiel #1
0
def run():
    clear()
    lights(False)
    x = pf.canvas.width()//2
    y = pf.canvas.height()//2

    s = 100
    G = Grid(x-s,y-s,x+s,y+s,2,2)
    decorate(G)

    delay(2)
    for g in [ 'NW','N','NE','W','C','E','SW','S','SE']:
        T = drawText("XXX  %s  XXX"%g,x,y,gravity=g)
        wait()
        undecorate(T)

    delay(1)
    from gui.gluttext import GLUTFONTS
    for f in GLUTFONTS.keys():
        S = drawText(f,20,20,font='hv18')
        T = drawText('X',x,y,font=f,gravity='C')
        wait()
        undecorate(S)
        undecorate(T)
lights(False)
x = pf.canvas.width()//2
y = pf.canvas.height()//2
x,y = 600,300
print x,y

from gui.decors import Grid

d = 50

G = Grid(x-50,y-50,x+50,y+50,2,2)
decorate(G)

delay(2)
for g in [ 'NW','N','NE','W','C','E','SW','S','SE']:
    T = drawText("XXX  %s  XXX"%g,x,y,gravity=g)
    wait()
    undecorate(T)


delay(1)
from gui.gluttext import GLUTFONTS
for f in GLUTFONTS.keys():
    S = drawText(f,20,20,font='hv18')
    T = drawText('X',x,y,font=f,gravity='C')
    wait()
    undecorate(S)
    undecorate(T)
    
# End
def getData():
    res = askItems([
        ('Value range type',None,'radio',['Minimum-Medium-Maximum','Minimum-Maximum']),
        ('Maximum value',12.0),
        ('Medium value',0.0),
        ('Minimum value',-6.0),
        ('Use a predefined color palet',True),
        ('Predefined color palet',None,'select',Palette.keys()),
        ('Maximum color',[1.,0.,0.]),
        ('Medium color',[1.,1.,0.]),
        ('Minimum color',[1.,1.,1.]),
        ('High exponent',1.0),
        ('Low exponent',1.0),
        ('Number of colors',12),
        ('Decimals',2),
        ('Scaling exponent',0),
        ('Show grid',True),
        ('Line width',1.5),
        ('Text left of colorscale',True),
        ('Font','hv18','select',GLUTFONTS.keys()),
        ('Position',[400,50]),
        ('Size',(100,600)),
        ('Header','Currently not displayed'),
        ('Gravity','Notused'),
        ],legacy=True)
    
    if not res:
        return

    valrange = res['Value range type']
    maxval = res['Maximum value']
    minval = res['Minimum value']
    if valrange == 'Minimum-Medium-Maximum':
        medval = res['Medium value']
    else: 
        medval = None

    predef = res['Use a predefined color palet']
    if predef:
        palet = res['Predefined color palet']
    else:
        maxcol = res['Maximum color']
        mincol = res['Minimum color'] 
        if valrange == 'Minimum-Medium-Maximum':
            medcol = res['Medium color']
        else: 
            medcol = None
        palet = [mincol,medcol,maxcol]

    maxexp = res['High exponent']
    if valrange == 'Minimum-Medium-Maximum':
        minexp = res['Low exponent']
    else:
        minexp = None

    ncolors = res['Number of colors']
    dec = res['Decimals']
    scale = res['Scaling exponent']
    if res['Show grid']:
        if ncolors <= 50:
            grid = ncolors
        else:
            grid = 1
    else:
        grid = 0
    linewidth = res['Line width']
    lefttext = res['Text left of colorscale']
    font = res['Font']
    x,y = res['Position']
    w,h = res['Size']
    # ok, now draw it
    drawColorScale(palet,minval,maxval,medval,maxexp,minexp,ncolors,dec,scale,grid,linewidth,lefttext,font,x,y,w,h)     
    _G('custom',text='Custom Color palette',items=[
        _I('maxcol',[1.,0.,0.],text='Maximum color',itemtype='color'),
        _I('medcol',[1.,1.,0.],text='Medium color',itemtype='color'),
        _I('mincol',[1.,1.,1.],text='Minimum color',itemtype='color'),
        ],checked=False),
    _I('maxexp',1.0,text='High exponent'),
    _I('minexp',1.0,text='Low exponent'),
    _I('ncolors',200,text='Number of colors'),
    _T('Grid/Label',[
        _I('ngrid',-1,text='Number of grid intervals'),
        _I('linewidth',1.5,text='Line width'),
        _I('nlabel',-1, text='Number of label intervals'), 
        _I('dec',2,text='Decimals'),
        _I('scale',0,text='Scaling exponent'),
        _I('lefttext',True,text='Text left of colorscale'),
        _I('font','hv18',text='Font',choices=GLUTFONTS.keys()),
        _I('header','Currently not displayed',text='Header',enabled=False),
        _I('gravity','Notused',text='Gravity',enabled=False),
        ]),
    _T('Position/Size',[
        _I('autosize',True,text='Autosize'),
        _I('size',(100,600),text='Size'),
        _I('autopos',True,text='Autoposition'),
        _I('position',[400,50],text='Position'),
        ]),
    ]

input_enablers = [
    ('valrange','Minimum-Medium-Maximum','medval','medcol'),
    ('custom',False,'palet'),
    ('autosize',False,'size'),
Beispiel #5
0
    _G('custom',text='Custom Color palette',items=[
        _I('maxcol',[1.,0.,0.],text='Maximum color',itemtype='color'),
        _I('medcol',[1.,1.,0.],text='Medium color',itemtype='color'),
        _I('mincol',[1.,1.,1.],text='Minimum color',itemtype='color'),
        ],checked=False),
    _I('maxexp',1.0,text='High exponent'),
    _I('minexp',1.0,text='Low exponent'),
    _I('ncolors',200,text='Number of colors'),
    _T('Grid/Label',[
        _I('ngrid',-1,text='Number of grid intervals'),
        _I('linewidth',1.5,text='Line width'),
        _I('nlabel',-1, text='Number of label intervals'),
        _I('dec',2,text='Decimals'),
        _I('scale',0,text='Scaling exponent'),
        _I('lefttext',True,text='Text left of colorscale'),
        _I('font','hv18',text='Font',choices=GLUTFONTS.keys()),
        _I('header','Currently not displayed',text='Header',enabled=False),
        _I('gravity','Notused',text='Gravity',enabled=False),
        ]),
    _T('Position/Size',[
        _I('autosize',True,text='Autosize'),
        _I('size',(100,600),text='Size'),
        _I('autopos',True,text='Autoposition'),
        _I('position',[100,50],text='Position'),
        ]),
    ]

input_enablers = [
    ('valrange','Minimum-Medium-Maximum','medval','medcol'),
    ('custom',False,'palet'),
    ('autosize',False,'size'),