| View previous topic :: View next topic |
| Author |
Message |
karenj General User

Joined: 20 Mar 2008 Posts: 9 Location: Antwerp, Belgium
|
Posted: Thu Mar 27, 2008 6:33 am Post subject: uno dialog in python |
|
|
Hi
I want to import dialogs I created with openoffice into a self-written python macro for openoffice.
I find information on 'DioalogLibraries' and 'createUnodialog' but how should I translate this into python?
thanks
Karen |
|
| Back to top |
|
 |
Villeroy Super User


Joined: 04 Oct 2004 Posts: 10065 Location: Germany
|
|
| Back to top |
|
 |
karenj General User

Joined: 20 Mar 2008 Posts: 9 Location: Antwerp, Belgium
|
Posted: Thu Mar 27, 2008 7:38 am Post subject: |
|
|
| Could you send me a link, example.. on how to write such a wrapper for a self-created dialog? |
|
| Back to top |
|
 |
Villeroy Super User


Joined: 04 Oct 2004 Posts: 10065 Location: Germany
|
Posted: Thu Mar 27, 2008 7:58 am Post subject: |
|
|
There is a wrapper in Basic container "OOo Macros", library "Tools", module "ModuleControls" function "LoadDialog" returning the dialog from which you call method execute(). _________________ Rest in peace, oooforum.org
Get help on http://forum.openoffice.org |
|
| Back to top |
|
 |
Villeroy Super User


Joined: 04 Oct 2004 Posts: 10065 Location: Germany
|
Posted: Thu Mar 27, 2008 11:27 am Post subject: |
|
|
Sorry, just calling a Basic-script to get a Basic dialog seems to work for me but the dialog alone does not suffice. Showing the dialog requires some voodoo I don't have the time to evaluate now.
For now I can call this function, which returns 1 if the dialog has been closed by a button of com.sun.star.awt.PushButtonType.OK, else 0 is returned.
Basic:
| Code: |
Function getDialogResult(sLib$, sDlg$)
oLib = DialogLibraries.getByName(sLib)
d = CreateUnoDialog(oLib.getByName(sDlg))
getDialogResult = d.execute()
End Function
|
Python:
| Code: |
def getBasicDialogResult(sLibName, sDlgName):
sURL = "vnd.sun.star.script:Standard.test_.getDialogResult?language=Basic&location=application"
office = Office()
oMSPF = office.createUnoService("com.sun.star.script.provider.MasterScriptProviderFactory")
oMSP = oMSPF.createScriptProvider('')
oScript = oMSP.getScript(sURL)
tpl = oScript.invoke((sLibName, sDlgName,), (), ())
# returns a tuple where the first element seems to be what we want:
return tpl[0]
|
It would be more valuable to get the dialog itself, so you can manipulate it before showing. _________________ Rest in peace, oooforum.org
Get help on http://forum.openoffice.org |
|
| Back to top |
|
 |
hanya Super User

Joined: 04 May 2005 Posts: 543 Location: Japan
|
|
| Back to top |
|
 |
SergeM Super User

Joined: 09 Sep 2003 Posts: 3211 Location: Troyes France
|
|
| Back to top |
|
 |
Villeroy Super User


Joined: 04 Oct 2004 Posts: 10065 Location: Germany
|
Posted: Thu Mar 27, 2008 12:05 pm Post subject: |
|
|
Oh, so simple indeed?  _________________ Rest in peace, oooforum.org
Get help on http://forum.openoffice.org |
|
| Back to top |
|
 |
karenj General User

Joined: 20 Mar 2008 Posts: 9 Location: Antwerp, Belgium
|
Posted: Sun Mar 30, 2008 11:37 pm Post subject: |
|
|
| Great! This works perfectly for me! |
|
| Back to top |
|
 |
|