Beispiel #1
0
def plotPowerpoint(runList, plotDir):

    # Set directory of QA plots (and output directory for presentation)
    if not plotDir.endswith("/"):
        plotDir = plotDir + "/"
    if not os.path.exists(plotDir):
        print("plotDir " + plotDir + "does not exist!")

    #--------------------------------------------------------------------
    # Some general settings for the routine
    # Detect whether pt-hard production or not
    isPtHard = os.path.exists(plotDir + "AllRuns/QAoutput/PtHard")
    # Detect whether pp production or not
    isPbPb = os.path.exists(plotDir +
                            "AllRuns/QAoutput/Jets/hFullJetPtCorrCentral.png")
    # Detect whether includes PHOS or not
    isIncludePhos = os.path.exists(
        plotDir + "AllRuns/QAoutput/Clusters/hClusPHOSEnergy.png")

    #period = "LHC15n"
    period = "LHC17p"
    #period = "LHC17q"
    #qa_author = "James Mulligan, Yale University"
    qa_author = "Eliane Epple, Yale University"
    system = "pp"
    if isPbPb:
        system = "Pb-Pb"

    print("Is pT hard: %s" % isPtHard)
    print("Is PbPb data: %s" % isPbPb)
    print("Includes PHOS info: %s" % isIncludePhos)
    print("Period: %s" % period)
    print("System: %s" % system)
    print("Author: %s" % qa_author)

    #--------------------------------------------------------------------
    # Start creating some introductory slides
    # Create a blank presentation
    qa = Presentation()

    # Define some slide layouts
    title_slide_layout = qa.slide_layouts[0]
    bullet_slide_layout = qa.slide_layouts[1]
    blank_slide_layout = qa.slide_layouts[6]

    # Make a title slide
    slide = qa.slides.add_slide(title_slide_layout)
    title = slide.shapes.title
    author = slide.placeholders[1]
    title.text = str(period) + " QA -- Full Jets"
    author.text = str(qa_author)

    # Make a general slide describing analysis details
    slide = qa.slides.add_slide(bullet_slide_layout)
    shapes = slide.shapes
    title_shape = shapes.title
    title_shape.text = str(period) + " QA -- Full Jets"
    body_shape = shapes.placeholders[1]
    tf = body_shape.text_frame
    tf.text = str(period) + ": 5.02 TeV " + str(system)
    p = tf.add_paragraph()
    p.text = "Runlist: " + str(runList)
    p = tf.add_paragraph()
    p.text = 'Physics selection: Default (no pileup cuts)'
    p = tf.add_paragraph()
    p.text = 'Trigger: kINT7'
    p = tf.add_paragraph()
    p.text = 'Event selection'
    p = tf.add_paragraph()
    p.text = 'N vertex contributors > 0'
    p.level = 1
    p = tf.add_paragraph()
    p.text = '|Vz| < 10 cm'
    p.level = 1
    p = tf.add_paragraph()
    p.text = '|Vz - VzSPD| < 0.5 cm'
    p.level = 1
    #p = tf.add_paragraph()
    #p.text = 'pT,jet < 4 pT,hard'
    #p.level = 1
    p = tf.add_paragraph()
    p.text = 'Track selection:' + str(system) + 'track cuts (hybrid tracks)'
    p = tf.add_paragraph()
    p.text = 'EMCal corrections: AliEmcalCorrectionTask, all corrections enabled, default parameters used'
    p = tf.add_paragraph()
    p.text = 'PHOS corrections: PHOS Tender, default settings'
    p = tf.add_paragraph()
    p.text = 'Jet Selection:'
    p = tf.add_paragraph()
    p.text = 'Charged jets: anti-kT, R=0.2, TPC fiducial cut, background-subtracted'
    p.level = 1
    p = tf.add_paragraph()
    p.text = 'Full jets: anti-kT, R=0.2, EMCal/DCal fiducial cut'
    p.level = 1
    p = tf.add_paragraph()
    p.text = 'Background subtracted using 2.76 TeV scale factors'
    p.level = 2
    tf.fit_text('Calibri', 14)

    #--------------------------------------------------------------------
    # Create a table at the end for summarizing the QA per run and object
    slide = qa.slides.add_slide(bullet_slide_layout)
    shapes = slide.shapes
    title_shape = shapes.title
    title_shape.text = str(period) + " QA -- Full Jets"
    body_shape = shapes.placeholders[1]
    tf = body_shape.text_frame
    tf.text = str(period) + ": 5.02 TeV " + str(system)
    totalEvents = 0
    totalRuns = 0
    for run in runList.split():
        inputFile = plotDir + str(run) + "/AnalysisResults.root"
        #if downloading the file did fail at some point (=zero bytes) you can check this here:
        size = os.stat(inputFile).st_size
        #print("size of root file: %s" % size)
        if size != 0:
            f = ROOT.TFile(inputFile)
            qaTaskName = determineQATaskName("AliAnalysisTaskPWGJEQA", f,
                                             isPtHard)
            #print("Found qaTaskName \"{0}\"".format(qaTaskName))
            qaList = f.Get(qaTaskName)
            histNEvent = qaList.FindObject("fHistEventCount")
            nEvents = histNEvent.GetBinContent(1)
            totalEvents = totalEvents + nEvents
            totalRuns = totalRuns + 1
            p = tf.add_paragraph()
            p.text = str(run) + " with " + str(nEvents) + " Evts "
        else:
            print(
                "!!!!!!! Root file for run %s is empty - please check download"
                % str(run))
    p = tf.add_paragraph()
    p.text = "Total number of used runs period: " + str(totalRuns)
    p = tf.add_paragraph()
    p.text = "Total events in period: " + str(totalEvents) + " Evts "
    tf.fit_text('Calibri', 14)

    #--------------------------------------------------------------------
    # Create the slides for all runs combined (Run = -1)
    # layout depending on the settings
    plotRun(qa, blank_slide_layout, plotDir, isPtHard, isPbPb, isIncludePhos,
            -1, 0)

    #define two different ways of plotting 1->ordered by run numbers 2->ordered by objects that are QAd'
    version = 2
    #--------------------------------------------------------------------
    # Now, do the run-by-run plots (run sorted)
    #
    if version == 1:
        for run in runList.split():

            if not os.path.exists(plotDir + str(run) + "/QAoutput/EventQA"):
                print("Run " + str(run) + " is empty -- skipping.")
                continue
            plotRun(qa, blank_slide_layout, plotDir, isPtHard, isPbPb,
                    isIncludePhos, run, 0)
    #--------------------------------------------------------------------
    # Now, do the run-by-run plots (object sorted)
    #
    if version == 2:
        for object in range(1, 5):
            for run in runList.split():

                if not os.path.exists(plotDir + str(run) +
                                      "/QAoutput/EventQA"):
                    print("Run " + str(run) + " is empty -- skipping.")
                    continue
                plotRun(qa, blank_slide_layout, plotDir, isPtHard, isPbPb,
                        isIncludePhos, run, object)
    #--------------------------------------------------------------------
    # Get number of events
    slide = qa.slides.add_slide(blank_slide_layout)
    shapes = slide.shapes
    #title_shape = shapes.title
    #title_shape.text = str(period) + " QA -- Full Jets"
    #body_shape = shapes.placeholders[1]
    rows = totalRuns + 1
    cols = 5
    left = top = Inches(0.3)
    width = Inches(6.0)
    height = Inches(0.2)

    table = shapes.add_table(rows, cols, left, top, width, height).table
    # set column widths
    table.columns[0].width = Inches(1.0)
    # table.columns[1].width = Inches(4.0)

    table.cell(0, 0).text = "Run"
    table.cell(0, 1).text = "Track OK"
    table.cell(0, 2).text = "Cluster OK"
    table.cell(0, 3).text = "Ch Jets OK"
    table.cell(0, 4).text = "Full Jets OK"
    col = 1
    for run in runList.split():
        table.cell(col, 0).text = str(run)
        col = col + 1

    #--------------------------------------------------------------------
    # Save the final presentation
    qa.save(plotDir + period + "_QA.pptx")
    print("Saved presentation in: " + plotDir + period + "_QA.pptx")
Beispiel #2
0
import sys
from pptx import Presentation
from pptx.chart.data import CategoryChartData
from pptx.enum.chart import XL_CHART_TYPE
from pptx.util import Inches

presentation = Presentation()

title_slide_layout = presentation.slide_layouts[0]
title_slide = presentation.slides.add_slide(title_slide_layout)
title_slide.shapes.title.text = "Demo presentation"
title_slide.placeholders[1].text = "Made by Sebastian Dremo"

chart_slide = presentation.slides.add_slide(presentation.slide_layouts[5])

chart_data = CategoryChartData()
chart_data.categories = ['X', 'Y']
#First argument is for name of a chart, second is first value of the chart and so on 
chart_data.add_series(sys.argv[1], (sys.argv[2], sys.argv[3]))

chart_slide.shapes.add_chart(XL_CHART_TYPE.COLUMN_CLUSTERED, Inches(2), Inches(2), Inches(6), Inches(4.5), chart_data)

presentation.save("../Presentations/DemoPresentationWithPython.pptx")

Beispiel #3
0
    Top_Fleche_1 = 1700808
    Top_Fleche_2 = 1196752
    Dist_Fleche = 969000

    for j in range(FolderNumber):
        for i in range(5):
            prs = Presentation(
                str(sourcepath) + '\Matrix ' + str(classe) + '.pptx')
            prs.slides[0].shapes[2].top = 1700808 + i * Dist_Fleche
            prs.slides[1].shapes[5].top = 1196752 + i * Dist_Fleche
            if i == 4:
                # Explosion éval

                shapes = prs.slides[0].shapes
                left = Inches(0.8)
                top = Inches(5.5)
                width = Inches(4.8)
                height = Inches(1.5)
                shape = shapes.add_shape(MSO_SHAPE.EXPLOSION1, left, top,
                                         width, height)
                cursor_sp = shapes[0]._element
                cursor_sp.addprevious(shapes[4]._element)
                fill = shape.fill
                fill.solid()
                fill.fore_color.rgb = RGBColor(255, 255, 0)
                line = shape.line
                line.color.rgb = RGBColor(0, 0, 0)
                line.color.brightness = 1.0  # % light
                line.width = Pt(0.0)
Beispiel #4
0
def start2():

    slide = prs.slides.add_slide(blank_slide_layout)
    #设置背景图片和主标题
    img_path = 'backgrounds/2_1.jpg'
    left, top, width, height = Inches(0), Inches(0), Inches(13.5), Inches(7.5)
    pic = slide.shapes.add_picture(img_path, left, top, width, height)
    #主标题
    left, top, width, height = Inches(3), Inches(2), Inches(8), Inches(1.5)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    p = tf.add_paragraph()
    p.font.name = '黑体'
    p.text = "数据助力水处理设施运维服务"
    p.font.color.rgb = RGBColor(255, 255, 255)
    p.font.size = Pt(40)
    #副标题1
    left = Inches(5.5)
    top = Inches(5)
    width = Inches(3)
    height = Inches(0.8)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    p = tf.add_paragraph()
    p.font.name = '黑体'
    p.text = "XXX科技有限公司"
    p.font.size = Pt(25)
    #副标题2
    left = Inches(5.8)
    top = Inches(5.8)
    width = Inches(3)
    height = Inches(0.7)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    p = tf.add_paragraph()
    p.font.name = '黑体'
    p.text = "日期:XXX年xxx月"
    p.font.color.rgb = RGBColor(255, 255, 255)
    p.font.size = Pt(15)
    prs.save('test.pptx')
Beispiel #5
0
def twentieth_page():
    slide = prs.slides.add_slide(blank_slide_layout)
    #背景图片
    img_path = 'backgrounds/1.jpg'
    SetPictureAndTitle(slide, img_path)
    #图片1位置
    img_path = 'images/20_1.jpg'
    left, top, width, height = Inches(2), Inches(4.4), Inches(2), Inches(3)
    pic = slide.shapes.add_picture(img_path, left, top, width, height)
    #图片2位置
    img_path = 'images/20_2.jpg'
    left, top, width, height = Inches(4.5), Inches(4.4), Inches(2), Inches(3)
    pic = slide.shapes.add_picture(img_path, left, top, width, height)
    #图片3位置
    img_path = 'images/20_3.jpg'
    left, top, width, height = Inches(7), Inches(4.4), Inches(2), Inches(3)
    pic = slide.shapes.add_picture(img_path, left, top, width, height)
    #段落1设置-读入数据
    txt_path = 'texts/20.txt'
    text = open(txt_path, encoding='utf-8')
    lines = text.readlines()
    #段落1设置-位置
    left, top, width, height = Inches(2), Inches(2), Inches(8), Inches(2.5)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    tf.word_wrap = True
    p = tf.add_paragraph()
    p.text = "这里控制 20.txt"
    for line in lines:
        p = tf.add_paragraph()
        p.font.name = '黑体'
        p.text = line
    prs.save('test.pptx')
Beispiel #6
0
from pptx import Presentation
from pptx.util import Inches

img_path = "docxTry.png"

prs = Presentation()
blank_slide_layout = prs.slide_layouts[6]
slide = prs.slides.add_slide(blank_slide_layout)

