🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: es.comp.os.linux.programacion
Article #7931

Re: Diccionario RAE on-line

#7931
From: amphora
Date: Tue, 21 Jan 2003 02:07
76 lines
3807 bytes
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

El Sat, 18 Jan 2003 21:25:32 +0100, Reinoso G. dijo:
>> Ah� va un script para consultar el diccionario de la Real Academia: drae.

No he resistido la tentaci�n de hacerlo en python y gtk:
El programa funciona casi a la perfecci�n, pero me temo que la versi�n
2 de gtk para python no est� todav�a muy pulida (al menos en debian) y
puede que d� un "segmentation fault". Se podr�a hacer una versi�n con
las gtk 1.2 que son mucho m�s estables (si alguien se anima...)

Para que funcione es necesario python-gtk2.

- -----------------------------------------------------
#!/usr/bin/env python
import urllib
import pygtk
pygtk.require('2.0')
import gtk,gtkhtml2

class ntrfz:
	def __init__(self):
		self.win= gtk.Window(gtk.WINDOW_TOPLEVEL)
		self.win.set_default_size(500,200)
		self.vbox = gtk.VBox(spacing=3)
		self.vbox.set_border_width(2)
		self.vbox.show()
		self.entry = gtk.Entry()
		self.vbox.pack_start(self.entry, expand=gtk.FALSE)
		self.button = gtk.Button("Buscar")
		self.vbox.pack_start(self.button,expand=gtk.TRUE)
		self.scrolled=gtk.ScrolledWindow()
		self.html=gtkhtml2.View()
		self.document=gtkhtml2.Document()
		self.scrolled.add(self.html)
		self.vbox.pack_end(self.scrolled,expand=gtk.TRUE)
		self.button.show()
		self.entry.show()
		self.win.add(self.vbox)
		self.win.show_all()
		self.win.connect('delete_event', gtk.mainquit)
		self.button.connect('clicked', self.bpressed)
	def bpressed(self,widget):
		word=self.entry.get_text()
		guest=urllib.urlopen("http://buscon.rae.es/draeI/\
		SrvltGUIBusUsual?TIPO_HTML=2&LEMA=%s&FORMATO=DRAE"%word)
		res=guest.read()
		self.newrequest(res)
		
	def newrequest(self,res):
		self.document.clear()
		self.document.open_stream('text/html')
		self.document.write_stream(res)
		self.document.close_stream()
		self.html.set_document(self.document)

faz=ntrfz()
gtk.mainloop()

- -----------------------------------------------------------

PD:Cuidado con la linea donde se hace la petici�n al servidor que es 
solo una.
- -- 
"La pipa quan �s nova/ te gust de soc,/quan �s a mitg fumar / te gust de
mel,/ i quan es vella,/ t� gust de cel" (Copla an�nima catalana)
amphora at escomposlinux dot org http://julieta.escomposlinux.org

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE+LKtjbxRsnxqoy84RAmqCAJ9CKN83gHkLkwRBJfdlt/NWbe0ZtgCgnqM6
R4tNfd45ByFpGnrr59gcixk=
=oyZA
-----END PGP SIGNATURE-----
Technical Details
Message-ID: <slrnb2paqu.3kf.amphora@hamlet.escomposlinux.org>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!cyclone.bc.net!news-hub.siol.net!fr.clara.net!heighliner.fr.clara.net!213.253.16.105.MISMATCH!mephistopheles.news.clara.net!news.clara.net!diablo.theplanet.net!news-hub.cableinet.net!blueyonder!marmolejo.escomposlinux.org!antonio.escomposlinux.org!julieta.escomposlinux.org!hamlet.escomposlinux.org!news
References: <slrnb2je1r.2k2.reinoso@EA4BAO.PLLANO.ESP.EU>

Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII
X-Google-Thread: f86c8,d6e0e5fad9e0be51
X-Google-Attributes: gidf86c8,public
X-Google-ArrivalTime: 2003-01-20 18:19:42 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!cyclone.bc.net!news-hub.siol.net!fr.clara.net!heighliner.fr.clara.net!213.253.16.105.MISMATCH!mephistopheles.news.clara.net!news.clara.net!diablo.theplanet.net!news-hub.cableinet.net!blueyonder!marmolejo.escomposlinux.org!antonio.escomposlinux.org!julieta.escomposlinux.org!hamlet.escomposlinux.org!news
From: amphora <amphora@hamlet.escomposlinux.org>
Newsgroups: es.comp.os.linux.programacion
Subject: Re: Diccionario RAE on-line
Date: Tue, 21 Jan 2003 03:07:31 +0100
Organization: Ecolnet
Lines: 76
Message-ID: <slrnb2paqu.3kf.amphora@hamlet.escomposlinux.org>
References: <slrnb2je1r.2k2.reinoso@EA4BAO.PLLANO.ESP.EU>
Reply-To: amphora@escomposlinux.org
NNTP-Posting-Host: hamlet.escomposlinux.org
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: julieta.escomposlinux.org 1043115578 20662 192.168.1.16 (21 Jan 2003 02:19:38 GMT)
X-Complaints-To: usenet@julieta.escomposlinux.org
NNTP-Posting-Date: Tue, 21 Jan 2003 02:19:38 +0000 (UTC)
User-Agent: slrn/0.9.7.4 (Linux)