OOo Basic 以外でエラーダイアログなどを利用する 
OOo Basic では MsgBox を利用すると簡単にエラーや情報、などの表示ができます。しかし、Python や他の言語からでは OOo Basic と同じようには利用できません。
その代わりに com.sun.star.awt.XMessageBoxFactory インターフェースを利用します。
ダイアログの種類 
ダイアログの種類は次のものがあります。ボタンの表示指定は com.sun.star.awt.MessageBoxButtons の定数で行います。
サービス名 | ダイアログ |
messbox | メッセージボックス |
warningbox | 警告 |
errorbox | エラー |
querybox | 疑問 |
infobox | 情報 |
例 
Py-UNO だと適当に次のような感じにします。ダイアログのサイズを指定しても無視されるので (自動調整) 適当にします。
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| | import uno
def message_box(toolkit,parent,box_type,btns,title="",message=""):
return toolkit.createMessageBox(
parent,
uno.createUnoStruct("com.sun.star.awt.Rectangle"),
box_type, btns,
title, message)
def show_dlg():
#.... needs toolkit and window peer as parent
dlg = message_box(toolkit,parent,"errorbox",1,"error","!!! error.")
n = dlg.execute()
dlg.dispose()
|
createMessageBox メソッドの戻り値は executable ダイアログなので、表示は execute メソッドで行います。ダイアログは使い終わったら dispose してやります。