Exemplo n.º 1
0
def decrement_outline_slide_num():
    mydict = open_pickle()
    cur_outline_num = mydict['outline_slide']
    print('cur_outline_num = ' + str(cur_outline_num))
    new_dec_num = cur_outline_num - 1
    mydict['outline_slide'] = new_dec_num
    save_pickle(mydict)
Exemplo n.º 2
0
def open_or_create_next_slide(save=True, close=True, force_no_outline=False):
    if save or close:
        success = _save_and_close(save=save, close=close)
        if not success:
            return
    mydict = open_pickle()
    next_slide = mydict['current_slide'] + 1
    mydict['current_slide'] = next_slide

    if check_for_slide(mydict):
        save_pickle(mydict)
        slidepath = build_slide_path(mydict)
        my_open(filename=slidepath)
        return
    
    if force_no_outline:
        outline_bool = False
    else:
        outline_bool = check_for_next_outline_slide(mydict)

    if outline_bool:
        outline_path = build_next_outline_path(mydict)
        next_outline_slide = mydict['outline_slide'] + 1
        mydict['outline_slide'] = next_outline_slide
        save_pickle(mydict)
        
        open_outline_png(outline_path)
    else:
        open_or_create_slide(mydict)
Exemplo n.º 3
0
def my_open(dialog_func=open_xcf, filename=None):
    folder = get_path_from_pkl()
    if filename is None:
        filename = dialog_func(initialdir=folder)
    #img = pdb.gimp_file_load(1, filename, filename)
    img = pdb.gimp_file_load(filename, filename)
    ind = find_graph_ind(img)
    title_in = img.filename
    #log_msg('title_in=%s' % title_in)
    if ind:
        img.layers[ind].visible = True


    ind2 = find_notes_layer(img)
    if ind2:
        pdb.gimp_image_set_active_layer(img, img.layers[ind2])

    pdb.gimp_image_clean_all(img)

    #Set the current_slide if it is in the current lecture
    mydict = open_pickle()
    full_pat = os.path.join(mydict['lecture_path'], mydict['search_pat'])
    if filename.find(full_pat) == 0:
        cur_slide = slide_num_from_path(filename)
        mydict['current_slide'] = cur_slide
        save_pickle(mydict)
    
    out2 = gimp.Display(img)
    gimp.displays_flush()
Exemplo n.º 4
0
def open_previous_slide(save=True, close=True):
    if save or close:
        success = _save_and_close(save=save, close=close)
        if not success:
            return
    mydict = open_pickle()
    prev_slide = mydict['current_slide'] - 1
    mydict['current_slide'] = prev_slide
    open_or_create_slide(mydict)
Exemplo n.º 5
0
def show_pickle():
    """Load the lecture pickle and display it on a Tk message dialog."""
    mydict = open_pickle()
    msg = ''
    line_pat = '%s: %s\n'
    for key, value in mydict.iteritems():
        curline = line_pat % (key, value)
        msg += curline
    W = tk_msg_dialog.myWindow(msg)
Exemplo n.º 6
0
def open_or_create_next_slide_old(save=True, close=True):
    if save or close:
        success = _save_and_close(save=save, close=close)
        if not success:
            return
    mydict = open_pickle()
    next_slide = mydict['current_slide'] + 1
    mydict['current_slide'] = next_slide
    open_or_create_slide(mydict)
Exemplo n.º 7
0
def jump_to_last_slide(save=True, close=True):
    ## if save or close:
    ##     success = _save_and_close(save=save, close=close)
    ##     if not success:
    ##         return
    ind = find_last_slide_ind()
    mydict = open_pickle()
    mydict['current_slide'] = ind - 1
    save_pickle(mydict)
    open_or_create_next_slide()
Exemplo n.º 8
0
def find_last_slide_ind():
    mydict = open_pickle()
    pat = mydict['pat']
    full_pat = os.path.join(mydict['lecture_path'], pat)
    for i in range(100):
        n = i + 1
        curpath = full_pat % n
        if not os.path.exists(curpath):
            n -= 1
            return n
