Beispiel #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)
Beispiel #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)
Beispiel #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()
Beispiel #4
0
def open_or_create_slide(mydict, verbosity=1):
    filepath = build_slide_path(mydict)
    if os.path.exists(filepath):
        if verbosity > 0:
            print('found:' + filepath)
        save_pickle(mydict)
        my_open(filename=filepath)
    else:
        print('filepath not found: ' + filepath)
        new_grid_image_2010()#this function saves the pickle
Beispiel #5
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()
Beispiel #6
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()
Beispiel #7
0
def reset_pickle():
    """Use this at the beginning of a lecture to set the pickle to
    slide 0 of the correct class based on the time and day of the
    week."""
    debug = 4
    #debugging - set to first day of class
    if debug == 1:
        now = time.strptime('08/23/10 8:55', '%m/%d/%y %H:%M')
    elif debug == 2:
        now = time.strptime('08/24/10 12:15', '%m/%d/%y %H:%M')
    elif debug == 3:
        now = time.strptime('09/08/10 13:25', '%m/%d/%y %H:%M')
    elif debug == 4:
        now = time.strptime('01/13/11 19:25', '%m/%d/%y %H:%M')
    else:
        now = time.localtime()
    
    mydict = {}
    mydict['current_slide'] = 0
    mydict['outline_slide'] = 0
    mydict['date_stamp'] = time.strftime('%m/%d/%y', now)
    date_str = time.strftime('%m_%d_%y', now)

    found = False
    if (now.tm_wday in [0,2]) and (now.tm_hour < 11):
        found = True
        course = '458'
        root = '/home/ryan/siue/classes/mechatronics/%i/lectures/%s' % \
               (now.tm_year, date_str)
    elif (now.tm_wday in [1,3]) and (11 < now.tm_hour < 15):
        found = True
        course = '482'
        root = '/home/ryan/siue/classes/482/%i/lectures/%s' % \
               (now.tm_year, date_str)
    elif (now.tm_wday in [1,3]) and (18 < now.tm_hour < 22):
        found = True
        course = '592'
        root = '/home/ryan/siue/classes/nonlinear_controls/%i/lectures/%s' % \
               (now.tm_year, date_str)
    if (now.tm_wday == 2) and (now.tm_hour > 12):
        found = True
        course = '492'
        root = '/home/ryan/siue/classes/mobile_robotics/%i/lectures/%s' % \
               (now.tm_year, date_str)


    if found:
        mydict['course_num'] = course
        mydict['pat'] = 'ME' + course + '_' + date_str + '_%0.4i.xcf'
        mydict['search_pat'] = 'ME' + course +'_' + date_str
        mydict['lecture_path'] = rwkos.FindFullPath(root)
        save_pickle(mydict)
    else:
        msg = 'Could not determine the course\n' + \
              'based on the current day/time.\n' + \
              '\n' + \
              'now.tm_wday = %s\n' % now.tm_wday + \
              'now.tm_hour = %s\n' % now.tm_hour + \
              '\n' + \
              'Run the script gimp_lecture_prep.py.'
        W = tk_msg_dialog.myWindow(msg)
Beispiel #8
0
def zero_current_slide():
    mydict = open_pickle()
    mydict['current_slide'] = 0
    save_pickle(mydict)
Beispiel #9
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