OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

uno dialog in python

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
karenj
General User
General User


Joined: 20 Mar 2008
Posts: 9
Location: Antwerp, Belgium

PostPosted: Thu Mar 27, 2008 6:33 am    Post subject: uno dialog in python Reply with quote

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
View user's profile Send private message
Villeroy
Super User
Super User


Joined: 04 Oct 2004
Posts: 10106
Location: Germany

PostPosted: Thu Mar 27, 2008 7:06 am    Post subject: Reply with quote

Write a small wrapper in Basic and call it from Python like this: http://www.oooforum.org/forum/viewtopic.phtml?t=69350
_________________
Rest in peace, oooforum.org
Get help on https://forum.openoffice.org
Back to top
View user's profile Send private message
karenj
General User
General User


Joined: 20 Mar 2008
Posts: 9
Location: Antwerp, Belgium

PostPosted: Thu Mar 27, 2008 7:38 am    Post subject: Reply with quote

Could you send me a link, example.. on how to write such a wrapper for a self-created dialog?
Back to top
View user's profile Send private message
Villeroy
Super User
Super User


Joined: 04 Oct 2004
Posts: 10106
Location: Germany

PostPosted: Thu Mar 27, 2008 7:58 am    Post subject: Reply with quote

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 https://forum.openoffice.org
Back to top
View user's profile Send private message
Villeroy
Super User
Super User


Joined: 04 Oct 2004
Posts: 10106
Location: Germany

PostPosted: Thu Mar 27, 2008 11:27 am    Post subject: Reply with quote

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 https://forum.openoffice.org
Back to top
View user's profile Send private message
hanya
Super User
Super User


Joined: 04 May 2005
Posts: 543
Location: Japan

PostPosted: Thu Mar 27, 2008 12:00 pm    Post subject: Reply with quote

com.sun.star.awt.DialogProvider service makes dialog easily.
http://www.oooforum.org/forum/viewtopic.phtml?p=95708#95708
Back to top
View user's profile Send private message
SergeM
Super User
Super User


Joined: 09 Sep 2003
Posts: 3211
Location: Troyes France

PostPosted: Thu Mar 27, 2008 12:01 pm    Post subject: Reply with quote

Somebody has added in my C++ document, python code concerning dialog : see
http://wiki.services.openoffice.org/wiki/Playing_with_Window_Toolkit_AWT
Perhaps good for a start.
_________________
Linux & Windows OOo3.0
UNO & C++ : WIKI
http://wiki.services.openoffice.org/wiki/Using_Cpp_with_the_OOo_SDK
In French
http://wiki.services.openoffice.org/wiki/Documentation/FR/Cpp_Guide
Back to top
View user's profile Send private message Visit poster's website
Villeroy
Super User
Super User


Joined: 04 Oct 2004
Posts: 10106
Location: Germany

PostPosted: Thu Mar 27, 2008 12:05 pm    Post subject: Reply with quote

hanya wrote:
com.sun.star.awt.DialogProvider service makes dialog easily.
http://www.oooforum.org/forum/viewtopic.phtml?p=95708#95708


Oh, so simple indeed? Embarassed
_________________
Rest in peace, oooforum.org
Get help on https://forum.openoffice.org
Back to top
View user's profile Send private message
karenj
General User
General User


Joined: 20 Mar 2008
Posts: 9
Location: Antwerp, Belgium

PostPosted: Sun Mar 30, 2008 11:37 pm    Post subject: Reply with quote

Great! This works perfectly for me!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group