python, glade,postgresql TEXTVIEW

Peon Blanco peonblanco83 en gmail.com
Mie Nov 7 17:37:19 CET 2007


pues gracias por responder pero  a un no a  quedado

es te  es el codigo junto con el error


#!/usr/bin/env python
# -*- coding: UTF8 -*-
# Python module MUSICA.py
# Autogenerated from MUSICA.glade
# Generated on Sun Nov 4 05:50:32 2007
# Warning: Do not delete or modify comments related to context
# They are required to keep user's code

import os, gtk, pg

from SimpleGladeApp import SimpleGladeApp

glade_dir = ""

# Put your modules and data here
# From here through main() codegen inserts/updates a class for
# every top-level widget in the .glade file.

class RELACIONDECANCIONES(SimpleGladeApp):

def __init__(self, glade_path="MUSICA.glade", root="RELACION DE
CANCIONES", domain=None):

glade_path = os.path.join(glade_dir, glade_path)

SimpleGladeApp.__init__(self, glade_path, root, domain)

def new(self):

#context RELACIONDECANCIONES.new {
print "A new RELACIONDECANCIONES has been created"
#context RELACIONDECANCIONES.new }

try:
usu = "postgres"
data = "MUSICA"
conn = pg.connect(dbname=data,user=usu)
self.con = self.textviewcon.get_buffer()
self.con.set_text("LA CONEXION FUE UN EXITO")
except:
self.con = self.textviewcon.get_buffer()
self.con.set_text("*** ERROR EN CONEXION ***")

#context RELACIONDECANCIONES custom methods {
#--- Write your own methods here ---#
#context RELACIONDECANCIONES custom methods }

def on_buttonBUSCAR_clicked(self, widget, *args):

#context RELACIONDECANCIONES.on_buttonBUSCAR_clicked {
print "on_buttonBUSCAR_clicked called with self.%s" % widget.get_name()
#context RELACIONDECANCIONES.on_buttonBUSCAR_clicked }

usu = "postgres"
data = "MUSICA"
conn = pg.connect(dbname=data,user=usu)
bus = self.entrycan.get_text()
con = """SELECT * FROM "MUSICA" WHERE "NOMBRE_DE_LA_BANDA = 's%' """ %bus

re = conn.query(con)
print re   # al  hacer esto si imprime lo que  hay en la base de datos
resu = self.textviewre.get_buffer()
resu.set_text(re)

def on_buttonELIMINAR_clicked(self, widget, *args):
#context RELACIONDECANCIONES.on_buttonELIMINAR_clicked {
print "on_buttonELIMINAR_clicked called with self.%s" % widget.get_name()
#context RELACIONDECANCIONES.on_buttonELIMINAR_clicked }

def main():

r_eLACION_DE_CANCIONES = RELACIONDECANCIONES()

r_eLACION_DE_CANCIONES.run()

if __name__ == "__main__":

main()



 ESTE ES EL ERROR

Traceback (most recent call last):

File "MUSICA.py", line 58, in on_buttonBUSCAR_clicked

resu.set_text(re)

TypeError: GtkTextBuffer.set_text() argument 1 must be string or
read-only buffer, not pgqueryobject

espero y me puedan ayudar
_______________________________________________
Lista de correo Python-es 
http://listas.aditel.org/listinfo/python-es
FAQ: http://listas.aditel.org/faqpyes





Más información sobre la lista de distribución Python-es