left = top = Inches(1)
pic = slide.shapes.add_picture(img_path, left, top)

left = Inches(5)
height = Inches(5.5)
pic = slide.shapes.add_picture(img_path, left, top, height = height)

prs.save("pptxTry_tps.pptx")
Beispiel #7
0
def directory2():
    slide = prs.slides.add_slide(blank_slide_layout)
    #设置背景图片和标题
    img_path = 'backgrounds/2_2.jpg'
    left, top, width, height = Inches(0), Inches(0), Inches(13.5), Inches(7.5)
    pic = slide.shapes.add_picture(img_path, left, top, width, height)
    #目录标题
    left, top, width, height = Inches(1), Inches(0), Inches(3), Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    p = txBox.text_frame.add_paragraph()
    p.font.name = '黑体'
    p.font.bold = True
    p.text = "目录"
    p.font.size = Pt(50)

    #目录
    left, top, width, height = Inches(2.4), Inches(1.4), Inches(3), Inches(5)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    p = tf.add_paragraph()
    p.font.name = '黑体'
    p.font.size = Pt(20)
    p.text = "● 第一个目录\n"
    p = tf.add_paragraph()
    p.font.name = '黑体'
    p.font.size = Pt(20)
    p.text = "● 第二个目录\n"
    p = tf.add_paragraph()
    p.font.name = '黑体'
    p.font.size = Pt(20)
    p.text = "● 第三个目录\n"
    p = tf.add_paragraph()
    p.font.name = '黑体'
    p.font.size = Pt(20)
    p.text = "● 第四个目录\n"
    p = tf.add_paragraph()
    p.font.name = '黑体'
    p.font.size = Pt(20)
    p.text = "● 第五个目录\n"
    p = tf.add_paragraph()
    p.font.name = '黑体'
    p.font.size = Pt(20)
    p.text = "● 第六个目录\n"
    prs.save('test.pptx')
Beispiel #8
0
def createPPTX(title, subtitle, draft, f, prs, content_slide):
    signCount = 0
    callCount = 0
    while draft:
        fileContent = str(draft.strip())
        if "#" in fileContent and not fileContent.lstrip().startswith('##'):
            try:
                type(PCDraft)
            except NameError:
                title.text = str(fileContent.replace("#", ""))
                prs.save(outfilename)
            else:
                try:
                    if(PCDraft != 0):
                        for shape in content_slide[PCDraft].shapes:
                            if not shape.has_text_frame:
                                continue
                            text_frame = shape.text_frame
                            p = text_frame.paragraphs[0]
                            p.text = fileContent.replace("#", "")
                    content_title = content_slide[PCDraft].shapes.title
                    content_title.text = str(fileContent.replace("#", ""))
                except(IndexError):
                    print(
                        "Pages is not equal to section in draft file.",
                        "exiting..."
                    )
                    sys.exit(1)
                except(UnboundLocalError):
                    print(
                        "Slide did not have content pages but the draft ",
                        "file specify one. Existing."
                    )
                    sys.exit(1)
                prs.save(outfilename)
        elif "##" in fileContent:
            subtitle.text = str(fileContent.replace("##", ""))
            prs.save(outfilename)
        elif "\\newpage" in fileContent:
            callCount += 1
            if args.pages <= 1:
                pass
            else:
                if callCount > 1:
                    PCDraft = signCount + 1
                    signCount += 1
                else:
                    PCDraft = 0

#        elif "content_title>" in fileContent:
#            try:
#                content_title = content_slide[PCDraft].shapes.title
#                content_title.text = str(fileContent.replace("%%%", ""))
#            except(IndexError):
#                print(
#                    "Pages is not equal to section in draft file.",
#                    "exiting..."
#                )
#                sys.exit(1)
#            except(UnboundLocalError):
#                print(
#                    "Slide did not have content pages but the draft ",
#                    "file specify one. Existing."
#                )
#                sys.exit(1)
#            prs.save(outfilename)

        elif "p>" in fileContent:
            try:
#                for shape in content_slide[PCDraft].shapes:
#                    if not shape.has_text_frame:
#                        continue
                    _, body, *_ = content_slide[PCDraft].shapes.placeholders
                    p = body.text_frame.add_paragraph()
                    p.text = fileContent.replace("p>", "")
                    p._pPr.insert(0, etree.Element("{http://schemas.openxmlformats.org/drawingml/2006/main}buNone"))
            except(IndexError):
                print("Pages is not enough. exiting...")
                sys.exit(1)
            prs.save(outfilename)
        elif "bgcl>" in fileContent:
            background = content_slide[PCDraft].background
            try:
                R, G, B = str(fileContent.replace("bgcl>", "")).split(",")
            except(ValueError):
                print(
                    "background value should be RGB value seperate ",
                    "by comma. Example: bgcl>255,255,255"
                )
                sys.exit(1)
            fill = background.fill
            fill.solid()
            try:
                fill.fore_color.rgb = RGBColor(int(R), int(G), int(B))
            except(ValueError):
                print(
                    "background value should be RGB value seperate by ",
                    "comma. Example: bgcl>255,255,255"
                )
                sys.exit(1)
            prs.save(outfilename)
        elif "-" in fileContent:
            try:
#                for shape in content_slide[PCDraft].shapes:
#                    if not shape.has_text_frame:
#                        continue
#                    text_frame = shape.text_frame
                    _, body, *_ = content_slide[PCDraft].shapes.placeholders
                    p = body.text_frame.add_paragraph()
                    p.level = 0
                    p.text = fileContent.replace("-","")
            except(IndexError):
                print("Page is not enough, exiting...")
                sys.exit(1)
            prs.save(outfilename)
                
        elif "img>" in fileContent:
            con_shapes = content_slide[PCDraft].shapes
            try:
                imgpath, x1, y1, x2, y2 = str(
                    fileContent.replace("img>",
                                        "")
                ).split(",")
            except(ValueError):
                print(
                    "image value should be image path, Position of ",
                    "image horizontal, Position of image verticle, ",
                    "size of image horizontal, size of image verticle in Inches."
                )
                sys.exit(1)
            try:
                con_shapes.add_picture(
                    str(imgpath), Inches(int(x1)),
                    Inches(int(y1)), Inches(int(x2)),
                    Inches(int(y2))
                )
            except(ValueError):
                print(
                    "image value should be image path, Position of ",
                    "image horizontal, Position of image verticle, ",
                    "size of image horizontal, size of image verticle in Inches."
                )
                sys.exit(1)
            except(FileNotFoundError):
                print("image file did not exist. Please try again.")
                sys.exit(1)
            prs.save(outfilename)
        elif "\n" or "\r\n" in fileContent:
            pass
        else:
            print(
                "draft file is corrupted. Check the format.txt file ",
                "and try again."
            )
        draft = f.readline()
