Skip to content

Commit 5b4b68e

Browse files
committed
feat: add example codes for picture, table, and text usage; update documentation structure
1 parent 323d7c8 commit 5b4b68e

File tree

12 files changed

+150
-98
lines changed

12 files changed

+150
-98
lines changed

docs/docs/codes/picture.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import tppt
2+
3+
(
4+
tppt.Presentation.builder()
5+
.slide(
6+
lambda slide: slide.BlankLayout()
7+
.builder()
8+
.picture(
9+
"your_image.png",
10+
left=(1, "in"),
11+
top=(1, "in"),
12+
width=(5, "in"),
13+
height=(2, "in"),
14+
)
15+
)
16+
.build()
17+
.save("simple.pptx")
18+
)

docs/docs/codes/polars.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import tppt
2+
from tppt._features import USE_POLARS, PandasDataFrame
3+
4+
if USE_POLARS:
5+
df = PandasDataFrame(
6+
[
7+
{"Price": 100, "Name": "Apple", "Quantity": 10},
8+
{"Price": 200, "Name": "Banana", "Quantity": 20},
9+
]
10+
)
11+
12+
(
13+
tppt.Presentation.builder()
14+
.slide(
15+
lambda slide: slide.BlankLayout()
16+
.builder()
17+
.table(
18+
df,
19+
left=(1, "in"),
20+
top=(1, "in"),
21+
width=(5, "in"),
22+
height=(2, "in"),
23+
)
24+
)
25+
.build()
26+
.save("simple.pptx")
27+
)

docs/docs/codes/table.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import tppt
2+
3+
(
4+
tppt.Presentation.builder()
5+
.slide(
6+
lambda slide: slide.BlankLayout()
7+
.builder()
8+
.table(
9+
[
10+
["Price", "Name", "Quantity"],
11+
["100", "Apple", "10"],
12+
["200", "Banana", "20"],
13+
],
14+
left=(1, "in"),
15+
top=(1, "in"),
16+
width=(5, "in"),
17+
height=(2, "in"),
18+
)
19+
)
20+
.build()
21+
.save("simple.pptx")
22+
)

docs/docs/codes/text.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import tppt
2+
3+
(
4+
tppt.Presentation.builder()
5+
.slide(
6+
lambda slide: slide.BlankLayout()
7+
.builder()
8+
.text(
9+
"Hello, World!",
10+
left=(1, "in"),
11+
top=(1, "in"),
12+
width=(5, "in"),
13+
height=(2, "in"),
14+
color="#0000FF",
15+
bold=True,
16+
italic=True,
17+
)
18+
)
19+
.build()
20+
.save("simple.pptx")
21+
)

docs/docs/usage/index.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
The `tppt.Presentation` class is a wrapper for the `pttx.Presentation` class and can be easily wrapped.
2+
3+
```python
4+
--8<-- "codes/wrap_presentation.py"
5+
```
6+
7+
However, the primary way to use tppt is through the builder.
8+
By using the builder, you can create slides while utilizing slide masters and slide layouts in a type-safe manner.
9+
10+
```python
11+
--8<-- "codes/quick_start.py"
12+
```

docs/docs/usage/picture.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
We support adding images, but there are no notable features.
2+
3+
```python
4+
--8<-- "codes/picture.py"
5+
```

docs/docs/usage/presentation.md

Lines changed: 0 additions & 12 deletions
This file was deleted.

docs/docs/usage/slide-layout.md

Lines changed: 5 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,9 @@
1-
# スライドレイアウト
1+
# Slide Layout
22

3-
TPPTでは、スライドのレイアウトを柔軟にカスタマイズすることができます。ここでは、基本的なレイアウトの設定方法と、よく使用されるパターンについて説明します。
3+
In TPPT, you can declaratively define slide layouts using type definitions.
44

5-
## 基本的なレイアウト設定
5+
## Defining Slide Layouts
66

7-
### 1. スライドサイズの設定
8-
```python
9-
from tppt import Presentation
7+
Slide layout definitions are declarative.
108

11-
# 16:9のワイドスクリーン形式
12-
presentation = Presentation(slide_width=16, slide_height=9)
13-
14-
# 4:3の標準形式
15-
presentation = Presentation(slide_width=4, slide_height=3)
16-
```
17-
18-
### 2. マージンの設定
19-
```python
20-
# スライドの余白を設定
21-
slide = presentation.add_slide()
22-
slide.set_margins(left=1.0, right=1.0, top=0.5, bottom=0.5)
23-
```
24-
25-
## 一般的なレイアウトパターン
26-
27-
### 1. タイトルスライド
28-
```python
29-
slide = presentation.add_slide()
30-
slide.add_title("プレゼンテーションのタイトル")
31-
slide.add_subtitle("サブタイトル")
32-
```
33-
34-
### 2. 2カラムレイアウト
35-
```python
36-
slide = presentation.add_slide()
37-
left_column = slide.add_column(width=0.5)
38-
right_column = slide.add_column(width=0.5)
39-
40-
left_column.add_text("左側のコンテンツ")
41-
right_column.add_text("右側のコンテンツ")
42-
```
43-
44-
### 3. 画像とテキストの組み合わせ
45-
```python
46-
slide = presentation.add_slide()
47-
slide.add_image("path/to/image.png", width=0.6)
48-
slide.add_text("画像の説明文", position="bottom")
49-
```
50-
51-
## レイアウトのカスタマイズ
52-
53-
### 1. グリッドシステムの利用
54-
```python
55-
slide = presentation.add_slide()
56-
grid = slide.add_grid(rows=2, cols=2)
57-
grid[0, 0].add_text("セル1")
58-
grid[0, 1].add_text("セル2")
59-
grid[1, 0].add_text("セル3")
60-
grid[1, 1].add_text("セル4")
61-
```
62-
63-
### 2. フレックスボックスレイアウト
64-
```python
65-
slide = presentation.add_slide()
66-
flex = slide.add_flex_container()
67-
flex.add_item("アイテム1", flex_grow=1)
68-
flex.add_item("アイテム2", flex_grow=2)
69-
```
70-
71-
## ベストプラクティス
72-
73-
1. **一貫性の維持**
74-
- 同じ種類のスライドでは、常に同じレイアウトを使用する
75-
- マージンやパディングの値を統一する
76-
77-
2. **視覚的な階層構造**
78-
- 重要な情報は大きく、目立つように配置
79-
- 補足情報は小さく、控えめに配置
80-
81-
3. **余白の活用**
82-
- 適切な余白を確保し、見やすいレイアウトを心がける
83-
- 要素同士の間隔を適切に設定する
84-
85-
4. **レスポンシブ対応**
86-
- 異なる画面サイズでも見やすいレイアウトを考慮
87-
- コンテンツの自動調整機能を活用する
9+
Currently, only placeholder definitions are supported.

docs/docs/usage/slide.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Slides are composed of a combination of text, pictures, and tables.
2+
3+
They are created based on slide layouts, and shapes are added using the builder pattern.

docs/docs/usage/table.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Tables have a simple wrapper that makes table creation easier.
2+
3+
Let's look at the simplest table.
4+
5+
```python
6+
--8<-- "codes/table.py"
7+
```
8+
9+
It's easy to understand.
10+
11+
In addition to this, tppt supports polars, pandas, pydantic, and dataclass to handle data analysis results.
12+
13+
```python
14+
--8<-- "codes/polars.py"
15+
```

0 commit comments

Comments
 (0)