generate pptx files from gsf files
This commit is contained in:
parent
985c1446e6
commit
af7e973cc0
30
test/test.py
30
test/test.py
|
@ -1,3 +1,8 @@
|
|||
import sys
|
||||
import io
|
||||
import pptx
|
||||
from pptx.util import Inches, Pt
|
||||
sys.path.append("..")
|
||||
from gwygsf import GSF
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
|
@ -16,6 +21,27 @@ def makeplot(name):
|
|||
ax.set_xlabel("um")
|
||||
ax.set_ylabel("um")
|
||||
fig.colorbar(gr)
|
||||
fig.savefig(f'{name}.png')
|
||||
|
||||
makeplot('test.gsf')
|
||||
img = io.BytesIO()
|
||||
fig.savefig(img)
|
||||
return img
|
||||
|
||||
def build_pptx(l, out):
|
||||
prs = pptx.Presentation()
|
||||
imgoff_x = Inches(2)
|
||||
imgoff_y = Inches(2)
|
||||
textoff = Inches(0.5)
|
||||
textoff_x = Inches(4.6)
|
||||
def addslide():
|
||||
return prs.slides.add_slide(prs.slide_layouts[6])
|
||||
|
||||
for (n,im) in l:
|
||||
s = addslide()
|
||||
s.shapes.add_picture(im, imgoff_x, imgoff_y)
|
||||
txt = s.shapes.add_textbox(textoff_x,textoff,textoff,textoff).text_frame.add_paragraph()
|
||||
txt.text = n
|
||||
txt.font.size = Pt(15)
|
||||
|
||||
prs.save(f"{out}.pptx")
|
||||
|
||||
build_pptx([(x,makeplot(x)) for x in sys.argv[2:len(sys.argv)-1]], sys.argv[len(sys.argv)-1])
|
||||
|
|
Loading…
Reference in New Issue