Hướng dẫn python powerpoint - python powerpoint

  • admin
  • 28/08/2022
  • 0
  • Lập trình Python

Bài trình chiếu này do thầy Nguyễn Thanh Tùng một trong những tác giả bộ sách Tin học 10 Cánh Diều đã biên soạn.

Hướng dẫn python powerpoint - python powerpoint

Xin lưu ý: Các bài trình chiếu từ các bài về Chương trình con có mở rông để bồi dưỡng thêm cho GV là chính nên khi dạy cho HS, các thầy cô cần chỉnh sửa cẩn trọng theo mức như SGK, tránh quá tải.

Tải về Bài trình chiếu PowerPoint lập trình Python cơ bản

  • Output: file file_text.txt
  • admin
  • 0
  • 28/08/2022

Lập trình PythonShow

  • Cài đặt: Mở Command prompt
  • Ví dụ 1: Tạo tệp PowerPoint mới với slide có tiêu đề và phụ đề
  • Ví dụ 2: Thêm Text-Box trong PowerPoint
  • Ví dụ 2: Thêm Text-Box trong PowerPoint
  • Ví dụ 3: Chuyển đổi tệp PowerPoint (.pptx) sang tệp Văn bản (.txt)
  • Output: file file_text.txt

admin

28/08/2022

Lập trình Python

  • Output: file file_text.txt
  • admin

28/08/2022

Lập trình Python

Nội dung chính Show

28/08/2022

Lập trình Python

Nội dung chính Show

Bài trình chiếu này do thầy Nguyễn Thanh Tùng một trong những tác giả bộ sách Tin học 10 Cánh Diều đã biên soạn.

Xin lưu ý: Các bài trình chiếu từ các bài về Chương trình con có mở rông để bồi dưỡng thêm cho GV là chính nên khi dạy cho HS, các thầy cô cần chỉnh sửa cẩn trọng theo mức như SGK, tránh quá tải.

Tải về Bài trình chiếu PowerPoint lập trình Python cơ bản

Ví dụ 4: Chèn hình ảnh vào tệp PowerPoint

Tuyệt vời ! Đây là một số ví dụ để bạn có thể sử dụng powerpoint bằng python.

Bạn cũng có thể học khóa học Python cơ bản và thiết kế game với python của tôi trên Unica để biết thêm chủ đề tuyệt vời khác.

12/08/2022

Lập trình Python

Bài 1 – Tìm hiểu về ngôn ngữ lập trình Python

Bài 2 – Phép toán, biểu thức, câu lệnh gán, hàm số học chuẩn

Cài đặt: Mở Command prompt

pip install python-pptx

Hãy xem một số cách sử dụng của thư viện này:

Ví dụ 1: Tạo tệp PowerPoint mới với slide có tiêu đề và phụ đề

from pptx import Presentation      
  
root = Presentation() 
  
# Tạo slide layout
first_slide_layout = root.slide_layouts[0]  
  
""" Layout:  
0 ->  title and subtitle 
1 ->  title and content 
2 ->  section header 
3 ->  two content 
4 ->  Comparison 
5 ->  Title only  
6 ->  Blank 
7 ->  Content with caption 
8 ->  Pic with caption 
"""
  
# Tạo Slide mới và gán đối tượng cho biến
slide = root.slides.add_slide(first_slide_layout) 
  
# Thêm title và subtitle trong Slide
slide.shapes.title.text = " Tạo bởi python-pptx"
  
# Tạo subtitle
slide.placeholders[1].text = "Subtitle ở đây"
  
# Saving file 
root.save("Output.pptx") 
  
print("done")

Output

Ví dụ 2: Thêm Text-Box trong PowerPoint

from pptx import Presentation  
from pptx.util import Inches, Pt 
  
ppt = Presentation()  
  
# Tạo blank layout 
blank_slide_layout = ppt.slide_layouts[6]  
  
# Tạo slide mới 
slide = ppt.slides.add_slide(blank_slide_layout) 
  
# Margin  
left = top = width = height = Inches(1)  
  
# Tạo textBox 
txBox = slide.shapes.add_textbox(left, top, 
                                 width, height) 
  
# Tạo textFrames 
tf = txBox.text_frame 
tf.text = "Đây là văn bản bên trong textbox"
  
# Thêm Paragraphs 
p = tf.add_paragraph()  
  
# adding text 
p.text = "Đoạn thứ hai này in đậm và in nghiêng" 
  
p.font.bold = True
p.font.italic = True
  
p = tf.add_paragraph() 
p.text = "Đoạn thứ ba này font chữ lớn nhé !!!" 
p.font.size = Pt(40) 
  
# save file 
ppt.save('test_2.pptx') 
  
print("done")

Output

Ví dụ 2: Thêm Text-Box trong PowerPoint

from pptx import Presentation 
  
ppt = Presentation("test_2.pptx") 
  
# open file
File_to_write_data = open("file_text.txt", "w") 
  
for slide in ppt.slides:  
    for shape in slide.shapes:  
        if not shape.has_text_frame:  
            continue 
        for paragraph in shape.text_frame.paragraphs:  
            for run in paragraph.runs:  
                File_to_write_data.write(run.text + "\n") 
  
# close the file                
File_to_write_data.close() 
  
print("Done")

Ví dụ 3: Chuyển đổi tệp PowerPoint (.pptx) sang tệp Văn bản (.txt)

Output: file file_text.txt

from pptx import Presentation  
from pptx.util import Inches  
  
# Image path  
img_path = 'nghia.png' 
  
ppt = Presentation()  
  
blank_slide_layout = ppt.slide_layouts[6]  
  
slide = ppt.slides.add_slide(blank_slide_layout)  
  
# Margins 
left = top = Inches(1)  
  
height = Inches(3)  
  
pic = slide.shapes.add_picture(img_path, left, 
                               top, height = height) 
# save file 
ppt.save('test_4.pptx') 
  
print("Done")

Output

from pptx import Presentation  
from pptx.util import Inches 
  
ppt = Presentation()  
  
slide = ppt.slides.add_slide(ppt.slide_layouts[6]) 
  
# Điều chỉnh kích thước   
x, y, cx, cy = Inches(2), Inches(2), Inches(4), Inches(1.5)  
  
# Thêm Table
shape = slide.shapes.add_table(3, 4, x,  
                               y, cx, cy) 
  
# Saving 
ppt.save("test_5.pptx") 
  
print("done")

Output

Ví dụ 2: Thêm Text-Box trong PowerPoint

Ví dụ 3: Chuyển đổi tệp PowerPoint (.pptx) sang tệp Văn bản (.txt)