Hello World (PyUNO
OpenOffice 2.2 有自带一个 Python 2.3.4 版的解译器,位於D:\Program Files\OpenOffice.org 2.2\program\python-core-2.3.4测试程式:
(注意,必须使用 Unix Line Feed 来換行。在 UltraEdit 中使用[转換->DOS 转 UNIX]。)
C:\Documents and Settings\${user}\Application Data\OpenOffice.org2\user\Scripts\python\test.py
需把 ${user} 換为登入的帐号名称。
java 代码
[*]def sayHello( ):
[*] """sayHello"""
[*] model = XSCRIPTCONTEXT.getDocument()
[*] text = model.Text
[*] cursor = text.createTextCursor()
[*] text.insertString( cursor, "Pyton says, Hello World", 0 )
[*]
[*]def sayHello2( ):
[*] """sayHello2"""
[*] model = XSCRIPTCONTEXT.getDocument()
[*] text = model.Text
[*] cursor = text.createTextCursor()
[*] text.insertString( cursor, "Pyton says, Hello World2", 0 )
每一个 python 的函式都可以做为执行点,可以下列方式来执行 Python Macro。
结果会在游标所在处出现 Python says, Hello World
页:
[1]