Ejemplo n.º 1
0
def makeWindow(root, st):
    " make the top window for autogoal options"
    global ag

    tp = Toplevel(borderwidth=3, relief='ridge')
    tp.wm_title('Autogoal settings')
    try:
        tp.maxw = root.maxw
        tp.maxh = root.maxh - 30
    except:
        v = root.geometry()
        parts = string.split(v, 'x')
        tp.maxw = int(parts[0])
        partx = string.replace(parts[1], '-', '+')
        partx = string.split(parts[1], '+')
        tp.maxh = int(partx[0]) - 30
    sizer = '%dx%d+0+25' % (tp.maxw, tp.maxh)
    tp.wm_geometry(sizer)
    #tp.overrideredirect(1)
    tp.transient(root)

    def _freeze_window(tp, geom, event, *args):
        if tp.wm_geometry() != geom:
            tp.wm_geometry(geom)

    tp.bind('<Configure>', Command(_freeze_window, tp, sizer))

    wk = Frame(tp)
    for lt in range(len(st.fmt)):
        if lt >= len(st.autogoals):
            if st.fmt[lt] == 'R' or st.fmt[lt] == 'M':
                st.autogoals.append([65, 0, 250])
            else:
                st.autogoals.append([20, 6, 250])
        lst = st.autogoals[lt][:]
        #print lst
        makeit(wk, lt, st.fmt[lt], lst)
    wk.pack(side='top')

    agfr = Frame(tp)
    Label(agfr,
          text='Seconds between autothresholds\n(0 means at end of a period)'
          ).pack(side='left')
    lobj = Spinner(agfr, width=4, min=0, max=1000)
    lobj.insert(0, ag.prob['autotime'])
    lobj.pack(side='left')
    lcmd = Command(Timeval, lobj)
    lcmd.widget = lobj
    ckbut = Button(agfr, width=37)
    lobj.button = ckbut
    lobj.bind('<Button-1>', Command(Entering, lcmd))
    lobj.bind('<Any-Leave>', lcmd)
    lobj.bind('<FocusOut>', lcmd)
    lobj.bind('<Return>', lcmd)
    lobj.configure(callback=lcmd)
    ckbut.pack(side='left')
    ckbut.bind('<Button-1>', Command(clicker, 1))
    clicker(0, ckbut)
    agfr.pack(side='top')
    ag.tvalid = 1

    fr = Frame(tp, height=50, bg='SlateGray1')
    byes = Button(fr, text='OK', command=OK, width=10)
    bno = Button(fr, text='Cancel', command=Canx, width=10)
    tp.protocol('WM_DELETE_WINDOW', Canx)
    bno.pack(side='right')
    byes.pack(side='right')
    fr.pack(side='bottom', fill='x', expand=0, ipady=50)
    #root.top=tp
    ag.okbutton = byes
    ag.active = None
    ag.bg = 'SystemWindow'  #wk.configure(background)   # get the original value
    ag.tp = tp
    tp.bind('<FocusOut>', holdtop)
    tp.grab_set()
    tp.focus_set()
    return tp
Ejemplo n.º 2
0
def makeit(wn, index, fmtchar, values):

    global ag

    fm = Frame(wn, relief='ridge', borderwidth=3)
    pct = None
    if fmtchar == 'C':
        Label(fm,
              text=' Input channel - no auto-thresholding').pack(side='top')
        for i in range(3):
            values.append(2)
    elif fmtchar == 'R':
        Label(fm, text='     Reward').pack(side='top', anchor='nw')
        pct = values[0]
        lowv = values[1]
        highv = values[2]
        for i in range(3):
            values.append(1)
    elif fmtchar == 'I':
        Label(fm, text='     Inhibit').pack(side='top', anchor='nw')
        pct = values[0]
        lowv = values[1]
        highv = values[2]
        for i in range(3):
            values.append(1)
    elif fmtchar == 'M':
        Label(fm, text='     Monitor').pack(side='top', anchor='nw')
        pct = values[0]
        lowv = values[1]
        highv = values[2]
        for i in range(3):
            values.append(1)
    else:
        Label(fm, text=' Unknown').pack(side='top', anchor='nw')
        for i in range(3):
            values.append(2)
    ag.valid.append(values)
    fm.pack(side='top')
    if pct == None:
        return

    # now arrange for validation and saving
    if fmtchar == 'R':
        Label(fm, text='Desired reward %         ', width=25).pack(side='left')
    else:
        Label(fm, text='Desired % over threshold ', width=25).pack(side='left')
    pobj = Spinner(fm, width=4, min=0, max=250)
    pobj.insert(0, pct)
    pobj.pack(side='left')
    pobj.index = index
    Label(fm, text='  Minimum uv ').pack(side='left')
    lobj = Spinner(fm, width=4, min=0, max=250)
    lobj.insert(0, lowv)
    lobj.pack(side='left')
    lobj.index = index
    Label(fm, text='  Maximum uv ').pack(side='left')
    hobj = Spinner(fm, width=4, min=0, max=250)
    hobj.insert(0, highv)
    hobj.pack(side='left')
    hobj.index = index

    pcmd = Command(Pctval, pobj)
    pcmd.widget = pobj
    pobj.bind('<Button-1>', Command(Entering, pcmd))
    pobj.bind('<Any-Leave>', pcmd)
    pobj.bind('<FocusOut>', pcmd)
    pobj.bind('<Return>', pcmd)
    pobj.configure(callback=pcmd)

    lcmd = Command(Lowval, lobj)
    lcmd.widget = lobj
    lobj.bind('<Button-1>', Command(Entering, lcmd))
    lobj.bind('<Any-Leave>', lcmd)
    lobj.bind('<FocusOut>', lcmd)
    lobj.bind('<Return>', lcmd)
    lobj.configure(callback=lcmd)

    hcmd = Command(Highval, hobj)
    hcmd.widget = hobj
    hobj.bind('<Button-1>', Command(Entering, hcmd))
    hobj.bind('<Any-Leave>', hcmd)
    hobj.bind('<FocusOut>', hcmd)
    hobj.bind('<Return>', hcmd)
    hobj.configure(callback=hcmd)