python - 尝试使用 python 代码关闭和打开 LibreOffice Impress
问题描述
使用树莓派运行 raspian。我想在触发器发生时打开一个 *.odp,然后当另一个触发器发生时,关闭文件,然后打开另一个 *.odp 文件。问题:一旦 LibreOffice Impress 打开,它似乎不再可用于通过终端接收命令。这些命令似乎只有在我们手动关闭 LibreOffice Impress 后才起作用。
我们已经成功地通过终端直接发送和通过我们的 python 脚本打开一个特定的 *.odp 文件。但是,我们似乎无法关闭演示文稿以便打开另一个演示文稿。
这是一段代码。射频代码是从遥控器接收...
cmd_openShowOn = "sudo libreoffice --nologo --show /home/pi/Documents/memorable.odp"
cmd_openShowOff = "sudo libreoffice --nologo --show /home/pi/Documents/forgettable.odp"
cmd_kill = "pkill soffice.bin"
if rfdevice.rx_code_timestamp != timestamp:
timestamp = rfdevice.rx_code_timestamp
logging.info(str(rfdevice.rx_code) +
" [pulselength " + str(rfdevice.rx_pulselength) +
", protocol " + str(rfdevice.rx_proto) + "]")
if str(rfdevice.rx_code) == "87347": # receives code to trigger closing anything that might be open and opening slide show for 'memorable.odp'
print ("Laser On")
os.system(cmd_kill)
os.system(cmd_openShowOn)
if str(rfdevice.rx_code) == "87356": # receives code to trigger closing anything that might be open and opening slide show for 'forgettable.odp'
print("Laser Off")
os.system(cmd_kill)
os.system(cmd_openShowOff)
time.sleep(1)
在我们手动终止 LibreOffice Impress 之前,任何来自 LibreOffice Impress 的后续响应都会被忽略。
解决方案
推荐阅读
- shared-libraries - 找不到 libfftw_mpi.so
- javascript - 如何动态更改图标源
- r - 如何在另一个块中绘制一个块中的数据?
- python - 使用瓶子和线程上传文件
- laravel - 如何在 Laravel 中获取 POST 数据?
- excel - 复制工作表错误:复制区域和粘贴区域大小不同
- mobile - 如何解决 Collapsible AnimatedContainer 的溢出颤动?
- javascript - 更改在 html 表中搜索的列
- php - 如何设置 404 页面的路由?
- java - org.springframework.beans.NotReadablePropertyException:bean 类的属性无效