Skip to content

Commit a07db28

Browse files
committed
fix: improve error handling for missing Polars by using tppt presentation
1 parent c97f28e commit a07db28

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

examples/dataflame_table.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
"""Example of creating tables from Polars dataframe."""
22

3-
import sys
43
from pathlib import Path
54

65
import tppt
76
from tppt.types import Color
87

98
# Flag to determine whether to use Polars
10-
USE_POLARS = True
119
EXAMPLE_DIR = Path(__file__).parent
1210

1311

1412
def main():
1513
"""Run the sample."""
16-
import polars as pl
14+
import polars as pl # type: ignore
1715

1816
# Create dataframe with Polars
1917
df = pl.DataFrame(
@@ -80,10 +78,17 @@ def main():
8078

8179

8280
if __name__ == "__main__":
81+
from tppt._features import USE_POLARS
82+
8383
if USE_POLARS:
8484
main()
8585
else:
86-
print(
87-
"Polars is not installed. Please install it to run this example.",
88-
file=sys.stderr,
89-
)
86+
tppt.Presentation.builder().slide(
87+
tppt.SlideBuilder().text(
88+
"Polars is not installed. Please install it to run this example.",
89+
left=(50, "pt"),
90+
top=(50, "pt"),
91+
width=(500, "pt"),
92+
height=(50, "pt"),
93+
)
94+
).build().save(EXAMPLE_DIR / "dataflame_table.pptx")

0 commit comments

Comments
 (0)