Beispiel #9
0
class DescribeTextFrame(object):
    """Unit-test suite for `pptx.text.text.TextFrame` object."""

    def it_can_add_a_paragraph_to_itself(self, add_paragraph_fixture):
        text_frame, expected_xml = add_paragraph_fixture
        text_frame.add_paragraph()
        assert text_frame._txBody.xml == expected_xml

    def it_knows_its_autosize_setting(self, autosize_get_fixture):
        text_frame, expected_value = autosize_get_fixture
        assert text_frame.auto_size == expected_value

    def it_can_change_its_autosize_setting(self, autosize_set_fixture):
        text_frame, value, expected_xml = autosize_set_fixture
        text_frame.auto_size = value
        assert text_frame._txBody.xml == expected_xml

    @pytest.mark.parametrize(
        "txBody_cxml",
        (
            "p:txBody/(a:p,a:p,a:p)",
            'p:txBody/a:p/a:r/a:t"foo"',
            'p:txBody/a:p/(a:br,a:r/a:t"foo")',
            'p:txBody/a:p/(a:fld,a:br,a:r/a:t"foo")',
        ),
    )
    def it_can_clear_itself_of_content(self, txBody_cxml):
        text_frame = TextFrame(element(txBody_cxml), None)
        text_frame.clear()
        assert text_frame._element.xml == xml("p:txBody/a:p")

    def it_knows_its_margin_settings(self, margin_get_fixture):
        text_frame, prop_name, unit, expected_value = margin_get_fixture
        margin_value = getattr(text_frame, prop_name)
        assert getattr(margin_value, unit) == expected_value

    def it_can_change_its_margin_settings(self, margin_set_fixture):
        text_frame, prop_name, new_value, expected_xml = margin_set_fixture
        setattr(text_frame, prop_name, new_value)
        assert text_frame._txBody.xml == expected_xml

    def it_knows_its_vertical_alignment(self, anchor_get_fixture):
        text_frame, expected_value = anchor_get_fixture
        assert text_frame.vertical_anchor == expected_value

    def it_can_change_its_vertical_alignment(self, anchor_set_fixture):
        text_frame, new_value, expected_xml = anchor_set_fixture
        text_frame.vertical_anchor = new_value
        assert text_frame._element.xml == expected_xml

    def it_knows_its_word_wrap_setting(self, wrap_get_fixture):
        text_frame, expected_value = wrap_get_fixture
        assert text_frame.word_wrap == expected_value

    def it_can_change_its_word_wrap_setting(self, wrap_set_fixture):
        text_frame, new_value, expected_xml = wrap_set_fixture
        text_frame.word_wrap = new_value
        assert text_frame._element.xml == expected_xml

    def it_provides_access_to_its_paragraphs(self, paragraphs_fixture):
        text_frame, ps = paragraphs_fixture
        paragraphs = text_frame.paragraphs
        assert len(paragraphs) == len(ps)
        for idx, paragraph in enumerate(paragraphs):
            assert isinstance(paragraph, _Paragraph)
            assert paragraph._element is ps[idx]

    def it_raises_on_attempt_to_set_margin_to_non_int(self):
        text_frame = TextFrame(element("p:txBody/a:bodyPr"), None)
        with pytest.raises(TypeError):
            text_frame.margin_bottom = "0.1"

    def it_knows_the_part_it_belongs_to(self, text_frame_with_parent_):
        text_frame, parent_ = text_frame_with_parent_
        part = text_frame.part
        assert part is parent_.part

    def it_knows_what_text_it_contains(
        self, request, text_get_fixture, paragraphs_prop_
    ):
        paragraph_texts, expected_value = text_get_fixture
        paragraphs_prop_.return_value = tuple(
            instance_mock(request, _Paragraph, text=text) for text in paragraph_texts
        )
        text_frame = TextFrame(None, None)

        text = text_frame.text

        assert text == expected_value

    def it_can_replace_the_text_it_contains(self, text_set_fixture):
        txBody, text, expected_xml = text_set_fixture
        text_frame = TextFrame(txBody, None)

        text_frame.text = text

        assert text_frame._element.xml == expected_xml

    def it_can_resize_its_text_to_best_fit(self, request, text_prop_):
        family, max_size, bold, italic, font_file, font_size = (
            "Family",
            42,
            "bold",
            "italic",
            "font_file",
            21,
        )
        text_prop_.return_value = "some text"
        _best_fit_font_size_ = method_mock(
            request, TextFrame, "_best_fit_font_size", return_value=font_size
        )
        _apply_fit_ = method_mock(request, TextFrame, "_apply_fit")
        text_frame = TextFrame(None, None)

        text_frame.fit_text(family, max_size, bold, italic, font_file)

        _best_fit_font_size_.assert_called_once_with(
            text_frame, family, max_size, bold, italic, font_file
        )
        _apply_fit_.assert_called_once_with(text_frame, family, font_size, bold, italic)

    def it_calculates_its_best_fit_font_size_to_help_fit_text(self, size_font_fixture):
        text_frame, family, max_size, bold, italic = size_font_fixture[:5]
        FontFiles_, TextFitter_, text, extents = size_font_fixture[5:9]
        font_file_, font_size_ = size_font_fixture[9:]

        font_size = text_frame._best_fit_font_size(family, max_size, bold, italic, None)

        FontFiles_.find.assert_called_once_with(family, bold, italic)
        TextFitter_.best_fit_font_size.assert_called_once_with(
            text, extents, max_size, font_file_
        )
        assert font_size is font_size_

    def it_calculates_its_effective_size_to_help_fit_text(self):
        sp_cxml = (
            "p:sp/(p:spPr/a:xfrm/(a:off{x=914400,y=914400},a:ext{cx=914400,c"
            "y=914400}),p:txBody/(a:bodyPr,a:p))"
        )
        text_frame = Shape(element(sp_cxml), None).text_frame
        assert text_frame._extents == (731520, 822960)

    def it_applies_fit_to_help_fit_text(self, request):
        family, font_size, bold, italic = "Family", 42, True, False
        _set_font_ = method_mock(request, TextFrame, "_set_font")
        text_frame = TextFrame(element("p:txBody/a:bodyPr"), None)

        text_frame._apply_fit(family, font_size, bold, italic)

        assert text_frame.auto_size is MSO_AUTO_SIZE.NONE
        assert text_frame.word_wrap is True
        _set_font_.assert_called_once_with(text_frame, family, font_size, bold, italic)

    def it_sets_its_font_to_help_fit_text(self, set_font_fixture):
        text_frame, family, size, bold, italic, expected_xml = set_font_fixture
        text_frame._set_font(family, size, bold, italic)
        assert text_frame._element.xml == expected_xml

    # fixtures ---------------------------------------------

    @pytest.fixture(
        params=[
            ("p:txBody/a:bodyPr", "p:txBody/(a:bodyPr,a:p)"),
            ("p:txBody/(a:bodyPr,a:p)", "p:txBody/(a:bodyPr,a:p,a:p)"),
        ]
    )
    def add_paragraph_fixture(self, request):
        txBody_cxml, expected_cxml = request.param
        text_frame = TextFrame(element(txBody_cxml), None)
        expected_xml = xml(expected_cxml)
        return text_frame, expected_xml

    @pytest.fixture(
        params=[
            ("p:txBody/a:bodyPr", None),
            ("p:txBody/a:bodyPr{anchor=t}", MSO_ANCHOR.TOP),
            ("p:txBody/a:bodyPr{anchor=b}", MSO_ANCHOR.BOTTOM),
        ]
    )
    def anchor_get_fixture(self, request):
        txBody_cxml, expected_value = request.param
        text_frame = TextFrame(element(txBody_cxml), None)
        return text_frame, expected_value

    @pytest.fixture(
        params=[
            ("p:txBody/a:bodyPr", MSO_ANCHOR.TOP, "p:txBody/a:bodyPr{anchor=t}"),
            (
                "p:txBody/a:bodyPr{anchor=t}",
                MSO_ANCHOR.MIDDLE,
                "p:txBody/a:bodyPr{anchor=ctr}",
            ),
            (
                "p:txBody/a:bodyPr{anchor=ctr}",
                MSO_ANCHOR.BOTTOM,
                "p:txBody/a:bodyPr{anchor=b}",
            ),
            ("p:txBody/a:bodyPr{anchor=b}", None, "p:txBody/a:bodyPr"),
        ]
    )
    def anchor_set_fixture(self, request):
        txBody_cxml, new_value, expected_cxml = request.param
        text_frame = TextFrame(element(txBody_cxml), None)
        expected_xml = xml(expected_cxml)
        return text_frame, new_value, expected_xml

    @pytest.fixture(
        params=[
            ("p:txBody/a:bodyPr", None),
            ("p:txBody/a:bodyPr/a:noAutofit", MSO_AUTO_SIZE.NONE),
            ("p:txBody/a:bodyPr/a:spAutoFit", MSO_AUTO_SIZE.SHAPE_TO_FIT_TEXT),
            ("p:txBody/a:bodyPr/a:normAutofit", MSO_AUTO_SIZE.TEXT_TO_FIT_SHAPE),
        ]
    )
    def autosize_get_fixture(self, request):
        txBody_cxml, expected_value = request.param
        text_frame = TextFrame(element(txBody_cxml), None)
        return text_frame, expected_value

    @pytest.fixture(
        params=[
            ("p:txBody/a:bodyPr", MSO_AUTO_SIZE.NONE, "p:txBody/a:bodyPr/a:noAutofit"),
            (
                "p:txBody/a:bodyPr/a:noAutofit",
                MSO_AUTO_SIZE.SHAPE_TO_FIT_TEXT,
                "p:txBody/a:bodyPr/a:spAutoFit",
            ),
            (
                "p:txBody/a:bodyPr/a:spAutoFit",
                MSO_AUTO_SIZE.TEXT_TO_FIT_SHAPE,
                "p:txBody/a:bodyPr/a:normAutofit",
            ),
            ("p:txBody/a:bodyPr/a:normAutofit", None, "p:txBody/a:bodyPr"),
        ]
    )
    def autosize_set_fixture(self, request):
        txBody_cxml, value, expected_cxml = request.param
        text_frame = TextFrame(element(txBody_cxml), None)
        expected_xml = xml(expected_cxml)
        return text_frame, value, expected_xml

    @pytest.fixture(
        params=[
            ("p:txBody/a:bodyPr", "left", "emu", Inches(0.1)),
            ("p:txBody/a:bodyPr", "top", "emu", Inches(0.05)),
            ("p:txBody/a:bodyPr", "right", "emu", Inches(0.1)),
            ("p:txBody/a:bodyPr", "bottom", "emu", Inches(0.05)),
            ("p:txBody/a:bodyPr{lIns=9144}", "left", "cm", 0.0254),
            ("p:txBody/a:bodyPr{tIns=18288}", "top", "mm", 0.508),
            ("p:txBody/a:bodyPr{rIns=76200}", "right", "pt", 6.0),
            ("p:txBody/a:bodyPr{bIns=36576}", "bottom", "inches", 0.04),
        ]
    )
    def margin_get_fixture(self, request):
        txBody_cxml, side, unit, expected_value = request.param
        text_frame = TextFrame(element(txBody_cxml), None)
        prop_name = "margin_%s" % side
        return text_frame, prop_name, unit, expected_value

    @pytest.fixture(
        params=[
            (
                "p:txBody/a:bodyPr",
                "left",
                Inches(0.11),
                "p:txBody/a:bodyPr{lIns=100584}",
            ),
            (
                "p:txBody/a:bodyPr{tIns=1234}",
                "top",
                Inches(0.12),
                "p:txBody/a:bodyPr{tIns=109728}",
            ),
            (
                "p:txBody/a:bodyPr{rIns=2345}",
                "right",
                Inches(0.13),
                "p:txBody/a:bodyPr{rIns=118872}",
            ),
            (
                "p:txBody/a:bodyPr{bIns=3456}",
                "bottom",
                Inches(0.14),
                "p:txBody/a:bodyPr{bIns=128016}",
            ),
            ("p:txBody/a:bodyPr", "left", Inches(0.1), "p:txBody/a:bodyPr"),
            ("p:txBody/a:bodyPr", "top", Inches(0.05), "p:txBody/a:bodyPr"),
            ("p:txBody/a:bodyPr", "right", Inches(0.1), "p:txBody/a:bodyPr"),
            ("p:txBody/a:bodyPr", "bottom", Inches(0.05), "p:txBody/a:bodyPr"),
        ]
    )
    def margin_set_fixture(self, request):
        txBody_cxml, side, new_value, expected_txBody_cxml = request.param
        text_frame = TextFrame(element(txBody_cxml), None)
        prop_name = "margin_%s" % side
        expected_xml = xml(expected_txBody_cxml)
        return text_frame, prop_name, new_value, expected_xml

    @pytest.fixture(params=["p:txBody", "p:txBody/a:p", "p:txBody/(a:p,a:p)"])
    def paragraphs_fixture(self, request):
        txBody_cxml = request.param
        txBody = element(txBody_cxml)
        text_frame = TextFrame(txBody, None)
        ps = txBody.xpath(".//a:p")
        return text_frame, ps

    @pytest.fixture(
        params=[
            (
                "p:txBody/(a:bodyPr,a:p/a:r)",
                True,
                False,
                "p:txBody/(a:bodyPr,a:p/(a:r/a:rPr{sz=600,b=1,i=0}/a:latin{typeface"
                "=F},a:endParaRPr{sz=600,b=1,i=0}/a:latin{typeface=F}))",
            ),
            (
                "p:txBody/a:p/a:br",
                True,
                False,
                "p:txBody/a:p/(a:br/a:rPr{sz=600,b=1,i=0}/a:latin{typeface=F},a:end"
                "ParaRPr{sz=600,b=1,i=0}/a:latin{typeface=F})",
            ),
            (
                "p:txBody/a:p/a:fld",
                True,
                False,
                "p:txBody/a:p/(a:fld/a:rPr{sz=600,b=1,i=0}/a:latin{typeface=F},a:en"
                "dParaRPr{sz=600,b=1,i=0}/a:latin{typeface=F})",
            ),
        ]
    )
    def set_font_fixture(self, request):
        txBody_cxml, bold, italic, expected_cxml = request.param
        family, size = "F", 6
        text_frame = TextFrame(element(txBody_cxml), None)
        expected_xml = xml(expected_cxml)
        return text_frame, family, size, bold, italic, expected_xml

    @pytest.fixture
    def size_font_fixture(self, FontFiles_, TextFitter_, text_prop_, _extents_prop_):
        text_frame = TextFrame(None, None)
        family, max_size, bold, italic = "Family", 42, True, False
        text, extents, font_size, font_file = "text", (111, 222), 21, "f.ttf"
        text_prop_.return_value = text
        _extents_prop_.return_value = extents
        FontFiles_.find.return_value = font_file
        TextFitter_.best_fit_font_size.return_value = font_size
        return (
            text_frame,
            family,
            max_size,
            bold,
            italic,
            FontFiles_,
            TextFitter_,
            text,
            extents,
            font_file,
            font_size,
        )

    @pytest.fixture(
        params=[(["foobar"], "foobar"), (["foo", "bar", "baz"], "foo\nbar\nbaz")]
    )
    def text_get_fixture(self, request):
        paragraph_texts, expected_value = request.param
        return paragraph_texts, expected_value

    @pytest.fixture(
        params=[
            # ---empty to something---
            ("p:txBody/a:p", "foobar", 'p:txBody/a:p/a:r/a:t"foobar"'),
            # ---something to something else---
            ('p:txBody/a:p/a:r/a:t"foobar"', "barfoo", 'p:txBody/a:p/a:r/a:t"barfoo"'),
            # ---single paragraph to multiple---
            (
                'p:txBody/a:p/a:r/a:t"barfoo"',
                "foo\nbar",
                'p:txBody/(a:p/a:r/a:t"foo",a:p/a:r/a:t"bar")',
            ),
            # ---multiple paragraphs to single---
            (
                'p:txBody/(a:p/a:r/a:t"foo",a:p/a:r/a:t"bar")',
                "barfoo",
                'p:txBody/a:p/a:r/a:t"barfoo"',
            ),
            # ---something to empty---
            ('p:txBody/a:p/a:r/a:t"foobar"', "", "p:txBody/a:p"),
            # ---vertical-tab becomes line-break---
            ("p:txBody/a:p", "a\vb", 'p:txBody/a:p/(a:r/a:t"a",a:br,a:r/a:t"b")'),
        ]
    )
    def text_set_fixture(self, request):
        txBody_cxml, text, expected_cxml = request.param
        txBody = element(txBody_cxml)
        expected_xml = xml(expected_cxml)
        return txBody, text, expected_xml

    @pytest.fixture(
        params=[
            ("p:txBody/a:bodyPr", None),
            ("p:txBody/a:bodyPr{wrap=square}", True),
            ("p:txBody/a:bodyPr{wrap=none}", False),
        ]
    )
    def wrap_get_fixture(self, request):
        txBody_cxml, expected_value = request.param
        text_frame = TextFrame(element(txBody_cxml), None)
        return text_frame, expected_value

    @pytest.fixture(
        params=[
            ("p:txBody/a:bodyPr", True, "p:txBody/a:bodyPr{wrap=square}"),
            ("p:txBody/a:bodyPr{wrap=square}", False, "p:txBody/a:bodyPr{wrap=none}"),
            ("p:txBody/a:bodyPr{wrap=none}", None, "p:txBody/a:bodyPr"),
        ]
    )
    def wrap_set_fixture(self, request):
        txBody_cxml, new_value, expected_txBody_cxml = request.param
        text_frame = TextFrame(element(txBody_cxml), None)
        expected_xml = xml(expected_txBody_cxml)
        return text_frame, new_value, expected_xml

    # fixture components -----------------------------------

    @pytest.fixture
    def _extents_prop_(self, request):
        return property_mock(request, TextFrame, "_extents")

    @pytest.fixture
    def FontFiles_(self, request):
        return class_mock(request, "pptx.text.text.FontFiles")

    @pytest.fixture
    def paragraphs_prop_(self, request):
        return property_mock(request, TextFrame, "paragraphs")

    @pytest.fixture
    def TextFitter_(self, request):
        return class_mock(request, "pptx.text.text.TextFitter")

    @pytest.fixture
    def text_frame_with_parent_(self, request):
        parent_ = loose_mock(request, name="parent_")
        text_frame = TextFrame(None, parent_)
        return text_frame, parent_

    @pytest.fixture
    def text_prop_(self, request):
        return property_mock(request, TextFrame, "text")
Beispiel #10
0
def plotFullJetSlides(slide, txBox, plotDir, isPtHard, isPbPb, includePHOS,
                      isAllRuns, run):

    # columns
    leftEdge = 0.1
    midEdge = 1.6
    rightEdge = 5.0
    if isPbPb:
        leftEdge = 0.1
        midEdge = 3.3
        rightEdge = 6.6
    # rows
    topEdge = 0.8
    midVertEdge = 2.9
    lowEdge = 5.1
    if isPbPb:
        topEdge = 0.8
        midVertEdge = 2.9
        lowEdge = 5.1
    #Figure width
    imgWidth = 4.0
    if isPbPb:
        imgWidth = 3.2
    titlewidth = Inches(7.)
    titleleft = Inches(2.5)

    tf = txBox.text_frame
    tf.text = "Run " + str(run) + " -- Full Jets"
    if isAllRuns:
        tf.text = "All Runs -- Full Jets"
    tf.fit_text('Calibri', 36)

    #- - - - - - - - - - - - - - -
    #Top row figures
    if isPbPb:
        img_path = plotDir + str(run) + "/QAoutput/Jets/hFullJetPtCorrCalo.png"
    else:
        img_path = plotDir + str(run) + "/QAoutput/Jets/hFullJetPt.png"
