Python实现从PPT中导出高分辨率图片
作者:小锋学长生活大爆炸 时间:2023-01-03 16:29:08
总结为:改注册表。
顺手写个脚本:
import tkinter as tk
from tkinter import ttk
import winreg
from tkinter import messagebox
class App(tk.Frame):
def __init__(self, master=None):
super().__init__(master)
self.master = master
self.pack()
self.version_maps = {
"Microsoft 365 ": "16.0",
"PowerPoint 2019": "16.0",
"PowerPoint 2016": "16.0",
"PowerPoint 2013": "15.0",
"PowerPoint 2010": "14.0",
"PowerPoint 2007": "12.0",
"PowerPoint 2003": "11.0",
}
self.center_window()
self.create_widgets()
def center_window(self):
width = 250
height = 200
screen_width = self.master.winfo_screenwidth()
screen_height = self.master.winfo_screenheight()
x = (screen_width - width) // 2
y = (screen_height - height) // 2
self.master.geometry(f"{width}x{height}+{x}+{y}")
self.master.title("PPT改DPI")
def create_widgets(self):
self.version_label = tk.Label(self, text="选择Office版本:")
self.version_label.pack()
self.version_var = tk.StringVar(self)
self.version_var.set(list(self.version_maps.keys())[0])
self.version_combobox = ttk.Combobox(
self,
textvariable=self.version_var,
values=list(self.version_maps.keys()),
state="readonly"
)
self.version_combobox.pack()
self.value_label = tk.Label(self, text="输入要修改的值:")
self.value_label.pack(pady=5)
self.value_entry = tk.Entry(self)
self.value_entry.insert(0, "96")
self.value_entry.pack(pady=5)
self.process_button = tk.Button(self, text="执行修改", command=self.process, width=15)
self.process_button.pack(pady=5)
self.quit_button = tk.Button(self, text="退出", command=self.master.destroy, width=15)
self.quit_button.pack(pady=5)
def process(self):
version = self.version_maps.get(self.version_var.get())
input_value = int(self.value_entry.get())
# 定义注册表路径和项名
reg_path = fr"Software\Microsoft\Office\{version}\PowerPoint\Options"
reg_key = "ExportBitmapResolution"
try:
# 打开注册表项
key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, reg_path, 0, winreg.KEY_ALL_ACCESS)
except:
messagebox.showerror("错误", f"注册表项不存在,请检查: {reg_path}")
return
try:
# 尝试获取项的值
value, reg_type = winreg.QueryValueEx(key, reg_key)
if reg_type == winreg.REG_DWORD:
# 如果项存在且类型为DWORD32,修改它的值
winreg.SetValueEx(key, reg_key, 0, winreg.REG_DWORD, input_value)
else:
messagebox.showerror("失败", "注册表项类型不符合要求")
except FileNotFoundError:
# 如果项不存在,创建它并设置为DWORD32类型
winreg.SetValueEx(key, reg_key, 0, winreg.REG_DWORD, input_value)
# 修改它的值
winreg.SetValueEx(key, reg_key, 0, winreg.REG_DWORD, input_value)
messagebox.showinfo("成功 ", "修改后的值 =>" + str(winreg.QueryValueEx(key, reg_key)[0]))
# 关闭注册表项
winreg.CloseKey(key)
root = tk.Tk()
app = App(master=root)
app.mainloop()
效果图
来源:https://blog.csdn.net/sxf1061700625/article/details/130557903
标签:Python,PPT,图片
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
python字典基本操作实例分析
2023-12-04 09:25:22
浅谈Python numpy创建空数组的问题
2022-10-10 07:11:08
![](https://img.aspxhome.com/file/2023/3/127823_0s.png)
一篇文章介绍redux、react-redux、redux-saga总结
2023-08-22 16:56:32
![](https://img.aspxhome.com/file/2023/2/55972_0s.jpg)
Python制作exe文件简单流程
2022-06-07 01:11:12
![](https://img.aspxhome.com/file/2023/2/91852_0s.png)
python定时器(Timer)用法简单实例
2021-01-10 15:43:04
Pandas中GroupBy具体用法详解
2023-08-10 04:16:42
更新修改后的Python模块方法
2022-02-20 15:34:09
![](https://img.aspxhome.com/file/2023/3/109613_0s.png)
python DataFrame数据格式化(设置小数位数,百分比,千分位分隔符)
2021-02-03 21:34:10
![](https://img.aspxhome.com/file/2023/1/68921_0s.png)
mssql存储过程表名和字段名为变量的实现方法
2011-12-01 07:59:13
html网页调用后端python代码的方法实例
2023-04-20 19:31:51
![](https://img.aspxhome.com/file/2023/0/121160_0s.png)
Python识别html主要文本框过程解析
2023-11-09 01:31:52
![](https://img.aspxhome.com/file/2023/1/95771_0s.jpg)
Python中shutil模块的学习笔记教程
2022-12-22 20:42:05
python代码的几种常见加密方式分享
2021-05-19 02:14:56
![](https://img.aspxhome.com/file/2023/1/90781_0s.png)
Python生成可执行文件之PyInstaller库的使用方式
2021-11-29 00:41:49
![](https://img.aspxhome.com/file/2023/5/121685_0s.png)
新手入门:防范SQL注入攻击的新办法
2009-03-11 15:14:00
pandas读取Excel批量转换时间戳的实践
2023-04-20 12:47:07
Python 如何将 matplotlib 图表集成进到PDF 中
2023-03-18 09:07:56
![](https://img.aspxhome.com/file/2023/1/107471_0s.png)
python关键字传递参数实例分析
2023-08-24 04:28:34
pjblog3相关日志功能(支持生成静态模式)
2008-11-20 13:41:00
win2000server IIS和tomcat5多站点配置
2023-06-26 04:45:33