コード例 #1
0
def when_I_call_shapes_add_movie(context):
    shapes = context.shapes
    x, y, cx, cy = Emu(2590800), Emu(571500), Emu(3962400), Emu(5715000)
    context.movie = shapes.add_movie(
        test_file('just-two-mice.mp4'), x, y, cx, cy,
        test_file('just-two-mice.png')
    )
コード例 #2
0
def given_a_PROG_ID_member_file_as_ole_object_file(context, PROG_ID_member):
    filename = {
        "DOCX": "shp-embedded-docx.docx",
        "PPTX": "shp-embedded-pptx.pptx",
        "XLSX": "shp-embedded-xlsx.xlsx",
    }[PROG_ID_member]
    with open(test_file(filename), "rb") as f:
        context.ole_object_file = io.BytesIO(f.read())
    context.PROG_ID_member = PROG_ID_member
コード例 #3
0
ファイル: action.py プロジェクト: lokesh1729/python-pptx
def given_a_shape_having_click_action_action(context, action):
    shape_idx = (
        "none",
        "first slide",
        "last slide",
        "previous slide",
        "next slide",
        "last slide viewed",
        "named slide",
        "end show",
        "hyperlink",
        "other presentation",
        "open file",
        "custom slide show",
        "OLE action",
        "run macro",
        "run program",
        "play media",
    ).index(action)
    slides = Presentation(test_file("act-props.pptm")).slides
    context.slides = slides
    context.click_action = slides[2].shapes[shape_idx].click_action
コード例 #4
0
ファイル: image.py プロジェクト: 74n3r/python-docx
def given_image_filename(context, filename):
    context.image_path = test_file(filename)
コード例 #5
0
ファイル: presentation.py プロジェクト: scanny/python-pptx
def when_I_open_a_presentation_extracted_into_a_directory(context):
    context.prs = Presentation(test_file("extracted-pptx"))
コード例 #6
0
ファイル: text_frame.py プロジェクト: mnjstwins/python-pptx
def when_I_call_TextFrame_fit_text(context):
    from helpers import test_file

    font_file = test_file("calibriz.ttf")
    context.text_frame.fit_text(bold=True, italic=True, font_file=font_file)
コード例 #7
0
ファイル: shape.py プロジェクト: wtayyeb/python-docx
def when_add_inline_picture_to_document(context):
    document = context.document
    run = document.add_paragraph().add_run()
    context.inline_shape = (document.inline_shapes.add_picture(
        test_file('monty-truth.png'), run))
コード例 #8
0
def when_I_call_TextFrame_fit_text(context):
    from helpers import test_file
    font_file = test_file('calibriz.ttf')
    context.text_frame.fit_text(bold=True, italic=True, font_file=font_file)
コード例 #9
0
def when_add_picture_specifying_width(context):
    document = context.document
    context.picture = document.add_picture(test_file('monty-truth.png'),
                                           width=Inches(1.5))
コード例 #10
0
def then_movie_poster_frame_is_the_same_image_as_poster_frame(context):
    actual_sha1 = context.movie.poster_frame.sha1
    with open(test_file('just-two-mice.png'), 'rb') as f:
        expected_sha1 = hashlib.sha1(f.read()).hexdigest()
    assert actual_sha1 == expected_sha1, 'not the same image'
コード例 #11
0
ファイル: shape.py プロジェクト: scanny/python-pptx
def then_movie_poster_frame_is_the_same_image_as_poster_frame(context):
    actual_sha1 = context.movie.poster_frame.sha1
    with open(test_file("just-two-mice.png"), "rb") as f:
        expected_sha1 = hashlib.sha1(f.read()).hexdigest()
    assert actual_sha1 == expected_sha1, "not the same image"
コード例 #12
0
ファイル: text.py プロジェクト: 74n3r/python-docx
def when_I_add_a_picture_to_the_run(context):
    run = context.run
    run.add_picture(test_file('monty-truth.png'))
コード例 #13
0
ファイル: hdrftr.py プロジェクト: madphysicist/python-docx
def when_I_call_run_add_picture(context):
    context.run.add_picture(test_file("test.png"))