#img_path = plotDir + str(run) + "/QAoutput/Jets/hFullJetPtCalo.png" #comparision of different jet types
    left = Inches(leftEdge)
    top = Inches(topEdge - 0.1)
    width = Inches(imgWidth * 1.1)
    if isAllRuns:
        top = Inches(topEdge)
        width = Inches(imgWidth * 1.2)
    if isPbPb:
        width = Inches(imgWidth * 1.05)
    slide.shapes.add_picture(img_path, left, top, width=width)

    if isPbPb:
        img_path = plotDir + str(run) + "/QAoutput/Jets/hFullJetPt.png"
        left = Inches(midEdge)
        top = Inches(topEdge - 0.1)
        if isAllRuns:
            top = Inches(topEdge)
        width = Inches(imgWidth * 1.05)
        slide.shapes.add_picture(img_path, left, top, width=width)

    img_path = plotDir + str(run) + "/QAoutput/Jets/hFullJetEtaPhi.png"
    left = Inches(rightEdge)
    top = Inches(topEdge)
    width = Inches(imgWidth * 1.1)
    if isPbPb:
        width = Inches(imgWidth)
    slide.shapes.add_picture(img_path, left, top, width=width)

    if isPbPb:
        img_path = plotDir + str(
            run) + "/QAoutput/Jets/hChargedJetRhoVsCent.png"
        left = Inches(rightEdge)
        top = Inches(topEdge + 2.2)
        width = Inches(imgWidth)
        slide.shapes.add_picture(img_path, left, top, width=width)

    #- - - - - - - - - - - - - - -
    #Bottom row figures
    # if isAllRuns and isPbPb:

    img_path = plotDir + str(run) + "/QAoutput/Jets/hDeltaEHadCorrProf.png"
    left = Inches(leftEdge)
    top = Inches(lowEdge + 0.1)
    width = Inches(3.2)
    if os.path.exists(img_path):
        slide.shapes.add_picture(img_path, left, top, width=width)

    img_path = plotDir + str(run) + "/QAoutput/Jets/hFullJetNEF.png"
    left = Inches(rightEdge + 1.6)
    top = Inches(lowEdge + 0.1)
    width = Inches(3.2)
    if os.path.exists(img_path):
        slide.shapes.add_picture(img_path, left, top, width=width)

    img_path = plotDir + str(run) + "/QAoutput/Jets/hFullJetPtLeadjetPt.png"
    left = Inches(leftEdge + 1)
    if isPbPb:
        left = Inches(midEdge)
    else:
        left = Inches(3.3)
    top = Inches(lowEdge + 0.1)
    width = Inches(3.2)
    slide.shapes.add_picture(img_path, left, top, width=width)
Beispiel #11
0
    shapes = slide.shapes

    shapes.title.text = 'Simulation Report'

    # 定义表格数据 ------
    name_objects = ["object1", "object2", "object3"]
    name_AIs = ["AI1", "AI2", "AI3"]
    val_AI1 = (19.2, 21.4, 16.7)
    val_AI2 = (22.3, 28.6, 15.2)
    val_AI3 = (20.4, 26.3, 14.2)
    val_AIs = [val_AI1, val_AI2, val_AI3]

    # 表格样式 --------------------
    rows = 4
    cols = 4
    top = Inches(1.5)
    left = Inches(1)  #Inches(2.0)
    width = Inches(2)  # Inches(6.0)
    height = Inches(0.5)  # Inches(0.8)

    # 添加表格到幻灯片 --------------------
    table = shapes.add_table(rows, cols, left, top, width, height).table

    # 设置单元格宽度
    table.columns[0].width = Inches(2)  # Inches(2.0)
    table.columns[1].width = Inches(2)
    table.columns[2].width = Inches(2)
    table.columns[3].width = Inches(2)

    # 设置标题行
    table.cell(0, 1).text = name_objects[0]
Beispiel #12
0
def plotChargedJetSlides(slide, txBox, plotDir, isPtHard, isPbPb, includePHOS,
                         isAllRuns, run):

    imgWidth = 3.3
    # columns
    leftEdge = 0.1
    midEdge = 1.6
    rightEdge = 5.0
    if isPbPb:
        leftEdge = 0.1
        midEdge = 3.3
        rightEdge = 6.6
    # rows
    topEdge = 0.8
    midVertEdge = 2.9
    lowEdge = 5.1
    if isPbPb:
        topEdge = 0.8
        midVertEdge = 2.9
        lowEdge = 5.1

    imgWidth = 4.0
    if isPbPb:
        imgWidth = 3.2
    titlewidth = Inches(7.)
    titleleft = Inches(2.5)

    tf = txBox.text_frame
    tf.text = "Run " + str(run) + " -- Charged Jets"
    if isAllRuns:
        tf.text = "All Runs -- Charged Jets"
    tf.fit_text('Calibri', 36)

    if isAllRuns and isPbPb:
        img_path = plotDir + str(
            run) + "/QAoutput/Jets/hChargedJetPtCorrCentral.png"
        left = Inches(rightEdge - 1.)
        top = Inches(topEdge - 0.1)
        width = Inches(imgWidth * 1.2)
        slide.shapes.add_picture(img_path, left, top, width=width)

        img_path = plotDir + str(
            run) + "/QAoutput/Jets/hChargedJetRhoVsCent.png"
        left = Inches(leftEdge)
        top = Inches(lowEdge - 0.5)
        width = Inches(imgWidth)
        slide.shapes.add_picture(img_path, left, top, width=width)

    if isPbPb:
        img_path = plotDir + str(run) + "/QAoutput/Jets/hChargedJetPtCorr.png"
    else:
        img_path = plotDir + str(run) + "/QAoutput/Jets/hChargedJetPt.png"
    left = Inches(leftEdge + 1)
    top = Inches(topEdge - 0.1)
    width = Inches(imgWidth)
    if isAllRuns:
        top = Inches(topEdge)
        width = Inches(imgWidth * 1.2)
    slide.shapes.add_picture(img_path, left, top, width=width)

    img_path = plotDir + str(run) + "/QAoutput/Jets/hChargedJetPtLeadjetPt.png"
    left = Inches(leftEdge + 1)
    if isPbPb:
        left = Inches(midEdge)
    top = Inches(lowEdge - 0.5)
    width = Inches(imgWidth)
    slide.shapes.add_picture(img_path, left, top, width=width)

    img_path = plotDir + str(run) + "/QAoutput/Jets/hChargedJetEtaPhi.png"
    left = Inches(rightEdge)
    top = Inches(lowEdge - 0.5)
    if isPbPb:
        top = Inches(lowEdge - 0.5)
    width = Inches(imgWidth)
    slide.shapes.add_picture(img_path, left, top, width=width)

    if not isAllRuns:
        img_path = plotDir + str(
            run) + "/QAoutput/Jets/hChargedJetEtaPhiRatio.png"
        left = Inches(rightEdge)
        top = Inches(topEdge - 0.1)
        width = Inches(imgWidth)
        slide.shapes.add_picture(img_path, left, top, width=width)
Beispiel #13
0
def plotClusterSlides(slide, txBox, plotDir, isPtHard, isPbPb, includePHOS,
                      isAllRuns, run):

    # print("Plot cluster slide")
    # print("Is pT hard: %s" % isPtHard)
    # print("Is PbPb data: %s" % isPbPb)
    # print("Includes PHOS info: %s" % includePHOS)
    # print("Is all run: %s" % isAllRuns)

    ## Settings
    ## If phos is included phos E spectrum and ratio to other clusters is plotted on the right
    ## Side of the slide
    ## If phos is not included the eta phi distribution is expanded instead

    imgWidth = 3.3
    # columns
    leftEdge = 0.1
    midEdge = 3.3
    rightEdge = 6.6
    # rows
    topEdge = 0.8
    midVertEdge = 2.9
    lowEdge = 5.1

    tf = txBox.text_frame
    tf.text = "Run " + str(run) + " -- Clusters"
    if isAllRuns:
        tf.text = "All Runs -- Clusters"
    tf.fit_text('Calibri', 36)

    img_path = plotDir + str(run) + "/QAoutput/Clusters/hClusEMCalEnergy.png"
    left = Inches(leftEdge)
    top = Inches(topEdge)
    width = Inches(imgWidth)
    slide.shapes.add_picture(img_path, left, top, width=width)

    img_path = plotDir + str(run) + "/QAoutput/Clusters/hClusDCalEnergy.png"
    if os.path.exists(img_path):
        left = Inches(midEdge)
        top = Inches(topEdge)
        width = Inches(imgWidth)
        slide.shapes.add_picture(img_path, left, top, width=width)

    if includePHOS:
        img_path = plotDir + str(
            run) + "/QAoutput/Clusters/hClusPHOSEnergy.png"
        if os.path.exists(img_path):
            left = Inches(rightEdge)
            top = Inches(topEdge)
            width = Inches(imgWidth)
            slide.shapes.add_picture(img_path, left, top, width=width)
    if not isAllRuns and not includePHOS:
        #img_path = plotDir + str(run) + "/QAoutput/Cells/profCellAbsIdTime.png"  #this is helpful in case there is an increased cluster/event yield
        img_path = plotDir + str(
            run
        ) + "/QAoutput/Cells/hCellEnergyTselRatio.png"  #This checks the cluster yield after timing cuts
        left = Inches(rightEdge)
        top = Inches(topEdge)
        width = Inches(imgWidth)
        slide.shapes.add_picture(img_path, left, top, width=width)

    img_path = plotDir + str(run) + "/QAoutput/Clusters/hClusPhiEta.png"
    left = Inches(leftEdge)
    top = Inches(lowEdge - 1)
    width = Inches(imgWidth * 1.4)
    if isAllRuns:
        left = Inches(midEdge)
        top = Inches(lowEdge - 1.7)
        if includePHOS:
            #left = Inches(midEdge-0.5)
            top = Inches(lowEdge - 1)
            width = Inches(imgWidth)
    slide.shapes.add_picture(img_path, left, top, width=width)

    if not isAllRuns:
        img_path = plotDir + str(
            run) + "/QAoutput/Clusters/hClusPhiEtaRatio.png"
        left = Inches(rightEdge - 1.5)
        top = Inches(lowEdge - 1)
        width = Inches(imgWidth * 1.4)
#what about phos case?
    slide.shapes.add_picture(img_path, left, top, width=width)

    if isAllRuns:
        img_path = plotDir + str(
            run) + "/QAoutput/Clusters/hClusEnergyRatioEMC.png"
        left = Inches(leftEdge)
        top = Inches(lowEdge - 0.9)
        if isAllRuns:
            top = Inches(lowEdge - 1.6)
        width = Inches(imgWidth)
        slide.shapes.add_picture(img_path, left, top, width=width)

        if includePHOS:
            img_path = plotDir + str(
                run) + "/QAoutput/Clusters/hClusEnergyRatio.png"
            left = Inches(rightEdge)
            top = Inches(lowEdge - 1.6)
            width = Inches(imgWidth)
            slide.shapes.add_picture(img_path, left, top, width=width)
Beispiel #14
0
def plotTrackSlides(slide, txBox, plotDir, isPtHard, isPbPb, isAllRuns, run):

    imgWidth = 3.3
    # columns
    leftEdge = 0.1
    midEdge = 3.3
    rightEdge = 6.6
    # rows
    topEdge = 1.5
    midVertEdge = 2.9
    lowEdge = 5.1

    # Title
    tf = txBox.text_frame
    tf.text = "Run " + str(run) + " -- Tracks"
    if isAllRuns:
        tf.text = "All Runs -- Tracks"
    tf.fit_text('Calibri', 40)

    img_path = plotDir + str(run) + "/QAoutput/EventQA/hEventReject.png"
    left = Inches(leftEdge)
    top = Inches(topEdge)
    width = Inches(imgWidth)
    slide.shapes.add_picture(img_path, left, top, width=width)

    img_path = plotDir + str(run) + "/QAoutput/Tracks/hTrackPt.png"
    left = Inches(midEdge)
    top = Inches(topEdge - 0.5)
    if isAllRuns:
        top = Inches(topEdge)
    width = Inches(imgWidth)
    slide.shapes.add_picture(img_path, left, top, width=width)

    img_path = plotDir + str(
        run) + "/QAoutput/Tracks/profTrackPtResolution.png"
    left = Inches(rightEdge)
    top = Inches(topEdge)
    width = Inches(imgWidth)
    slide.shapes.add_picture(img_path, left, top, width=width)

    img_path = plotDir + str(run) + "/QAoutput/Tracks/hTrackPhi.png"
    left = Inches(leftEdge)
    top = Inches(lowEdge - 0.5)
    width = Inches(imgWidth)
    slide.shapes.add_picture(img_path, left, top, width=width)

    img_path = plotDir + str(run) + "/QAoutput/Tracks/hTrackEta.png"
    left = Inches(midEdge)
    top = Inches(lowEdge - 0.5)
    width = Inches(imgWidth)
    slide.shapes.add_picture(img_path, left, top, width=width)

    img_path = plotDir + str(run) + "/QAoutput/Tracks/hTrackEtaPhi.png"
    left = Inches(rightEdge)
    top = Inches(lowEdge - 0.5)
    width = Inches(imgWidth)
    slide.shapes.add_picture(img_path, left, top, width=width)
