29 lines
895 B
Python
29 lines
895 B
Python
#!/usr/bin/env python3
|
|
|
|
import uno
|
|
from com.sun.star.awt import MessageBoxButtons as MSG_BUTTONS
|
|
OK = MSG_BUTTONS.BUTTONS_OK
|
|
|
|
|
|
CTX = uno.getComponentContext()
|
|
SM = CTX.getServiceManager()
|
|
|
|
|
|
def create_instance(name, with_context=False):
|
|
if with_context:
|
|
instance = SM.createInstanceWithContext(name, CTX)
|
|
else:
|
|
instance = SM.createInstance(name)
|
|
return instance
|
|
|
|
|
|
def msgbox(message, title='ZAZ Python Custom Path', buttons=OK, type_msg='infobox'):
|
|
""" Create message box
|
|
type_msg: infobox, warningbox, errorbox, querybox, messbox
|
|
http://api.libreoffice.org/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1awt_1_1XMessageBoxFactory.html
|
|
"""
|
|
toolkit = create_instance('com.sun.star.awt.Toolkit')
|
|
parent = toolkit.getDesktopWindow()
|
|
box = toolkit.createMessageBox(parent, type_msg, buttons, title, str(message))
|
|
return box.execute()
|