@@ -11,29 +11,71 @@ pip install tppt
1111## 使用例
1212
1313``` python
14- from tppt import Presentation, SlideTemplate, SlideMaster, SlideBuilder
15-
16-
17- class MySlideTemplate (SlideTemplate ):
18- """ Custom slide template."""
19- pass
20-
21-
22- class MyTitleSlide (MySlideTemplate ):
23- """ Custom title slide."""
24- pass
25-
26-
27- # スライドマスターを作成
28- sm = SlideMaster(template_class = MySlideTemplate)
14+ from pathlib import Path
15+ import tppt
16+ from tppt.types import Color
2917
3018# ビルダーパターンを使用してプレゼンテーションを作成
3119presentation = (
32- Presentation.builder(sm)
20+ tppt.Presentation.builder()
21+ .slide(
22+ tppt.SlideBuilder()
23+ .text(
24+ " Amazing Presentation" ,
25+ left = (50 , " pt" ),
26+ top = (50 , " pt" ),
27+ width = (400 , " pt" ),
28+ height = (50 , " pt" ),
29+ size = (60 , " pt" ),
30+ bold = True ,
31+ italic = True ,
32+ color = Color(" #0000FF" ),
33+ )
34+ .text(
35+ " Example of using tppt library" ,
36+ left = (50 , " pt" ),
37+ top = (120 , " pt" ),
38+ width = (400 , " pt" ),
39+ height = (30 , " pt" ),
40+ )
41+ )
42+ .slide(
43+ tppt.SlideBuilder()
44+ .text(
45+ " 画像の例" ,
46+ left = (50 , " pt" ),
47+ top = (50 , " pt" ),
48+ width = (300 , " pt" ),
49+ height = (40 , " pt" ),
50+ )
51+ .picture(
52+ " image.png" ,
53+ left = (50 , " pt" ),
54+ top = (100 , " pt" ),
55+ width = (300 , " pt" ),
56+ height = (80 , " pt" ),
57+ )
58+ )
3359 .slide(
34- SlideBuilder()
35- .text(" Hello, world!" , x = (100 , " pt" ), y = (100 , " pt" ))
36- .image(path = " image.png" , width = (100 , " pt" ), height = (100 , " pt" ))
60+ tppt.SlideBuilder()
61+ .text(
62+ " 表の例" ,
63+ left = (50 , " pt" ),
64+ top = (50 , " pt" ),
65+ width = (300 , " pt" ),
66+ height = (40 , " pt" ),
67+ )
68+ .table(
69+ [
70+ [" 製品" , " 価格" , " 在庫" ],
71+ [" 製品A" , " ¥1,000" , " 10個" ],
72+ [" 製品B" , " ¥2,500" , " 5個" ],
73+ ],
74+ left = (50 , " pt" ),
75+ top = (100 , " pt" ),
76+ width = (400 , " pt" ),
77+ height = (200 , " pt" ),
78+ )
3779 )
3880 .build()
3981)
@@ -46,7 +88,9 @@ presentation.save("output.pptx")
4688
4789- 型安全なインターフェース
4890- ビルダーパターンによる直感的なAPI
49- - カスタムスライドテンプレートのサポート
91+ - テキスト、画像、表などの要素を簡単に配置
92+ - 位置やサイズの細かな調整が可能
93+ - テキストのスタイル(サイズ、太字、斜体、色)のカスタマイズ
5094
5195## アーキテクチャ
5296
0 commit comments