Beispiel #15
0
def diapo(nom):

#slide 1 

    img_path = 'picsellia.png'
    prs = Presentation()
    title_slide_layout = prs.slide_layouts[0]
    slide = prs.slides.add_slide(title_slide_layout)
    title = slide.shapes.title
    subtitle = slide.placeholders[1]
    date = datetime.datetime.now().strftime("%y-%m-%d")
    img_path1 = 'picsellia.png'
    
    
    title.text = "Rapport d'avancée"
    subtitle.text = "Picsell.ia - 15/07/2019"
    
    left = Inches(4)
    top = Inches(0.2)
    width = Inches (2)
    height = Inches (2.6)
    pic = slide. shapes. add_picture(img_path, left, top, width, height)
    
    left = Inches(9.1)
    top = Inches(0.15)
    width = Inches (0.7)
    height = Inches (0.9)
    pic = slide. shapes. add_picture(img_path1, left, top, width, height)
    
    
    #slide2
    
    bullet_slide_layout = prs.slide_layouts[1]
    
    slide = prs.slides.add_slide(bullet_slide_layout)
    shapes = slide.shapes
    
    title_shape = shapes.title
    body_shape = shapes.placeholders[1]
    
    #partie pour mettre la photo dans le coin 
    img_path1 = 'picsellia.png'
    left = Inches(9.1)
    top = Inches(0.15)
    width = Inches (0.7)
    height = Inches (0.9)
    pic = slide. shapes. add_picture(img_path1, left, top, width, height)
    
    
    #titre
    left = Inches (0.5)
    top = Inches(0.2)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    p = tf.add_paragraph()
    p.text = "Contextualisation"
    p.font.size = Pt(40)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(50, 171, 104)
    
    
    #j'ai créé plusieurs boites de textes car comme je le disais j'ai pas trouvé comment
    #faire en sorte de retourner à la ligne sans casser la typologie
    #j'ai fait un petit bout de code (à côté) qui me permettait de savoir si 
    #le nombre de caractères était trop grand et ferait dépasser de la ligne et
    #qui disait vers où s'arrêter; ca m'a été un peu utile
    
    #j'ai pris 0.2 pour un retour à la ligne et 0.5 pour un saut de ligne 
    
    left = Inches (0.5)
    top = Inches(1.4)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    p = tf.add_paragraph()
    p.text = "Rendez-vous pris en mars 2019, nous vous avions présenté notre projet de start-up :"
    p.font.size = Pt(14)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(127, 127, 127)
    p.font.underline = MSO_UNDERLINE.SINGLE_LINE
    
    
    left = Inches (0.5)
    top = Inches(1.9)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    p = tf.add_paragraph()
    p.text = "Nous sommes spécialisés en annotation semi automatique de base de données d'images,"
    p.font.size = Pt(14)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(127, 127, 127)
    
    left = Inches (0.5)
    top = Inches(2.1)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    p = tf.add_paragraph()
    p.text = "de vidéos, de textes et de sons nécessaires au déploiement de vos solutions IA."
    p.font.size = Pt(14)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(127, 127, 127)
    
    left = Inches (0.5)
    top = Inches(2.6)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    p = tf.add_paragraph()
    p.text = "Nous avions besoin de données pour tester notre service, vous nous avez donc envoyé votre dataset"
    p.font.size = Pt(14)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(127, 127, 127)
    
    
    left = Inches (0.5)
    top = Inches(2.8)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    p = tf.add_paragraph()
    p.text = "contenant des déchets PET ou non PET / Alimentaire non Alimentaire / Bouteille Barquette."
    p.font.size = Pt(14)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(127, 127, 127)
    
    left = Inches (0.5)
    top = Inches(3.3)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    p = tf.add_paragraph()
    p.text = "Ce dataset s'inscrivant dans votre volonté de développer des solutions de tri via intelligence"
    p.font.size = Pt(14)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(127, 127, 127)
    
    left = Inches (0.5)
    top = Inches(3.5)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    p = tf.add_paragraph()
    p.text = "artificielle, la labellisation de données n'étant pas votre principal problème car vous avez"
    p.font.size = Pt(14)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(127, 127, 127)
    
    left = Inches (0.5)
    top = Inches(3.7)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    p = tf.add_paragraph()
    p.text = "la main sur vos données, vous nous aviez proposé de vous présenter nos résultats afin que"
    p.font.size = Pt(14)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(127, 127, 127)
    
    left = Inches (0.5)
    top = Inches(3.9)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    p = tf.add_paragraph()
    p.text = "vous puissiez déterminer si notre service répond ou non à vos besoins."
    p.font.size = Pt(14)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(127, 127, 127)
    
    left = Inches (0.5)
    top = Inches(4.4)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    p = tf.add_paragraph()
    p.text = "Nous avons toutefois tenu à faire de nombreuses analyses de vos données, afin de vous donner"
    p.font.size = Pt(14)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(127, 127, 127)
    
    left = Inches (0.5)
    top = Inches(4.6)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    p = tf.add_paragraph()
    p.text = "le plus d'informations possibles et vous présenter les pistes possibles de développement de votre projet."
    p.font.size = Pt(14)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(127, 127, 127)
    
    left = Inches (0.5)
    top = Inches(5.1)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    p = tf.add_paragraph()
    p.text = "Dans un second temps nous allons vous présenter notre service et ce qu'il peut vous apporter."
    p.font.size = Pt(14)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(127, 127, 127)
    
    
    #slide 3 
    
    bullet_slide_layout = prs.slide_layouts[1]
    
    slide = prs.slides.add_slide(bullet_slide_layout)
    shapes = slide.shapes
    
    title_shape = shapes.title
    body_shape = shapes.placeholders[1]
    
    #partie pour mettre la photo dans le coin 
    img_path1 = 'picsellia.png'
    left = Inches(9.1)
    top = Inches(0.15)
    width = Inches (0.7)
    height = Inches (0.9)
    pic = slide. shapes. add_picture(img_path1, left, top, width, height)
    
    
    left = Inches (0.5)
    top = Inches(0.2)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    p = tf.add_paragraph()
    p.text = "Les prérequis de votre projet"
    p.font.size = Pt(40)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(50, 171, 104)
    
    
    
    #ici je voulais créer un objet et le mettre ensuite en vert mais des deux facons si desosus
    #j'ai pas réussi parceque les connecteurs et les formes marchent pas directement avec ca
    #du coup à court d'idées et j'ai mis une photo de barre verte
    
    
    #line1=slide.shapes.add_connector(MSO_CONNECTOR.STRAIGHT, Inches(5), Inches(1.7), Inches(5), Inches(6.7))
    
    #line1=slide.shapes.add_shape(MSO_SHAPE.RECTANGLE, Inches(5), Inches(1.7), Inches(5), Inches(6.7))
    #line1.color.rgb = RGBColor(50, 171, 104)
    img_path1 = 'ligne.png'
    left = Inches(9.1)
    top = Inches(0.15)
    width = Inches (0.7)
    height = Inches (0.9)
    pic = slide. shapes. add_picture(img_path1,Inches(5), Inches(1.7), Inches(0.10), Inches(5))
    
    left = Inches (0.5)
    top = Inches(1.8)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    p = tf.add_paragraph()
    p.text = "Pertinence de vos données"
    p.font.size = Pt(26)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(0,0,0)
    p.font.underline = MSO_UNDERLINE.SINGLE_LINE
    
    left = Inches (0.5)
    top = Inches(2.1)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    p = tf.add_paragraph()
    p.text = "pour votre use-case :"
    p.font.size = Pt(26)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(0,0,0)
    p.font.underline = MSO_UNDERLINE.SINGLE_LINE
    
    left = Inches (0.4)
    top = Inches(3.5)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    p = tf.add_paragraph()
    p.text = " - Dataset ayant la même proportion"
    p.font.size = Pt(20)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(50, 50, 50)
    
    left = Inches (0.4)
    top = Inches(3.8)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    p = tf.add_paragraph()
    p.text = "d'images dans chaque classe."
    p.font.size = Pt(20)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(50, 50, 50)
    
    left = Inches (0.4)
    top = Inches(4.5)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    p = tf.add_paragraph()
    p.text = "- Qualité suffisante des images pour"
    p.font.size = Pt(20)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(50, 50, 50)
    
    left = Inches (0.4)
    top = Inches(4.8)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    p = tf.add_paragraph()
    p.text = "pour obtenir un process de qualité."
    p.font.size = Pt(20)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(50, 50, 50)
    
    
    left = Inches (5.1)
    top = Inches(1.8)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    p = tf.add_paragraph()
    p.text = "Faisabilité de votre use-case :"
    p.font.size = Pt(26)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(0,0,0)
    p.font.underline = MSO_UNDERLINE.SINGLE_LINE
    
    
    left = Inches (5.1)
    top = Inches(3.5)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    p = tf.add_paragraph()
    p.text = "- Bonnes performances de prédiction"
    p.font.size = Pt(20)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(50,50,50)
    
    left = Inches (5.1)
    top = Inches(3.8)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    p = tf.add_paragraph()
    p.text = "si l'on a un dataset labellisé."
    p.font.size = Pt(20)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(50,50,50)
    
    #slide 4 
    
    bullet_slide_layout = prs.slide_layouts[1]
    
    slide = prs.slides.add_slide(bullet_slide_layout)
    shapes = slide.shapes
    
    title_shape = shapes.title
    body_shape = shapes.placeholders[1]
    
    
    #partie pour mettre la photo dans le coin 
    img_path1 = 'picsellia.png'
    left = Inches(9.1)
    top = Inches(0.15)
    width = Inches (0.7)
    height = Inches (0.9)
    pic = slide. shapes. add_picture(img_path1, left, top, width, height)
    
    left = Inches (0.5)
    top = Inches(0.2)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    
    p = tf.add_paragraph()
    p.text = "Prérequis 1 : Proportion du datasheet"
    p.font.size = Pt(40)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(50, 171, 104)
    
    
    img_path2 = 'C:\codePyth\'',nom,'image_1.png'
    left = Inches(3)
    top = Inches(1.7)
    width = Inches (4)
    height = Inches (3)
    pic = slide. shapes. add_picture(img_path2, left, top, width, height)
    
    left = Inches (0.5)
    top = Inches(5)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    
    
    p = tf.add_paragraph()
    p.text = "TTTTTTTTTTTTT :"
    p.font.size = Pt(14)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(127, 127, 127)
    p.font.underline = MSO_UNDERLINE.SINGLE_LINE
    
    
    
    #slide5 
    bullet_slide_layout = prs.slide_layouts[1]
    
    slide = prs.slides.add_slide(bullet_slide_layout)
    shapes = slide.shapes
    
    title_shape = shapes.title
    body_shape = shapes.placeholders[1]
    
    
    #partie pour mettre la photo dans le coin 
    img_path1 = 'picsellia.png'
    left = Inches(9.1)
    top = Inches(0.15)
    width = Inches (0.7)
    height = Inches (0.9)
    pic = slide. shapes. add_picture(img_path1, left, top, width, height)
    
    left = Inches (0.5)
    top = Inches(0.2)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    
    p = tf.add_paragraph()
    p.text = "Prérequis 1 : Proportion du datasheet"
    p.font.size = Pt(40)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(50, 171, 104)
    
    
    img_path2 = 'C:\codePyth\'',nom,'image_2.png'
    left = Inches(3)
    top = Inches(1.7)
    width = Inches (4)
    height = Inches (3)
    pic = slide. shapes. add_picture(img_path2, left, top, width, height)
    
    left = Inches (0.5)
    top = Inches(5)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    
    
    p = tf.add_paragraph()
    p.text = "TTTTTTTTTTTTT :"
    p.font.size = Pt(14)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(127, 127, 127)
    p.font.underline = MSO_UNDERLINE.SINGLE_LINE
    
    #Slide 6 
    bullet_slide_layout = prs.slide_layouts[1]
    
    slide = prs.slides.add_slide(bullet_slide_layout)
    shapes = slide.shapes
    
    title_shape = shapes.title
    body_shape = shapes.placeholders[1]
    
    
    #partie pour mettre la photo dans le coin 
    img_path1 = 'picsellia.png'
    left = Inches(9.1)
    top = Inches(0.15)
    width = Inches (0.7)
    height = Inches (0.9)
    pic = slide. shapes. add_picture(img_path1, left, top, width, height)
    
    left = Inches (0.5)
    top = Inches(0.2)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    
    p = tf.add_paragraph()
    p.text = "Prérequis 1 : Proportion du datasheet"
    p.font.size = Pt(40)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(50, 171, 104)
    
    
    img_path2 = 'C:\codePyth\'',nom,'image_3.png'
    left = Inches(3)
    top = Inches(1.7)
    width = Inches (4)
    height = Inches (3)
    pic = slide. shapes. add_picture(img_path2, left, top, width, height)
    
    left = Inches (0.5)
    top = Inches(5)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    
    
    p = tf.add_paragraph()
    p.text = "TTTTTTTTTTTTT :"
    p.font.size = Pt(14)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(127, 127, 127)
    p.font.underline = MSO_UNDERLINE.SINGLE_LINE
    
    
    
    #Slide7
    
    
    bullet_slide_layout = prs.slide_layouts[1]
    
    slide = prs.slides.add_slide(bullet_slide_layout)
    shapes = slide.shapes
    
    title_shape = shapes.title
    body_shape = shapes.placeholders[1]
    
    
    #partie pour mettre la photo dans le coin 
    img_path1 = 'picsellia.png'
    left = Inches(9.1)
    top = Inches(0.15)
    width = Inches (0.7)
    height = Inches (0.9)
    pic = slide. shapes. add_picture(img_path1, left, top, width, height)
    
    left = Inches (0.5)
    top = Inches(0.2)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    
    p = tf.add_paragraph()
    p.text = "Prérequis 2 : Qualité des images"
    p.font.size = Pt(40)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(50, 171, 104)
    
    
    img_path2 ='C:\codePyth\'',nom,'image_4.png'
    left = Inches(2.2)
    top = Inches(1.8)
    width = Inches (2)
    height = Inches (2)
    pic = slide. shapes. add_picture(img_path2, left, top, width, height)
    
    img_path3 = 'C:\codePyth\'',nom,'image_5.png'
    left = Inches(6)
    top = Inches(1.8)
    width = Inches (2)
    height = Inches (2)
    pic = slide. shapes. add_picture(img_path3, left, top, width, height)
    
    
    left = Inches (0.5)
    top = Inches(5)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    
    p = tf.add_paragraph()
    p.text = "TTTTTTTTTTTTT :"
    p.font.size = Pt(14)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(127, 127, 127)
    p.font.underline = MSO_UNDERLINE.SINGLE_LINE
    p.level = 1
    
    p = tf.add_paragraph()
    p.text = "PPPPPPPPPPPPPPPP :"
    p.font.size = Pt(14)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(127, 127, 127)
    p.font.underline = MSO_UNDERLINE.SINGLE_LINE
    p.level = 1
    
    
    #Slide8
    
    
    bullet_slide_layout = prs.slide_layouts[1]
    
    slide = prs.slides.add_slide(bullet_slide_layout)
    shapes = slide.shapes
    
    title_shape = shapes.title
    body_shape = shapes.placeholders[1]
    
    
    #partie pour mettre la photo dans le coin 
    img_path1 = 'picsellia.png'
    left = Inches(9.1)
    top = Inches(0.15)
    width = Inches (0.7)
    height = Inches (0.9)
    pic = slide. shapes. add_picture(img_path1, left, top, width, height)
    
    left = Inches (0.5)
    top = Inches(0.2)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    
    p = tf.add_paragraph()
    p.text = "Prérequis 2 : Qualité des images"
    p.font.size = Pt(40)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(50, 171, 104)
    
    
    img_path2 = 'C:\codePyth\'',nom,'image_6.png'
    left = Inches(2.2)
    top = Inches(1.8)
    width = Inches (2)
    height = Inches (2)
    pic = slide. shapes. add_picture(img_path2, left, top, width, height)
    
    img_path3 = 'C:\codePyth\'',nom,'image_7.png'
    left = Inches(6)
    top = Inches(1.8)
    width = Inches (2)
    height = Inches (2)
    pic = slide. shapes. add_picture(img_path3, left, top, width, height)
    
    
    left = Inches (0.5)
    top = Inches(5)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    
    p = tf.add_paragraph()
    p.text = "TTTTTTTTTTTTT :"
    p.font.size = Pt(14)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(127, 127, 127)
    p.font.underline = MSO_UNDERLINE.SINGLE_LINE
    p.level = 1
    
    p = tf.add_paragraph()
    p.text = "PPPPPPPPPPPPPPPP :"
    p.font.size = Pt(14)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(127, 127, 127)
    p.font.underline = MSO_UNDERLINE.SINGLE_LINE
    p.level = 1
    
    
    #Slide9
    
    
    bullet_slide_layout = prs.slide_layouts[1]
    
    slide = prs.slides.add_slide(bullet_slide_layout)
    shapes = slide.shapes
    
    title_shape = shapes.title
    body_shape = shapes.placeholders[1]
    
    
    #partie pour mettre la photo dans le coin 
    img_path1 = 'picsellia.png'
    left = Inches(9.1)
    top = Inches(0.15)
    width = Inches (0.7)
    height = Inches (0.9)
    pic = slide. shapes. add_picture(img_path1, left, top, width, height)
    
    left = Inches (0.5)
    top = Inches(0.2)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    
    p = tf.add_paragraph()
    p.text = "Prérequis 2 : Qualité des images"
    p.font.size = Pt(40)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(50, 171, 104)
    
    
    img_path2 = 'C:\codePyth\'',nom,'image_8.png'
    left = Inches(2.2)
    top = Inches(1.8)
    width = Inches (2)
    height = Inches (2)
    pic = slide. shapes. add_picture(img_path2, left, top, width, height)
    
    img_path3 = 'C:\codePyth\'',nom,'image_9.png'
    left = Inches(6)
    top = Inches(1.8)
    width = Inches (2)
    height = Inches (2)
    pic = slide. shapes. add_picture(img_path3, left, top, width, height)
    
    
    left = Inches (0.5)
    top = Inches(5)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    
    p = tf.add_paragraph()
    p.text = "TTTTTTTTTTTTT :"
    p.font.size = Pt(14)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(127, 127, 127)
    p.font.underline = MSO_UNDERLINE.SINGLE_LINE
    p.level = 1
    
    p = tf.add_paragraph()
    p.text = "PPPPPPPPPPPPPPPP :"
    p.font.size = Pt(14)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(127, 127, 127)
    p.font.underline = MSO_UNDERLINE.SINGLE_LINE
    p.level = 1
    
    
    #Slide10
    
    
    bullet_slide_layout = prs.slide_layouts[1]
    
    slide = prs.slides.add_slide(bullet_slide_layout)
    shapes = slide.shapes
    
    title_shape = shapes.title
    body_shape = shapes.placeholders[1]
    
    
    #partie pour mettre la photo dans le coin 
    img_path1 = 'picsellia.png'
    left = Inches(9.1)
    top = Inches(0.15)
    width = Inches (0.7)
    height = Inches (0.9)
    pic = slide. shapes. add_picture(img_path1, left, top, width, height)
    
    left = Inches (0.5)
    top = Inches(0.2)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    p = tf.add_paragraph()
    p.text = "Prérequis 3 : Faisabilité"
    p.font.size = Pt(40)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(50, 171, 104)
    
    p = tf.add_paragraph()
    p.text = "TTTTTTTTTTTTTTTTTTT :"
    p.font.size = Pt(14)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(127, 127, 127)
    p.font.underline = MSO_UNDERLINE.SINGLE_LINE
    p.level = 1
    
    
    #La slide qui suit c'était un peu plus chiant puisque comme je créais les boites de textes
    #il fallait que je fasse comme du "collage" pour que les différentes couleurs de texte
    #se suivent bien (après c'est censé être une slide qui bouge pas donc ca pause plus trop de pb)
    
    #Slide11
    
    
    bullet_slide_layout = prs.slide_layouts[1]
    
    slide = prs.slides.add_slide(bullet_slide_layout)
    shapes = slide.shapes
    
    title_shape = shapes.title
    body_shape = shapes.placeholders[1]
    
    
    #partie pour mettre la photo dans le coin 
    img_path1 = 'picsellia.png'
    left = Inches(9.1)
    top = Inches(0.15)
    width = Inches (0.7)
    height = Inches (0.9)
    pic = slide. shapes. add_picture(img_path1, left, top, width, height)
    
    left = Inches (0.5)
    top = Inches(0.2)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    
    p = tf.add_paragraph()
    p.text = "Notre service"
    p.font.size = Pt(40)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(50, 171, 104)
    
    left = Inches (0.5)
    top = Inches(1.4)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    p = tf.add_paragraph()
    p.text = "Nous fournissons un service d'"
    p.font.size = Pt(14)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(50, 50, 50)
    
    left = Inches (3.12)
    top = Inches(1.4)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    p = tf.add_paragraph()
    p.text = "annotation d'image et de conseil en intelligence artificielle."
    p.font.size = Pt(14)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(50, 171, 104)
    
    left = Inches (0.5)
    top = Inches(1.9)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    p = tf.add_paragraph()
    p.text = "En couplant intelligemment l'"
    p.font.size = Pt(14)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(50, 50, 50)
    
    left = Inches (3)
    top = Inches(1.9)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    p = tf.add_paragraph()
    p.text = "action humaine de labellisation et nos algorithmes"
    p.font.size = Pt(14)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(50, 171, 104)
    
    left = Inches (7.33)
    top = Inches(1.9)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    p = tf.add_paragraph()
    p.text = ", nous optimisons"
    p.font.size = Pt(14)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(50, 50, 50)
    
    left = Inches (0.5)
    top = Inches(2.1)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    p = tf.add_paragraph()
    p.text = "la préparation de votre base de donnée et vous donnons une inside pertinente sur les algorithmes"
    p.font.size = Pt(14)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(50, 50, 50)
    
    left = Inches (0.5)
    top = Inches(2.3)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    p = tf.add_paragraph()
    p.text = "à utiliser pour votre use-case."
    p.font.size = Pt(14)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(50, 50, 50)
    
    left = Inches (0.5)
    top = Inches(2.8)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    p = tf.add_paragraph()
    p.text = "Pour vous donner un ordre d'idée nous, nous labellisons : "
    p.font.size = Pt(14)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(50, 50, 50)
    
    left = Inches (5.45)
    top = Inches(2.8)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    p = tf.add_paragraph()
    p.text = "1000 images en 25 minutes."
    p.font.size = Pt(14)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(50, 171, 104)
    
    left = Inches (0.5)
    top = Inches(3.2)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    p = tf.add_paragraph()
    p.text = "Ainsi pour créer une database susceptible d'obtenir des bonnes performances pour discriminer"
    p.font.size = Pt(14)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(50, 50, 50)
    
    left = Inches (0.5)
    top = Inches(3.4)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    p = tf.add_paragraph()
    p.text = "Bouteille/Barquette il vous faut un dataset d'"
    p.font.size = Pt(14)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(50, 50, 50)
    
    left = Inches (4.33)
    top = Inches(3.4)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    p = tf.add_paragraph()
    p.text = "images différentes"
    p.font.size = Pt(14)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(50, 171, 104)
    
    left = Inches (5.95)
    top = Inches(3.4)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    p = tf.add_paragraph()
    p.text = """(Sans "data augmentation" -> cf rotation """
    p.font.size = Pt(14)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(50, 50, 50)
    
    left = Inches (0.5)
    top = Inches(3.6)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    p = tf.add_paragraph()
    p.text = "de vos objets lors de la prise de photo) d'environ"
    p.font.size = Pt(14)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(50, 50, 50)
    
    left = Inches (4.75)
    top = Inches(3.6)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    p = tf.add_paragraph()
    p.text = "5000 images par classe. "
    p.font.size = Pt(14)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(50, 171, 104)
    
    left = Inches (6.8)
    top = Inches(3.6)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    p = tf.add_paragraph()
    p.text = "Notre service peut vous"
    p.font.size = Pt(14)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(50, 50, 50)
    
    left = Inches (0.5)
    top = Inches(3.8)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    p = tf.add_paragraph()
    p.text = "fournir une telle base en 7h de tavail comprenant :"
    p.font.size = Pt(14)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(50, 50, 50)
    
    left = Inches (0.5)
    top = Inches(4.3)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    p = tf.add_paragraph()
    p.text = "- 4 h de labellisation assisté par nos algorithmes"
    p.font.size = Pt(14)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(50, 50, 50)
    
    left = Inches (0.5)
    top = Inches(4.8)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    p = tf.add_paragraph()
    p.text = "- 1 h de process de data augmentation pour vous fournir une base prête à l'emploi"
    p.font.size = Pt(14)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(50, 50, 50)
    
    left = Inches (0.5)
    top = Inches(5.3)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    p = tf.add_paragraph()
    p.text = "- 2 h d'analyse et de rédaction de rapport sur vos données et conseils adaptés à vos compétences en interne"
    p.font.size = Pt(14)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(50, 50, 50)
    
    left = Inches (0.5)
    top = Inches(5.8)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    p = tf.add_paragraph()
    p.text = "Nous vous permettrons donc d'"
    p.font.size = Pt(14)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(50, 50, 50)
    
    left = Inches (3.22)
    top = Inches(5.8)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    p = tf.add_paragraph()
    p.text = "accélérer la phase de recherche et développement de vos projets"
    p.font.size = Pt(14)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(50, 171, 104)
    
    left = Inches (0.5)
    top = Inches(6)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    p = tf.add_paragraph()
    p.text = "d'intelligence artificielle"
    p.font.size = Pt(14)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(50, 171, 104)
    
    left = Inches (2.58)
    top = Inches(6)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    p = tf.add_paragraph()
    p.text = "en vous donnat toutes les clefs pour la"
    p.font.size = Pt(14)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(50, 50, 50)
    
    left = Inches (5.94)
    top = Inches(6)
    width = height = Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    p = tf.add_paragraph()
    p.text = "réussite de votre projet."
    p.font.size = Pt(14)
    p.font.name = 'Lato'
    p.font.color.rgb = RGBColor(50, 171, 104)
    
    
    
    prs.save('test4.pptx')
