Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -315,19 +315,32 @@ def main():
|
|
| 315 |
display_centers()
|
| 316 |
display_other_properties()
|
| 317 |
|
|
|
|
| 318 |
fig = plot_triangle(vertices, properties)
|
| 319 |
|
| 320 |
-
|
| 321 |
-
|
|
|
|
| 322 |
coords['x1'], coords['y1'], coords['x2'], coords['y2'], coords['x3'], coords['y3'],
|
| 323 |
a, b, c, A, B, C, area, perimeter, I_x, I_y, U_x, U_y, G_x, G_y,
|
| 324 |
midpoints, radius_in, radius_circum, fig
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 329 |
|
| 330 |
-
# New code for Save as PDF
|
| 331 |
# if st.button("Save as PDF"):
|
| 332 |
# try:
|
| 333 |
# # Add debug message
|
|
|
|
| 315 |
display_centers()
|
| 316 |
display_other_properties()
|
| 317 |
|
| 318 |
+
# Plot triangle
|
| 319 |
fig = plot_triangle(vertices, properties)
|
| 320 |
|
| 321 |
+
### Code for Save as PDF
|
| 322 |
+
# Generate the PDF in-memory
|
| 323 |
+
pdf_file = save_as_pdf_reportlab(
|
| 324 |
coords['x1'], coords['y1'], coords['x2'], coords['y2'], coords['x3'], coords['y3'],
|
| 325 |
a, b, c, A, B, C, area, perimeter, I_x, I_y, U_x, U_y, G_x, G_y,
|
| 326 |
midpoints, radius_in, radius_circum, fig
|
| 327 |
+
)
|
| 328 |
+
|
| 329 |
+
# Allow user to download the generated PDF file
|
| 330 |
+
st.download_button("Download PDF", pdf_file, file_name="Triangle_solver_results.pdf", mime="application/pdf")
|
| 331 |
+
|
| 332 |
+
### Old code for Save as PDF
|
| 333 |
+
# if st.button("Save as PDF"):
|
| 334 |
+
# save_as_pdf_reportlab(
|
| 335 |
+
# coords['x1'], coords['y1'], coords['x2'], coords['y2'], coords['x3'], coords['y3'],
|
| 336 |
+
# a, b, c, A, B, C, area, perimeter, I_x, I_y, U_x, U_y, G_x, G_y,
|
| 337 |
+
# midpoints, radius_in, radius_circum, fig
|
| 338 |
+
# )
|
| 339 |
+
# st.success("Results saved as PDF!")
|
| 340 |
+
# with open("Triangle_solver_results.pdf", "rb") as pdf_file:
|
| 341 |
+
# st.download_button("Download PDF", pdf_file, file_name="Triangle_solver_results.pdf")
|
| 342 |
|
| 343 |
+
### New code for Save as PDF
|
| 344 |
# if st.button("Save as PDF"):
|
| 345 |
# try:
|
| 346 |
# # Add debug message
|