示例#1
0
def close_matching(str):
    """ close all pylab windows with str in the title,
    see also raise _matching"""
    (labs_nums) = zip(pl.get_figlabels(), pl.get_fignums())
    closed = 0
    for (lab, num) in labs_nums:
        if str in lab:
            pl.close(num)
            closed += 1
    if closed == 0: print('No figures matching {s} found'.format(s=str))
示例#2
0
def raise_matching(str):
    """ raise all pylab windows with str in the title,
    whether they flash or raise depends on window manager and settings
    Note than figure(num='myname') is a legal way to name a fig"""
    labs = pl.get_figlabels()
    for lab in labs:
        if str in lab:
            pl.figure(lab)
            mgr = pl.get_current_fig_manager()
            mgr.window.tkraise()
示例#3
0
def raise_matching(str):
    """ raise all pylab windows with str in the title,
    whether they flash or raise depends on window manager and settings
    Note than figure(num='myname') is a legal way to name a fig"""
    labs = pl.get_figlabels()
    for lab in labs:
        if str in lab:
            pl.figure(lab)
            mgr = pl.get_current_fig_manager()
            mgr.window.tkraise()
示例#4
0
def close_matching(str):
    """ close all pylab windows with str in the title,
    see also raise _matching"""
    (labs_nums) = zip(pl.get_figlabels(),pl.get_fignums())
    closed = 0
    for (lab,num) in labs_nums:
        if str in lab:
            pl.close(num)
            closed += 1
    if closed == 0: print('No figures matching {s} found'
                          .format(s=str))
示例#5
0
def close_matching(str):
    """ close all pylab windows with str in the title,
    see also raise _matching"""
    # coded differently as the number must be given to close.
    (labs_nums) = zip(pl.get_figlabels(), pl.get_fignums())
    closed = 0
    for (lab, num) in labs_nums:
        if (str == '' and str == lab) or (str != '' and str in lab):
            # x=input('pause')
            pl.close(num)
            closed += 1
    if closed == 0: print('No figures matching "{s}" found'.format(s=str))
示例#6
0
def get_fig_nums_labs(match_str=''):
    """ get all figure labels if they exist, or str of the fig num if note
    The match_str is compared with lab just to detect no matches - all labs are returned
    """
    fig_nums = pl.get_fignums()
    fig_labs = pl.get_figlabels()
    nums_labs = []
    for num, lab in zip(fig_nums, fig_labs):
        if lab == '': lab = str(num)
        nums_labs.append(lab)
    # check for matches here, save duplicating code.
    matches = [nl for nl in nums_labs if match_str in nl]
    if len(matches) == 0:
        print('No matches to ' + match_str)
    return (nums_labs)