Beispiel #16
0
slide_page_2.shapes.title.text = '本次執行摘要'  #大標題
#在標題下面的文字框新增文字,其實就是一串字串結合起來。
slide_page_2.placeholders[1].text_frame.text =\
'關鍵字: '+ptt_crawler_index.keyword+'\n'+\
'執行時間:'+datetime.datetime.now().strftime('%Y-%m-%d %H:%M')+'\n'+\
'爬取共 ' + str(ptt_crawler_index.page_n) +' 頁,共有 '+str(len(total_result))+' 篇文章,\n'+\
'詞彙字典:共有 '+str(len(pos_word)) +' 個正向詞彙, '+str(len(neg_word))+' 個負向詞彙'

#第三頁:SHOW 前四筆文章資料,提供使用者對於抓下來的文本有初步概念
slide_page_3 = prs.slides.add_slide(prs.slide_layouts[1])
slide_page_3.shapes.title.text = '最新' + str(
    ptt_crawler_index.page3_article_show_n) + '筆文章'
table = slide_page_3.shapes.add_table(
    rows=ptt_crawler_index.page3_article_show_n + 1,
    cols=4,
    left=Inches(0.1),
    top=Inches(1.5),
    width=Inches(5),
    height=Inches(1.2)).table  #在此修改表格的欄位數,寬度等等
