3 messages in org.openoffice.fr.progRe: [prog] un HelloWorld en python ?
FromSent OnAttachments
Axel RousseauMar 12, 2007 8:54 am 
Laurent GodardMar 12, 2007 9:10 am 
Bernard MarcellyMar 12, 2007 10:21 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: [prog] un HelloWorld en python ?Actions...
From:Bernard Marcelly (marc@club-internet.fr)
Date:Mar 12, 2007 10:21:05 am
List:org.openoffice.fr.prog

Message de Axel Rousseau date 2007-03-12 16:54 :

Bonjour, J'essaye de faire ma premiere macro en python, mais je suis un peu bloqué. J'ai créé un fichier dans le repertoire utilisateur (Application Data\OpenOffice.org2\user\Scripts\python) et ce fichier contient une méthode assez simple : def HelloWorldPython( ): """Prints the string 'Hello World(in Python)' into the current document""" #get the doc from the scripting context which is made available to all scripts model = XSCRIPTCONTEXT.getDocument() text = model.Text cursor = text.createTextCursor() text.insertString( cursor, "Hello World(in Python)", 0 )

Mais quand je vais dans "gérer les macros", je vois bien mon fichier, mais je ne vois pas en dessous ma méthode. Faut il déclarer les méthodes quelques parts ? y'a t'il certaines régles à suivre ?

Bonsoir, Oui, il y a des règles. Pas vraiment bien documentées. D'abord utiliser un éditeur de texte qui crée des fins de lignes à la Unix, pas à la Windows. Ensuite, s'il y a une erreur de compilation, on ne voit pas les noms de fonctions (et on ne voit pas d'erreur !).

Pour plus d'information, doc officielle: <http://udk.openoffice.org/python/scriptingframework/index.html>

Sur le wiki on peut trouver des choses : <http://wiki.services.openoffice.org/wiki/Python>

Bon courage Bernard