Example #1
0
def rerange(text):
    import re
    r_blank = re.compile(r'\s+')
    lines = text.splitlines(True)
    if len(lines) <= 1:
        return
    s = []
    flag = True
    pos = []
    for line in lines:
        line = line.rstrip()
        if not line:
            s.append('')
            continue
        strings = ['']  #strings
        #append leading blank
        b = r_blank.match(line)
        if b:
            p = b.end()
        else:
            p = 0
        if flag:
            pos.append(p)
        while 1:
            lastp = p
            b = feed(line, p)
            if b:
                p = p + common.string_width(b)
                strings.append(b)
            else:
                break
            b = r_blank.match(line[p:])
            if b:
                p = p + b.end()
            else:
                break
            if flag:
                pos.append(p - lastp)

        if flag:
            flag = False
            pos.append(0)
        s.append(''.join(
            [common.hz_string_ljust(x, y) for x, y in zip(strings, pos)]))
    return s
Example #2
0
def rerange(text):
    import re
    r_blank = re.compile(r'\s+')
    lines = text.splitlines(True)
    if len(lines) <= 1:
        return
    s = []
    flag = True
    pos = []
    for line in lines:
        line = line.rstrip()
        if not line: 
            s.append('')
            continue
        strings = ['']#strings
        #append leading blank
        b = r_blank.match(line)
        if b:
            p = b.end()
        else:
            p = 0
        if flag:
            pos.append(p)
        while 1:
            lastp = p
            b = feed(line, p)
            if b:
                p = p + common.string_width(b)
                strings.append(b)
            else:
                break
            b = r_blank.match(line[p:])
            if b:
                p = p + b.end()
            else:
                break
            if flag:
                pos.append(p - lastp)
           
        if flag:
            flag = False
            pos.append(0)
        s.append(''.join([common.hz_string_ljust(x, y) for x, y in zip(strings, pos)]))
    return s
Example #3
0
def setmenuitemtext(menuitem, label, accel):
    caption = label + accel.rjust(40-common.string_width(label))
    menuitem.SetText(caption)