Here's a stripped-to-basics version of my code:
Code: Select all
# example of creating a dialog using Python
import uno
from com.sun.star.awt.PosSize import POSSIZE
def addAwtModel(oDM,srv,sName,dProps):
oCM = oDM.createInstance("com.sun.star.awt.UnoControl"+ srv +"Model")
while dProps:
prp = dProps.popitem()
uno.invoke(oCM,"setPropertyValue",(prp[0],prp[1]))
oCM.Name = sName
oDM.insertByName(sName,oCM)
def addShareDlg():
ctx = uno.getComponentContext()
smgr = ctx.ServiceManager
oDM = smgr.createInstance("com.sun.star.awt.UnoControlDialogModel")
oDM.Title = 'Test'
oDialog = smgr.createInstance("com.sun.star.awt.UnoControlDialog")
oDialog.setModel(oDM)
addAwtModel(oDM,'ListBox','myListBox',{})
listText = oDialog.getControl('myListBox')
listText.addItem('aaa',1)
listText.addItem('bbb',2)
listText.setPosSize(10,10,400,300, POSSIZE) # x, y, width, height, flag
oDialog.setPosSize(20,0,500,500,POSSIZE)
oDialog.setVisible(True)
x = oDialog.execute()
Can someone please point me in the right direction? Many thanks.