Exemplo n.º 9
0
def open_new_outline_slide():
    #This doesn't work perfectly.  It seems like it opens pngs instead
    #of xcfs (which makes sense if you look at get_slide_num_filename)
    outline_path = open_image()
    print('outline_path = ' + outline_path)
    folder, fn = os.path.split(outline_path)
    fno, ext = os.path.splitext(fn)
    p = re.compile('^(.*)_([0-9]+)$')
    q = p.match(fno)
    if q is None:
        print('filename did not match pattern ending in 4 digits:' + fn)
    part1 = q.group(1)
    num_str = q.group(2)
    assert len(num_str) == 4, "filename did not end in exactly 4 digits:" + num_str
    pat = part1 + '_%0.4i' + ext
    outline_num = int(num_str)
    mydict = open_pickle()
    mydict['outline_slide'] = outline_num - 1
    mydict['outline_pat'] = pat
    mydict['outline_dir'] = folder
    save_pickle(mydict)
    print('mydict = ' + str(mydict))
    open_or_create_next_slide()
Exemplo n.º 10
0
def zero_current_slide():
    mydict = open_pickle()
    mydict['current_slide'] = 0
    save_pickle(mydict)
Exemplo n.º 11
0
def new_grid_image_2010(footer='', footer_x=1920, \
                        outline=False):#timg, tdrawable):
    print('in new_grid_image_2010. ~/Library/Application Support/....')
    width = 2000
    #height = 1600
    height = 1300
    header_x = 1780
    footer_y = height - 80

    img = gimp.Image(width, height, RGB)

    white_layer = gimp.Layer(img, "White Layer", width, height, \
                             RGB_IMAGE, 100, NORMAL_MODE)
    pdb.gimp_drawable_fill(white_layer, WHITE_FILL)
    img.add_layer(white_layer)

    graph_layer = pdb.gimp_file_load_layer(img, graph_path)
    img.add_layer(graph_layer)

    new_name, slide_num = PGLU.get_slide_num_filename_2010()
    print('new_name = ' + new_name)
    mydict = open_pickle()
    notes_name = "Notes Layer %0.4d" % int(slide_num)
    trans_layer = gimp.Layer(img, notes_name, width, height, \
                             RGBA_IMAGE, 100, NORMAL_MODE)
    pdb.gimp_drawable_fill(trans_layer, TRANSPARENT_FILL)
    img.add_layer(trans_layer)

    img.active_layer = trans_layer
    date_str = mydict['date_stamp']
    #date_str = date_str.replace('_','/')
    pdb.gimp_context_set_foreground((0,0,0))
    cn = mydict['course_num']
    font_size_header_footer = 40

    if cn == '106':
        fmt = "IME %s\n%s"
    else:
        print('cn = %s' % cn)
        print('type(cn) = %s' % type(cn))
        fmt = "ME %s\n%s"

    #if not outline:
    date_stamp = fmt % (cn, date_str)

    text_layer = pdb.gimp_text_fontname(img, trans_layer, \
                                        header_x, 10, \
                                        date_stamp, \
                                        0, \
                                        True, font_size_header_footer, \
                                        1, "Sans")

    pdb.gimp_floating_sel_anchor(text_layer)

    text_layer2 = pdb.gimp_text_fontname(img, trans_layer, footer_x, footer_y, \
                                         footer+str(slide_num), \
                                         0, True, font_size_header_footer, \
                                         1, "Sans")


    pdb.gimp_floating_sel_anchor(text_layer2)
    #pdb.gimp_selection_all(img)
    #pdb.gimp_edit_clear(trans_layer)

    new_path = os.path.join(mydict['lecture_path'], new_name)
    img.filename = new_path


    mydict['current_slide'] = slide_num
    save_pickle(mydict)
    
    out1 = gimp.Display(img)
    gimp.displays_flush()
    pdb.gimp_image_clean_all(img)
    ## title_in = img.filename
    ## log_msg('title_in=%s' % title_in)
    #move_resize_window()
    #print('just tried to move_resize_window')
    #pdb.gimp_selection_none(img)
    return img