[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [libreoffice-users] Calling a libreoffice basic function from a python script
- Subject: Re: [libreoffice-users] Calling a libreoffice basic function from a python script
- From: Mauricio Baeza <firstname.lastname@example.org>
- Date: Sun, 17 May 2020 23:10:37 -0500
- To: email@example.com
On Sat, 2020-05-16 at 20:26 -0500, Jim wrote:
> I started experimenting with calling a basic function from a python
> script. I was surprised that without to much trouble I got it to work
> a certain extent.
> I am working on linux Mint.
> I started with a basic Sub I found. In it's original form it had 3
> values hard coded and it popped up a message box that displayed the
> color value from the rgb input. I rewrote it as a Function that took
> rgb values as parameters.
> Here is the basic:
> Function ColorExampleFunc(r as long, g as long, b as long)
> Dim lVar As Long
> lVar = rgb(207,231,245)
> msgbox "The color " & lVar & " consists of:" & Chr(13) &_
> "red= " & red(lVar) & Chr(13)&_
> "green= " & green(lVar) & Chr(13)&_
> "blue= " & blue(lVar) & Chr(13) , 64,"colors"
> end function
> Here is the python:
> import os
> result = os.system('soffice
> This works as it will pop up the message box with the color value
> displayed. What I need to do is capture that color value (which is
> usually an eight digit number) in variable in the python script.
> I printed result and it was equal to 0.
> It's been a long time since I did anything in basic. I imagine I
> have to get rid of the msgbox code and set the rgb values equal to a
> variable and then return them, but I'm not sure how to do it.
> Does anyone know how to get the color value in the python script?
> Thanks, Jim
You need used MasterScriptProviderFactory
Change the original Basic function to:
Function ColorExampleFunc(r As Integer, g As Integer, b As Integer) As
ColorExampleFunc = RGB(r, g, b)
Then you can call, look my example:
To unsubscribe e-mail to: firstname.lastname@example.org
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.libreoffice.org/global/users/
|[libreoffice-users] Re: Calling a libreoffice basic function from a python script||Jim <email@example.com>|
|[libreoffice-users] Calling a libreoffice basic function from a python script||Jim <firstname.lastname@example.org>|
- Prev by Date: Re: [libreoffice-users] Re: IF problem
- Next by Date: [libreoffice-users] Re: Calling a libreoffice basic function from a python script
- Previous by thread: [libreoffice-users] Re: Calling a libreoffice basic function from a python script
- Next by thread: [libreoffice-users] Re: Calling a libreoffice basic function from a python script