Code: Select all
from apso_utils import mri, msgbox
Did I miss something during the installation? I precise that all my python macro works well. It's just that APSO sounds very handfull.
Code: Select all
from apso_utils import mri, msgbox
Code: Select all
ln ~/.config/libreoffice/4/user/uno_packages/cache/uno_packages/lu22318xbgt0a.tmp_/apso.oxt/python/pythonpath ~/.config/libreoffice/4/user/Scripts/python/pythonpath
Code: Select all
import uno
from com.sun.star.awt.MessageBoxType import MESSAGEBOX, INFOBOX, WARNINGBOX, ERRORBOX, QUERYBOX
from com.sun.star.awt.MessageBoxButtons import BUTTONS_OK, BUTTONS_OK_CANCEL, BUTTONS_ABORT_IGNORE_RETRY, BUTTONS_YES_NO_CANCEL, BUTTONS_YES_NO, BUTTONS_RETRY_CANCEL, DEFAULT_BUTTON_OK, DEFAULT_BUTTON_CANCEL, DEFAULT_BUTTON_RETRY, DEFAULT_BUTTON_YES, DEFAULT_BUTTON_NO, DEFAULT_BUTTON_IGNORE
from com.sun.star.awt.MessageBoxResults import CANCEL, OK, YES, NO, RETRY, IGNORE
class Office:
'''Frequently used office objects and useful methods'''
def __init__(self, local_context = uno.getComponentContext(), connect_string = ''):
if connect_string:
# "uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext"
resolver = local_context.ServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", local_context )
self.ctx = ctx = resolver.resolve(connect_string)
else:
self.ctx = local_context
self.smgr = self.ctx.getServiceManager()
self.tk = self.smgr.createInstance('com.sun.star.awt.Toolkit')
self.StarDesktop = self.smgr.createInstance('com.sun.star.frame.Desktop')
self.win = None
def getDocument(self):
return self.StarDesktop.CurrentFrame.Controller.getModel()
def createUnoService(self, name,):
return self.smgr.createInstance(name)
def getURLStruct(self, sURL):
url = uno.createUnoStruct('com.sun.star.util.URL')
srv = self.createUnoService('com.sun.star.util.URLTransformer')
url.Complete = sURL
x = uno.invoke(srv,"parseStrict",(uno.Any('com.sun.star.util.URL',url),))
return x[0]==True and x[1] or Null
def getPropertyValue(self, n, v):
p = uno.createUnoStruct('com.sun.star.beans.PropertyValue')
p.Name = n
p.Value = v
return p
def setMsgboxWindow(self, win):
self.win = win
def msgbox(self,title='<Dummy>',msg='<Hello World>',etyp=MESSAGEBOX,ebtn=BUTTONS_OK):
mbox = self.tk.createMessageBox(self.win,etyp,ebtn,title,msg)
return mbox.execute()
def mri(self, obj):
mri = self.createUnoService("mytools.Mri")
mri.inspect(obj)
If you don't launch Apso once in your session, apso_utils will not be found .Apso readme wrote:APSO comes with a small library apso_utils that contains some helpers for debugging purpose during macro writing. [...] The module apso_utils can't be imported before APSO was first loaded. Only the console macro is accessible outside APSO.
The module apso_utils can't be imported before APSO was first loaded.
hubert lambert wrote:If you don't launch Apso once in your session, apso_utils will not be found.
Code: Select all
def entryfunc(event=None):
ctx = XSCRIPTCONTEXT.getComponentContext()
ctx.ServiceManager.createInstance("apso.python.script.organizer.impl")
# now we can use apso_utils library
from apso_utils import console
console()