コード例 #14
0
ファイル: action.py プロジェクト: lokesh1729/python-pptx
def given_an_ActionSetting_object_as_click_action(context, action):
    shape_idx = {"NONE": 0, "NAMED_SLIDE": 6}[action]
    slides = Presentation(test_file("act-props.pptm")).slides
    context.slides = slides
    context.click_action = slides[2].shapes[shape_idx].click_action
コード例 #15
0
ファイル: shape.py プロジェクト: AKimZ/python-docx
def when_add_inline_picture_from_file_like_object(context):
    document = context.document
    run = document.add_paragraph().add_run()
    with open(test_file('monty-truth.png'), 'rb') as f:
        context.inline_shape = document.inline_shapes.add_picture(f, run)
コード例 #16
0
ファイル: shapes.py プロジェクト: scanny/python-pptx
def when_I_call_shapes_add_movie(context):
    shapes = context.shapes
    x, y, cx, cy = Emu(2590800), Emu(571500), Emu(3962400), Emu(5715000)
    context.movie = shapes.add_movie(
        test_file("just-two-mice.mp4"), x, y, cx, cy, test_file("just-two-mice.png")
    )
コード例 #17
0
ファイル: shape.py プロジェクト: AKimZ/python-docx
def when_add_inline_picture_to_document(context):
    document = context.document
    run = document.add_paragraph().add_run()
    context.inline_shape = (document.inline_shapes.add_picture(
        test_file('monty-truth.png'), run
    ))
コード例 #18
0
def when_add_picture_specifying_only_image_file(context):
    document = context.document
    context.picture = document.add_picture(test_file('monty-truth.png'))
コード例 #19
0
ファイル: api.py プロジェクト: AKimZ/python-docx
def when_add_picture_specifying_width(context):
    document = context.document
    context.picture = document.add_picture(
        test_file('monty-truth.png'), width=Inches(1.5)
    )
コード例 #20
0
ファイル: shape.py プロジェクト: wtayyeb/python-docx
def when_add_inline_picture_from_file_like_object(context):
    document = context.document
    run = document.add_paragraph().add_run()
    with open(test_file('monty-truth.png'), 'rb') as f:
        context.inline_shape = document.inline_shapes.add_picture(f, run)
コード例 #21
0
ファイル: api.py プロジェクト: AKimZ/python-docx
def when_add_picture_specifying_only_image_file(context):
    document = context.document
    context.picture = document.add_picture(test_file('monty-truth.png'))
コード例 #22
0
ファイル: hdrftr.py プロジェクト: ajendrex/python-docx
def when_I_call_run_add_picture(context):
    context.run.add_picture(test_file("test.png"))
コード例 #23
0
ファイル: document.py プロジェクト: ajendrex/python-docx
def when_add_picture_specifying_height(context):
    document = context.document
    context.picture = document.add_picture(test_file("monty-truth.png"),
                                           height=Inches(1.5))
コード例 #24
0
def when_I_call_placeholder_insert_picture(context, filename):
    placeholder = context.shape
    path = test_file(filename)
    with open(path, 'rb') as f:
        context.image_sha1 = hashlib.sha1(f.read()).hexdigest()
    context.placeholder = placeholder.insert_picture(path)
コード例 #25
0
ファイル: text.py プロジェクト: wtayyeb/python-docx
def when_I_add_a_picture_to_the_run(context):
    run = context.run
    run.add_picture(test_file('monty-truth.png'))
コード例 #26
0
ファイル: placeholder.py プロジェクト: handwriter/python-pptx
def when_I_call_placeholder_insert_picture(context, filename):
    placeholder = context.shape
    path = test_file(filename)
    with open(path, "rb") as f:
        context.image_sha1 = hashlib.sha1(f.read()).hexdigest()
    context.placeholder = placeholder.insert_picture(path)
コード例 #27
0
ファイル: image.py プロジェクト: revvsales/python-docx-1
def given_image_filename(context, filename):
    context.image_path = test_file(filename)