| View previous topic :: View next topic |
| Author |
Message |
Guest
|
Posted: Mon Jan 05, 2004 7:26 am Post subject: Python and OOo: do you have some links? |
|
|
Hi all,
I've been using OOo in some small Visual Basic programs.
Lately however, I'm wondering if VB is the language to use:
* VB6 is the last 'real' VB, VB.NET is just C# with a different look.
* VB is platform specific.
* VB is not open source.
* VB is sometimes just s**t. You really have to work around the problems of VB.
Python however seems to solve all these objections!
Now, I'm not a Python guru (yet! ), so do you have any clues on how to work with OOo in it?
I hear about the Python UNO bridge, but completely don't understand what it is and how it works.
Is Python in OOo already finished, mature?
So basically, if you could give me some pointers to start, I would be very grateful.
Greets,
Chris
BTW: does anybody have any clue on how to compare documents in a program?
see also http://www.oooforum.org/forum/viewtopic.php?t=2853 |
|
| Back to top |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 3991 Location: Lawrence, Kansas, USA
|
Posted: Mon Jan 05, 2004 8:34 am Post subject: |
|
|
I had been meaning to learn Python for a couple years. It was OOo that finally pushed me to expend the effort.
I have done a limited amount of coding in Python, and most of it for OOo. I have ended up spending far more time in OOo Basic than I would like. Several reasons. Basic is easily accessible, and seems to be best for giving OOo examples.
Everyone who has OOo 1.1 has the option to install an integrated Python implementation.
Python code can be run in two forms.
1. External to OOo.
2. Installed as a component.
Number 2 means you could write a true component, with new Services that are part of the office. You would of course, have to install them with pkgchk. But I'm working on that. I'm thinking it may be possible to install a Python component into the office from a Basic macro document -- no pkgchk.
Number 1 means that you have to configure OOo to listen for Uno connections. I have a macro document that trivially accomplishes this configuration step. It used to be a major pain to hand edit an XCU file. The macro document is available at OOoMacros.org. I think it is called UnoConnectionListener. You open it, and can configure OOo to listen for a connection on any TCP/IP port, such as port 8100.
Then your python or java program, even from a different computer, can connect to your computer on port 8100 and drive the OOo to do things. (I have done the different computer / different OS thing to OOo from Java, but not from python.)
If you jump through some hoops, you can even use Python with IDLE, I've done it. IDLE is a GUI IDE for doing python development. Using IDLE makes python development much easier. Using this, you get a level of interactivity that niether Basic nor Java offers. You can create OOo objects from the command line. You could do something like....
| Code: | oDrawDoc = oDesktop.loadComponentFromURL( "private:factory/sdraw", "_blank", 0, (,) )
|
from IDLE's interactive command shell, and up pops a new draw document. (You must have the Desktop object in oDesktop first.) But then, interactively you could do things, like put a rectangle onto the drawing....
| Code: | oShape = oDrawDoc.createInstance( "com.sun.star.drawing.RectangleShape" )
oDrawDoc.add( oShape )
oShape.Position = MakePoint( 3000, 4000 )
oShape.Size = MakeSize( 4000, 5000 )
oShape.FillColor = 0
|
As you type in each of the above lines, you would see its effect immediately and instantly reflected in the drawing document window.
In some of my old messages posted here I have described how to get Python with IDLE running on Windows. Since then I've also done it on Linux.
As for Python language issues, the biggest one I can think of is how sequences in UNO are mapped to tupples in Python. Understand how to use tupples.
Right now, I'm going to dig around in some of my old postings to find some useful information. _________________ Want to make OOo Drawings like the colored flower design to the left? |
|
| Back to top |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 3991 Location: Lawrence, Kansas, USA
|
|
| Back to top |
|
 |
Chris_147 General User

Joined: 28 Aug 2003 Posts: 27
|
Posted: Tue Jan 06, 2004 1:56 am Post subject: |
|
|
DannyB,
again you come with some good answers.
Thanks.
I'll try them.
Installing Python is no problem. Just the interaction with OOo.
As I see it I can use it like with VB (number 1: external in your post) Only Python allows to do it also from the commandline...
Number 2 (component) in your post is extra, but is more difficult I understood.
Well, thanks anyway. Now finding the time to learn Python
Chris |
|
| Back to top |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 3991 Location: Lawrence, Kansas, USA
|
Posted: Tue Jan 06, 2004 10:24 am Post subject: |
|
|
| Chris_147 wrote: | | Installing Python is no problem. Just the interaction with OOo. |
You must use the Python that comes with OOo. I will explain all this in my guide.
If installing OOo for first time, pick Custom installation, and make sure Python-UNO bridge is installed.
If OOo is already installed, then quit OOo, run Setup, and pick Modify, then make sure Python-UNO bridge is selected.
Everyone who has OOo 1.1 can install OOo's custom-compiled Python this easily. (Custom compiled because OOo uses a different StdCLib from the commonly available precompiled python distributions.) _________________ Want to make OOo Drawings like the colored flower design to the left? |
|
| Back to top |
|
 |
nom OOo Enthusiast

Joined: 17 Dec 2003 Posts: 153 Location: NSW, Australia
|
Posted: Tue Jan 06, 2004 6:13 pm Post subject: |
|
|
Danny,
Thanks a lot! Can't wait to get my hands on your documentation... I tried getting python to work with OOo a few months back and never had any success.
Cheers,
Nom |
|
| Back to top |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 3991 Location: Lawrence, Kansas, USA
|
|
| Back to top |
|
 |
|
|
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
|