# 設定單元格寬度
table.columns[0].width = Inches(2)
table.columns[1].width = Inches(2)
table.columns[2].width = Inches(3.5)
table.columns[3].width = Inches(2)

# 設定標題行
table.cell(0, 0).text = '文章標題'
table.cell(0, 1).text = '發佈時間'
table.cell(0, 2).text = '文章內容'
table.cell(0, 3).text = '連結'
Beispiel #17
0
import os
from pptx import Presentation
from pptx.util import Inches

IM_DIR = os.path.join("hconcat")

if __name__ == '__main__':
    images = os.listdir(IM_DIR)
    prs = Presentation()

    for file in images:
        slide = prs.slides.add_slide(prs.slide_layouts[5])
        title = slide.shapes.title
        title.text = file
        pic = slide.shapes.add_picture(os.path.join(IM_DIR, file),
                                       top=Inches(2.47),
                                       left=Inches(0.5),
                                       height=Inches(2.56))
    prs.save('test.pptx')
def make_rssi():
    #
    datenow = str(date.today())[2:4] + str(date.today())[5:7] + str(
        date.today())[8:10]
    name = 'tester'
    filename = 'createCSV/' + datenow + 'test.csv'
    excelname = 'Excel/' + datenow + 'test' + name + '.xlsx'
    picturename = 'chartPicture/avgSnrChart_'
    pptname = 'ppt/' + datenow + 'test' + name + '.pptx'
    titletext = 'title'

    f = open(filename, 'r')

    station_key = dict()

    station_col = 2  # 초기 기지국 별 셀 위치
    xbar_row = 2  # 초기 x축 셀 위치
    cnt_col = 2  # 초기 개수 셀 위치
    cnt_row = 2  # 초기 개수 셀 위치

    count = []  # 개수를 받는 빈 리스트 선언
    #

    # load pptx
    prs = Presentation(pptname)

    title_slide_layout = prs.slide_layouts[0]
    slide = prs.slides.add_slide(title_slide_layout)
    title = slide.shapes.title
    subtitle = slide.placeholders[1]

    title.text = "title"
    subtitle.text = titletext

    slide_layout = prs.slide_layouts[1]
    slide = prs.slides.add_slide(slide_layout)
    slide_title_shape = slide.shapes.title
    slide_title_shape.text = "STATION LIST(" + titletext + ")"
    slide_body_shape = slide.placeholders[1]  # text box 객체
    slide_body_tf = slide_body_shape.text_frame

    # load excel
    write_wb = openpyxl.load_workbook(excelname)
    write_ws = write_wb.create_sheet('second')

    for line in f:
        rawdata = json.loads(line.replace("'", "\""))
        if rawdata['payload']['station'] in station_key:
            if rawdata['payload']['rssi'] != 'null':
                station_key[rawdata['payload']['station']].append(
                    float(rawdata['payload']['rssi']))
        else:
            if rawdata['payload']['rssi'] != 'null':
                station_key[rawdata['payload']['station']] = [
                    float(rawdata['payload']['rssi'])
                ]

    write_ws.cell(row=1, column=1, value='x축범위')

    for items in station_key.items():
        avg = round(sum(items[1]) / len(items[1]), 2)

        ys, xs, patches = plt.hist(items[1],
                                   range=(-160, 0),
                                   color='r',
                                   edgecolor='black',
                                   linewidth=1.2,
                                   rwidth=0.8,
                                   bins=160,
                                   alpha=0.4)

        count.append(ys)
        write_ws.cell(row=1,
                      column=station_col,
                      value='rssi(station : ' + items[0] + ')')
        station_col = station_col + 1

        plt.xlabel('rssi')
        plt.ylabel('개수')
        plt.title('rssi 차트\n(station : ' + items[0] + ') 평균 : ' + str(avg))

        plt.grid()
        plt.axvline(avg, linestyle='--')

        plt.minorticks_on()

        check_picture = os.path.exists(picturename + items[0] + '.png')
        if check_picture == True:
            # delete picture
            os.unlink(picturename + items[0] + '.png')
            # save picture
            plt.savefig(picturename + items[0] + '.png', dpi=500)
        else:
            # save picture
            plt.savefig(picturename + items[0] + '.png', dpi=500)

        # show chart
        # plt.show()

        plt.clf()  # initialize

        # save pptx
        slide_p = slide_body_tf.add_paragraph()
        slide_p.text = items[0]
        slide_p.font.size = Pt(17)
        slide_layout = prs.slide_layouts[6]
        slide = prs.slides.add_slide(slide_layout)
        slide.shapes.add_picture(picturename + items[0] + '.png',
                                 Inches(0.5),
                                 Inches(0.5),
                                 width=Inches(9),
                                 height=Inches(6))

    prs.save(pptname)

    # insert excel
    for i in range(0, len(xs) - 1):
        write_ws.cell(row=xbar_row, column=1, value=xs[i])
        xbar_row = xbar_row + 1

    for i in range(len(count)):
        for j in range(len(count[i])):
            write_ws.cell(row=cnt_row, column=cnt_col, value=int(count[i][j]))
            cnt_row = cnt_row + 1
        if cnt_row == 162:
            cnt_row = 2
            cnt_col = cnt_col + 1
    # save excel
    write_wb.save(excelname)
Beispiel #19
0
def start3():
    slide = prs.slides.add_slide(blank_slide_layout)
    #设置背景图片和主标题
    img_path = 'backgrounds/3_1.jpg'
    left, top, width, height = Inches(0), Inches(0), Inches(13.5), Inches(7.5)
    pic = slide.shapes.add_picture(img_path, left, top, width, height)
    #主标题
    left, top, width, height = Inches(5), Inches(2.5), Inches(5), Inches(2)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    p = tf.add_paragraph()
    p.font.name = '黑体'
    p.font.bold = True
    p.text = "工作总结"
    p.font.color.rgb = RGBColor(255, 255, 0)
    p.font.size = Pt(80)
    #副标题1
    left = Inches(7)
    top = Inches(5)
    width = Inches(3)
    height = Inches(0.8)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    p = tf.add_paragraph()
    p.font.name = '黑体'
    p.font.color.rgb = RGBColor(255, 255, 0)
    p.text = "汇报人:XXXXX\n 日期:XXXXX"
    p.font.size = Pt(25)
    prs.save('test.pptx')
from pptx.enum.shapes import MSO_SHAPE
from pptx.dml.color import RGBColor
from pptx.util import Inches, Pt
from pptx.enum.dml import MSO_THEME_COLOR

title = 'Automated Presentation Creating Process\n\
How to Create PowerPoint Presentations with Python '

pylogo = 'pylogo.png'
pptlogo = 'pptlogo.png'
prs = Presentation()

# front page
#-----------------------------------------------------------------------------------------------------------------------
slide = prs.slides.add_slide(prs.slide_layouts[6])
prs.slide_width = Inches(16)
prs.slide_height = Inches(9)

shape = slide.shapes.add_shape(MSO_SHAPE.RECTANGLE, 0, Inches(9 / 1.5),
                               Inches(16), Inches(9 / 8.5))
