从Python控制Libreoffice Impress [英] Control Libreoffice Impress from Python

查看:378
本文介绍了从Python控制Libreoffice Impress的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写面向演讲者和会议的应用程序.我用Python编写代码,并专注于Linux.

Im writing an application oriented to speakers and conferences. Im writing it with Python and focused on Linux.

我想知道是否可以在Linux下以某种方式使用Python控制LibreOffice Impress.

I would like to know if its possible to control LibreOffice Impress with Python, under Linux in some way.

我想从我的Python应用程序启动一个加载了某些.odp文件的LibreOffice Impress实例.然后,我希望能够从odp接收一些信息,例如:上一张,当前和下一张幻灯片.或以某种方式随时随地生成幻灯片的图像.

I want to start an instance of LibreOffice Impress with some .odp file loaded, from my Python app. Then, I would like to be able to receive from the odp some info like: previous, current and next slide. Or somehow generate the images of the slides on the go.

最后,我想实时控制LibreOffice.这是:使用方向键在幻灯片中移动;左右.

Finally, I want to control LibreOffice in real time. This is: move through the slides using direction keys; right and left.

想法是单独使用python,但我不介意使用外部库或框架.

The idea is to use python alone, but I don't mind using external libraries or frameworks.

非常感谢.

推荐答案

最后,我找到了一种使用Python的简便易行的方法来解决此问题. Im不是使用库或API,而是使用套接字连接到Impress并对其进行控制.

Finally, I found a way to solve this using Python, in an elegant and easy way. Instead of libraries or APIs, Im using a socket to connect to Impress and control it.

在文章末尾,您可以阅读全文,该全文指示如何以这种方式控制Impress.这很容易,而且很神奇.

At the end of the post you can read the full-text that indicates how to control Impress this way. It is easy, and amazing.

您使用Python向Impress发送一条消息(正在某个端口监听),它会接收该消息并根据您的请求执行操作.

You send a message using Python to Impress ( that is listening in some port ), it receives the message and does things based on your request.

您必须在应用程序中启用此远程控制"功能.我用这个解决了我的问题.

You must enable this "remote control" feeature in the app. I solved my problem using this.

感谢您的回复!.

通信是通过UTF-8编码的字符流进行的. (在LibreOffice部分中使用RTL_TEXTENCODING_UTF8.)

Communication is over a UTF-8 encoded character stream. (Using RTL_TEXTENCODING_UTF8 in the LibreOffice portion.)

有关设置和初始握手的更多TCP特定细节 编写,但实际的消息协议与蓝牙相同.

More TCP-specific details on setup and initial handshake to be written, but the actual message protocol is the same as for Bluetooth.

一条消息由一个或多个行组成.第一行是消息说明, 进一步的行可以添加任何必要的数据.空行表示该消息.

A message consists of one or more lines. The first line is the message description, further lines can add any necessary data. An empty line concludes the message.

即"MESSAGE \ n \ n"或"MESSAGE \ nDATA \ nDATA2 ... \ n \ n"

I.e. "MESSAGE\n\n" or "MESSAGE\nDATA\nDATA2...\n\n"

您必须继续阅读邮件,直到出现空白行(例如, 换行)以允许将来的协议扩展.

You must keep reading a message until an empty line (i.e. double new-line) is reached to allow for future protocol extension.

连接后,服务器将发送"LO_SERVER_SERVER_PAIRED". (即"LO_SERVER_SERVER_PAIRED \ n \ n"通过流发送.)

Once connected the server sends "LO_SERVER_SERVER_PAIRED". (I.e. "LO_SERVER_SERVER_PAIRED\n\n" is sent over the stream.)

随后,如果正在运行幻灯片放映,服务器将发送slideshow_started, 或slideshow_finished(如果没有幻灯片正在运行). (有关详细信息,请参见下文.)

Subsequently the server will send either slideshow_started if a slideshow is running, or slideshow_finished if no slideshow is running. (See below for details of.)

然后,当前服务器实现继续发送所有幻灯片注释和预览 给客户. (应对此进行更改,以防止出现内存问题,并进行预览 请求机制已实现.)

The current server implementation then proceeds to send all slide notes and previews to the client. (This should be changed to prevent memory issues, and a preview request mechanism implemented.)

在以下情况下,客户端不应假定服务器的状态已更改: 命令已发送.所有更改都将以信号通知给客户端. (这是为了允许多个客户端请求不同的更改等情况.)

The client should not assume that the state of the server has changed when a command has been sent. All changes will be signalled back to the client. (This is to allow for cases such as multiple clients requesting different changes, etc.)

[方括号]中的任何行都是可选的,如果不需要,则应省略.

Any lines in [square brackets] are optional, and should be omitted if not needed.

  • transition_next
  • transition_previous

  • transition_next
  • transition_previous

goto_slide slide_number

goto_slide slide_number

presentation_start

presentation_start

presentation_stop

presentation_stop

presentation_resume////在presentation_blank_screen之后恢复.

presentation_resume // Resumes after a presentation_blank_screen.

  • pointer_started//在屏幕的初始位置(x,y)创建一个红点 initial_x//用户首次触摸屏幕时应调用 initial_y//请注意,x,y相对于幻灯片大小以百分比表示(从0.0到1.0)
  • pointer_dismissed//关闭屏幕上的指针红点,当用户停止触摸屏幕时应调用
  • pointer_coordination//将指针的位置更新为当前(x,y) current_x//请注意,x,y以相对于幻灯片大小的百分比(从0.0到1.0)表示 current_y////除非screenupdater的性能得到显着改善,否则我们应该考虑限制更新的频率. //远端
  • pointer_started // create a red dot on screen at initial position (x,y) initial_x // This should be called when user first touch the screen initial_y // note that x, y are in percentage (from 0.0 to 1.0) with respect to the slideshow size
  • pointer_dismissed // This dismiss the pointer red dot on screen, should be called when user stop touching screen
  • pointer_coordination // This update pointer's position to current (x,y) current_x // note that x, y are in percentage (from 0.0 to 1.0) with respect to the slideshow size current_y // unless screenupdater's performance is significantly improved, we should consider limit the update frequency on the // remote-end
  • slideshow_finished//(如果开始播放时没有幻灯片放映,也会发送.)

  • slideshow_finished // (Also transmitted if no slideshow running when started.)

slideshow_started//(如果幻灯片在启动时正在运行,则也发送.) numberOfSlides currentSlideNumber

slideshow_started // (Also transmitted if a slideshow is running on startup.) numberOfSlides currentSlideNumber

幻灯片注释 slideNumber [Notes]//注释是html文档,也可能包含\ n换行符, //即客户端应继续阅读,直到到达空白行为止.

slide_notes slideNumber [Notes] // The notes are an html document, and may also include \n newlines, // i.e. the client should keep reading until a blank line is reached.

slide_updated//服务器上的幻灯片已更改 currentSlideNumber

slide_updated // Slide on server has changed currentSlideNumber

slide_preview//提供幻灯片的预览图像. slideNumber 图片//基本为64编码的png图片.

slide_preview // Supplies a preview image for a slide. slideNumber image // A Base 64 Encoded png image.

  • slideshow_info//配对后,服务器端将发回当前演示文稿的标题 标题
  • slideshow_info // once paired, the server-end will send back the title of the current presentation Title

这篇关于从Python控制Libreoffice Impress的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