[Libreoffice] python - msgbox fragment ...
Michael Meeks
michael.meeks at novell.com
Mon Apr 11 09:01:02 PDT 2011
Hi Timo,
On Sat, 2011-04-09 at 02:22 +0200, Timo wrote:
> Is there a way to test the pythonfile within office? At the moment each
> time i kill soffice, restart writer and click
So - after a bit more digging; I got to here:
class MessageBox:
def __init__(self, XParentWindow):
try:
if XParentWindow is None:
frame = XSCRIPTCONTEXT.getDesktop().getCurrentFrame()
XParentWindow = frame.getContainerWindow()
self.Parent = XParentWindow
self.Toolkit = XParentWindow.getToolkit()
except:
raise AttributeError, 'Did not get a valid parent window'
def msgbox(self, message='', flag=0, title=''):
'''Wrapper for com.sun.star.awt.XMessageBoxFactory.'''
rect = uno.createUnoStruct('com.sun.star.awt.Rectangle')
dlg = self.Toolkit.createMessageBox(self.Parent, rect, "errorbox", 1, title, message)
dlg.execute()
Which at least works for me, though I couldn't see why the
com.sun.star.awt.MessageBoxButtons set of constants wouldn't work nicely
for me.
When I whack that into my system's TableSample.py and add:
box = MessageBox(None)
box.msgbox ("What is this ?")
to createTable() - I get a nice message-box first :-) I bound running
that macro to F4 to make it quicker to loop iterate / check the code
The UNO API is pretty fearsome to use, it can help to read the
interface comments in offapi/ but it is not for the faint hearted,
clearly :-)
I guess, seeing how broken the C++ side is - with helpful comments
like:
if(!bIsLoggedIn)
{
OSL_FAIL("create error message");
return;
}
that simply don't create an error message, or do anything useful -
perhaps a chunk of the work needed is on the C++ side anyway.
HTH,
Michael.
--
michael.meeks at novell.com <><, Pseudo Engineer, itinerant idiot
More information about the LibreOffice
mailing list