shape.shadow.inherit = False
fill = shape.fill
fill.solid()
fill.fore_color.rgb = RGBColor(255, 0, 0)
shape.text = title
line = shape.line
line.color.rgb = RGBColor(255, 0, 0)
logo1 = slide.shapes.add_picture(pylogo,
                                 Inches(13.8),
                                 Inches(6.0),
                                 height=Inches(1.0),
Beispiel #21
0
def twelfth_page():
    slide = prs.slides.add_slide(blank_slide_layout)
    #背景图片
    img_path = 'backgrounds/1.jpg'
    SetPictureAndTitle(slide, img_path)
    #图片1位置
    img_path = 'images/12_1.jpg'
    left, top, width, height = Inches(0.2), Inches(3.5), Inches(3), Inches(2)
    pic = slide.shapes.add_picture(img_path, left, top, width, height)

    left, top, width, height = Inches(1), Inches(2), Inches(2), Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    p = txBox.text_frame.add_paragraph()
    p.font.name = '黑体'
    p.text = "第一个标题"

    #图片2位置
    img_path = 'images/12_2.jpg'
    left, top, width, height = Inches(3.4), Inches(3.5), Inches(3), Inches(2)
    pic = slide.shapes.add_picture(img_path, left, top, width, height)

    left, top, width, height = Inches(4.2), Inches(2), Inches(2), Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    p = txBox.text_frame.add_paragraph()
    p.font.name = '黑体'
    p.text = "第二个标题"

    #图片3位置
    img_path = 'images/12_3.jpg'
    left, top, width, height = Inches(6.6), Inches(3.5), Inches(3), Inches(2)
    pic = slide.shapes.add_picture(img_path, left, top, width, height)

    left, top, width, height = Inches(7.4), Inches(2), Inches(2), Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    p = txBox.text_frame.add_paragraph()
    p.font.name = '黑体'
    p.text = "第三个标题"

    #图片4位置
    img_path = 'images/12_4.jpg'
    left, top, width, height = Inches(9.8), Inches(3.5), Inches(3), Inches(2)
    pic = slide.shapes.add_picture(img_path, left, top, width, height)

    left, top, width, height = Inches(10.6), Inches(2), Inches(2), Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    p = txBox.text_frame.add_paragraph()
    p.font.name = '黑体'
    p.text = "第二个标题"
    prs.save('test.pptx')
Beispiel #22
0
#!/usr/bin/env python3

from pptx import Presentation
from pptx.util import Inches

prs = Presentation()
title_only_slide_layout = prs.slide_layouts[5]
slide = prs.slides.add_slide(title_only_slide_layout)
shapes = slide.shapes

shapes.title.text = 'Adding a Table'

rows = cols = 2
left = top = Inches(2.0)
width = Inches(6.0)
height = Inches(0.8)

table = shapes.add_table(rows, cols, left, top, width, height).table

# set column widths
table.columns[0].width = Inches(2.0)
table.columns[1].width = Inches(4.0)

# write column headings
table.cell(0, 0).text = 'Foo'
table.cell(0, 1).text = 'Bar'

# write body cells
table.cell(1, 0).text = 'Baz'
table.cell(1, 1).text = 'Qux'
Beispiel #23
0
def nineteenth_page():
    slide = prs.slides.add_slide(blank_slide_layout)
    #背景图片
    img_path = 'backgrounds/1.jpg'
    SetPictureAndTitle(slide, img_path)
    #图片位置
    img_path = 'images/19.jpg'
    left, top, width, height = Inches(9), Inches(1.5), Inches(2), Inches(2)
    pic = slide.shapes.add_picture(img_path, left, top, width, height)
    #图标1+文字位置
    icon_path = 'icons/1.jpg'
    left, top, width, height = Inches(2), Inches(3.5), Inches(0.7), Inches(0.7)
    pic = slide.shapes.add_picture(icon_path, left, top, width, height)

    left, top, width, height = Inches(2.8), Inches(3.5), Inches(2), Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    p = txBox.text_frame.add_paragraph()
    p.font.name = '黑体'
    p.text = "第一个标题"
    #图标2+文字位置
    icon_path = 'icons/2.jpg'
    left, top, width, height = Inches(2), Inches(5.3), Inches(0.7), Inches(0.7)
    pic = slide.shapes.add_picture(icon_path, left, top, width, height)

    left, top, width, height = Inches(2.8), Inches(5.3), Inches(2), Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    p = txBox.text_frame.add_paragraph()
    p.font.name = '黑体'
    p.text = "第二个标题"
    #图标3+文字位置
    icon_path = 'icons/3.jpg'
    left, top, width, height = Inches(6.5), Inches(3.5), Inches(0.7), Inches(
        0.7)
    pic = slide.shapes.add_picture(icon_path, left, top, width, height)

    left, top, width, height = Inches(7.3), Inches(3.5), Inches(2), Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    p = txBox.text_frame.add_paragraph()
    p.font.name = '黑体'
    p.text = "第三个标题"
    #图标4+文字位置
    icon_path = 'icons/4.jpg'
    left, top, width, height = Inches(6.5), Inches(5.3), Inches(0.7), Inches(
        0.7)
    pic = slide.shapes.add_picture(icon_path, left, top, width, height)

    left, top, width, height = Inches(7.3), Inches(5.3), Inches(2), Inches(1)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    p = txBox.text_frame.add_paragraph()
    p.font.name = '黑体'
    p.text = "第四个标题"
    prs.save('test.pptx')
    def write_summary_pptx(self, presentation_name):
        """
        Creates a pptx including time series plots, metadata and descriptions of all columns in TSC dataframe.
        The user is recommended to apply format changes after exporting to pptx-format
        """
        prs = pptx.Presentation()

        # Presentation settings
        title_page_slide_layout = prs.slide_layouts[0]
        title_slide_layout = prs.slide_layouts[5]

        # Add title page
        slide = prs.slides.add_slide(title_page_slide_layout)
        title = slide.shapes.title
        title.text = "TSConstrictor Summary"
        subtitle = slide.placeholders[1]
        subtitle.text = "Autogenerated " + str(datetime.date.today())

        # Add analysis for each column in TSConstrictor dataframe
        for column in self.dataframe.columns:
            if self.dataframe[column].dtype != np.dtype('O'):
                # Create plot
                self.plot_static(y_column=column, save_name='timeseries.png')
                if not os.path.isfile('timeseries.png'):
                    continue

                # Time series slide
                slide = prs.slides.add_slide(title_slide_layout)
                title = slide.shapes.title
                title.text = column + ' - time series'

                # Add plot to slide
                left = Inches(0.5)
                top = Inches(2)
                width = Inches(8)
                pic = slide.shapes.add_picture("timeseries.png",
                                               left,
                                               top,
                                               width=width)
                os.remove('timeseries.png')

                # Statistics and metadata slide
                slide = prs.slides.add_slide(title_slide_layout)
                title = slide.shapes.title
                title.text = column + ' \n Statistics and description'
                shapes = slide.shapes

                # Find number of rows of metadata and description
                try:
                    desc_rows = len(self.description[column])
                except KeyError:
                    desc_rows = 0
                    print('No description found for ' + column)
                try:
                    meta_rows = len(self.metadata[column])
                except KeyError:
                    meta_rows = 0
                    print('No metadata found for ' + column)

                # Set number of rows to the max of metadata and description
                rows = max(meta_rows, desc_rows) + 1

                # Set column indices for metadata and description
                if desc_rows > 0 and meta_rows > 0:
                    cols = 5
                    desc_col = 0
                    meta_col = 3
                elif desc_rows + meta_rows == 0:
                    continue
                else:
                    cols = 2
                    desc_col = 0
                    meta_col = 0

                # Set table properties
                left = top = Inches(1.5)
                width = Inches(8)
                height = Inches(0.6)

                table = shapes.add_table(rows, cols, left, top, width,
                                         height).table

                # Fill table with descirption and metadata
                if desc_rows > 0:
                    # write column headings
                    table.cell(0, desc_col).text = 'Description'
                    table.cell(0, desc_col + 1).text = 'Value'

                    # write body cells
                    count = 1
                    for key in self.description[column].keys():
                        table.cell(count, desc_col).text = key
                        table.cell(count, desc_col + 1).text = str(
                            self.description[column][key])
                        count += 1

                if meta_rows > 0:
                    # write column headings
                    table.cell(0, meta_col).text = 'Description'
                    table.cell(0, meta_col + 1).text = 'Value'

                    # write body cells
                    count = 1
                    for key in self.metadata[column].keys():
                        table.cell(count, meta_col).text = key
                        table.cell(count, meta_col + 1).text = str(
                            self.metadata[column][key])
                        count += 1

        prs.save(presentation_name)
Beispiel #25
0
def twenty_second_page():
    slide = prs.slides.add_slide(blank_slide_layout)
    #背景图片
    img_path = 'backgrounds/1.jpg'
    SetPictureAndTitle(slide, img_path)
    #图片1位置
    img_path = 'images/22.jpg'
    left, top, width, height = Inches(2), Inches(2), Inches(4), Inches(3)
    pic = slide.shapes.add_picture(img_path, left, top, width, height)
    #段落1设置-读入数据
    txt_path = 'texts/22_1.txt'
    text = open(txt_path, encoding='utf-8')
    lines = text.readlines()
    #段落1设置-位置
    left, top, width, height = Inches(6.2), Inches(2), Inches(6), Inches(5)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame
    tf.word_wrap = True
    p = tf.add_paragraph()
    p.text = "这里控制 22_1和22_2f.txt"
    for line in lines:
        p = tf.add_paragraph()
        p.text = line
        p.font.size = Pt(15)
    #段落2设置-读入数据
    txt_path = 'texts/22_2.txt'
    text = open(txt_path, encoding='utf-8')
    lines = text.readlines()
    #段落2设置-位置
    left, top, width, height = Inches(2), Inches(5), Inches(4), Inches(2)
    txBox = slide.shapes.add_textbox(left, top, width, height)
    tf = txBox.text_frame

    for line in lines:
        p = tf.add_paragraph()
        p.font.name = '黑体'
        p.text = line
        p.font.size = Pt(25)
    prs.save('test.pptx')
Beispiel #26
0
    Create new text box.
    [Text-related objects — python-pptx 0.6.21 documentation](https://python-pptx.readthedocs.io/en/latest/api/text.html#textframe-objects)
    '''
    pos        = Position()
    shapes     = slide.shapes
    txtbx      = shapes.add_textbox(pos.left, pos.top, pos.width, pos.height)
    txtbx.text = text


SLD_LAYOUT_TITLE_AND_CONTENT = 0

filename = 'test.pptx'
prs, file_exist = pptxBasics.open_pptx(filename)

# Set slide size
prs.slide_height=Inches(9)
prs.slide_width=Inches(16)

slide_layout = prs.slide_layouts[SLD_LAYOUT_TITLE_AND_CONTENT]
slide = prs.slides.add_slide(slide_layout)

# slide = prs.slides[0]



# title = slide.shapes.title
subtitle = slide.placeholders[1]    
# title.text = "Hello, World2!"
subtitle.text = "python-pptx was here!"

position = [Cm(5.0), Cm(5.0), Cm(5.0), Cm(5.0)]
#! /usr/bin/env python
import csv, sys, numpy, math, pandas, os
from pptx import Presentation
from pptx.util import Inches, Pt
from pptx.enum.text import PP_ALIGN
from pptx.dml.color import RGBColor
from pptx.enum.dml import MSO_THEME_COLOR
from pathlib import Path

prs = Presentation()
prs.slide_height = Inches(5.63)
prs.slide_width = Inches(10)
blank_slide_layout = prs.slide_layouts[6]

width = Inches(7.28)
height = Inches(0.52)

textfile1 = open(sys.argv[1]).read().splitlines()
textfile2 = open(sys.argv[2]).read().splitlines()
textfile3 = open(sys.argv[3]).read().splitlines()

count = 0
count1 = 0

for line in textfile1:
    slide = prs.slides.add_slide(blank_slide_layout)
    #(left, top, width, height)
    txBox = slide.shapes.add_textbox(Inches(2.63), Inches(0.89), width, height)
    tf = txBox.text_frame
    p = tf.paragraphs[0]
    p.alignment = PP_ALIGN.CENTER
Beispiel #28
0
 def __init__(self):
     self.left   = Inches(1)
     self.top    = Inches(1)
     self.width  = Inches(6)
     self.height = Inches(3)
Beispiel #29
0
def create_metric_slide(prs,metric):
    #metric info
    metric_name = metric['timeSeries'][0]['metadata']['metricName']
    category =  metric['timeSeries'][0]['metadata']['attributes']['category']
    print metric_name
    #determine if service, and send to IMPALA_QUERY function if an IMPALA_QUERY slide
    if category == 'SERVICE':
        service_name = metric['timeSeries'][0]['metadata']['attributes']['serviceDisplayName']
    elif category == 'IMPALA_QUERY' and metric_name == 'query_duration':
        create_impala_query_slides(prs,metric)
        return
    elif category == 'IMPALA_QUERY' and metric_name == 'hdfs_average_scan_range':
        return
    else:
        service_name = 'Cluster'

    #metric_name = metric['timeSeries'][0]['metadata']['metricName']
    
    formatted_metric_name = ''
    #format the metric name and capitalize first letters
    metric_name_arr = metric_name.split("_")
    for word in metric_name_arr:
        formatted_metric_name += word.title() + " "
    
    metric_name = formatted_metric_name

    value_access_name = 'max'
    
         
    unit_type = metric['timeSeries'][0]['metadata']['unitNumerators'][0]
    numerator = metric['timeSeries'][0]['metadata']['unitNumerators'][0]
    denominators = metric['timeSeries'][0]['metadata']['unitDenominators']
    timestamps = deque()
    values = deque()
    points = ''
    if not metric['timeSeries'][0]['data']:
        points = metric['timeSeries'][1]['data']
    else:
        points = metric['timeSeries'][0]['data']
    slide = prs.slides.add_slide(prs.slide_layouts[12])
    for point in points:
        formatted_timestamp = point['timestamp'].split("T")
        timestamps.append(formatted_timestamp[0])
        #max value doesn't exist for data points in SUM or INTEGRAL statistics, need to use value key
        if point['type'] == 'CALCULATED':
            values.append(point['value'])
        elif unit_type == 'bytes':
            #Read and write metrics in MB, otherwise in gigabytes
            if 'read' in metric_name.lower() or 'writ' in metric_name.lower():
                value_in_mb = float(point['aggregateStatistics'][value_access_name])/(1024*1024)
                values.append(value_in_mb)
                numerator = 'megabytes'
            else:
                value_in_gb = float(point['aggregateStatistics'][value_access_name])/(1024*1024*1024) 
                values.append(value_in_gb)
                numerator = 'gigabytes'
        else:
            values.append(point['aggregateStatistics'][value_access_name])
    
    #determine what our measurement (IE bytes/sec or just queries)
    if len(denominators) > 0:
        denominator = metric['timeSeries'][0]['metadata']['unitDenominators'][0]
        measurement = numerator + '/' + denominator
    else:
        denominator = 'None'
        measurement = numerator

    # change title and properties
    title = slide.shapes.title
    title.text = service_name + " " + metric_name
    title.text_frame.paragraphs[0].font.name = "calibri"
    title.text_frame.paragraphs[0].font.size = Pt(28)

    # define chart data ---------------------
    chart_data = ChartData()
    chart_data.categories = timestamps
    chart_series_title = measurement
    chart_data.add_series(chart_series_title, values)
    

    # add chart to slide --------------------
    x, y, cx, cy = Inches(2.25), Inches(1.4), Inches(9), Inches(6.0)
    chart =  slide.shapes.add_chart(XL_CHART_TYPE.LINE, x, y, cx, cy, chart_data)
    
    # sets chart plot to all be the same color (default in PPT is all different colors by category)
    plot = chart.chart.plots[0]
    plot.vary_by_categories = False

    # change axis properties
    category_axis = chart.chart.category_axis
    value_axis = chart.chart.value_axis

    # change axis font properties
    category_axis.tick_labels.font.name = "calibri"
    category_axis.tick_labels.font.size = Pt(11)
    value_axis.tick_labels.font.name = "calibri"
    value_axis.tick_labels.font.size = Pt(11)
   
    # change legend properties
    chart.chart.has_legend = True
    chart.chart.legend.include_in_layout = False
    chart.chart.legend.font.name = "calibri"
    chart.chart.legend.font.size = Pt(11)
    return
Beispiel #30
0
# Initialization
individual = get_individual('[I0001]')
max = 6

# Create the blank ppt
prs = Presentation()
title_slide_layout = prs.slide_layouts[6]
slide = prs.slides.add_slide(title_slide_layout)

# Get the blank ppt dimensions
s_height = prs.slide_height
s_width = prs.slide_width

# Create the initial child shape
shapes = slide.shapes
width_s = Inches(1.0)
height_s = Inches(0.5)
left_s = s_width / 2 - width_s / 2
top_s = s_height - height_s

shape_s = shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE, left_s, top_s, width_s,
                           height_s)
# Populate name and dates
p = shape_s.text_frame.paragraphs[0]
run = p.add_run()
run.text = individual.Surname.str.cat() + ', ' + individual.Given.str.cat(
) + '\n' + get_date(individual['Birth date'].str.cat()) + ' ~ ' + get_date(
    individual['Death date'].str.cat()) + '\n de ' + get_birth_place(
        individual['Birth place'].str.cat())

font = run.font