Foros del Web » Programando para Internet » Python »

Boton Reset

Estas en el tema de Boton Reset en el foro de Python en Foros del Web. Hola a todos! Como dije en el anterior mensaje que postee soy nueva en python y estoy trabajando con gtk2 para hacer una interfaz gráfica, ...
  #1 (permalink)  
Antiguo 05/11/2011, 12:25
Avatar de PyLau  
Fecha de Ingreso: octubre-2011
Mensajes: 10
Antigüedad: 12 años, 6 meses
Puntos: 1
Boton Reset

Hola a todos!

Como dije en el anterior mensaje que postee soy nueva en python y estoy trabajando con gtk2 para hacer una interfaz gráfica, tengo un formulario sencillo con labels, entry y botones y quisiera saber si hay alguna forma de borrar el texto del entry pulsando un botón.
Algo así como un botón de "Reset" que borre todo lo que hay en todos los entry...
Aquí esta el código si lo necesitan, es súper sencillo lo único que necesito es la función del reset.

Gracias!!!

Código:
#!/usr/bin/env python
#-*- coding: UTF-8 -*-

import pygtk
pygtk.require('2.0')
import gtk

class Formulario:
	
	def __init__(self):
		
		
		window = gtk.Window()
		window.connect('destroy', lambda w: gtk.main_quit())
		window.set_size_request(500,400)
		tablec = gtk.Table(12,9,False)
		

		labeli = gtk.Label("\tArchivo de Configuracion:")
		labeli.show()
		tablec.attach(labeli, 0,9,0,1)		

		labelc11 = gtk.Label("Dominio")
		labelc11.show()
		tablec.attach(labelc11, 0,5,1,2)	
		
		entry = gtk.Entry()
		entry.set_text("dominio")		
		entry.show()		
		tablec.attach(entry, 5,9,1,2)	

		labelc21 = gtk.Label("Usuario")
		labelc21.show()
		tablec.attach(labelc21, 0,5,2,3)	
		
		entryc22 = gtk.Entry()
		entryc22.set_text("pylau")
		entryc22.show()		
		tablec.attach(entryc22, 5,9,2,3)	

		labelc31 = gtk.Label("Directorio")
		labelc31.show()
		tablec.attach(labelc31, 0,5,3,4)	
		
		entryc32 = gtk.Entry()
		entryc32.set_text("pylau")
		entryc32.show()		
		tablec.attach(entryc32, 5,9,3,4)
		
		labelc41 = gtk.Label("Directorio")
		labelc41.show()
		tablec.attach(labelc41, 0,5,4,5)	
		
		entryc42 = gtk.Entry()
		entryc42.set_text("/home/laura/proyectos")
		entryc42.show()		
		tablec.attach(entryc42, 5,9,4,5)
		
		labelc51 = gtk.Label("Nombre")
		labelc51.set_justify(gtk.JUSTIFY_CENTER)
		labelc51.show()
		tablec.attach(labelc51, 0,5,5,6)	
		
		entryc52 = gtk.Entry()
		entryc52.set_text("Laura Estefania Parra Rodriguez")
		entryc52.show()		
		tablec.attach(entryc52, 5,9,5,6)				
		
		labelc61 = gtk.Label("Correo")
		labelc61.show()
		tablec.attach(labelc61, 0,5,6,7)	
		
		entryc62 = gtk.Entry()
		entryc62.set_text("[email protected]")
		entryc62.show()		
		tablec.attach(entryc62, 5,9,6,7)

		labelc71 = gtk.Label("Tu llave pública")
		labelc71.show()
		tablec.attach(labelc71, 0,5,7,8)	
		
		entryc72 = gtk.Entry()
		entryc72.set_text("")
		entryc72.show()		
		tablec.attach(entryc72, 5,9,7,8)
		
		labelc81 = gtk.Label("Lugar1")
		labelc81.show()
		tablec.attach(labelc81, 0,5,8,9)	
		
		entryc82 = gtk.Entry()
		entryc82.set_text("/home/laura/proyectos")
		entryc82.show()		
		tablec.attach(entryc82, 5,9,8,9)
		
		labelc91 = gtk.Label("Lugar2")
		labelc91.show()
		tablec.attach(labelc91, 0,5,9,10)	
		
		entryc92 = gtk.Entry()
		entryc92.set_text("/home/laura/proyectos")
		entryc92.show()		
		tablec.attach(entryc92, 5,9,9,10)

		labelc101 = gtk.Label("Lugar3")
		labelc101.show()
		tablec.attach(labelc101, 0,5,10,11)	
		
		entryc102 = gtk.Entry()
		entryc102.set_text("/home/laura/proyectos")
		entryc102.show()		
		tablec.attach(entryc102, 5,9,10,11)


		buttonc1 = gtk.Button("Reset")
		buttonc1.show()
		tablec.attach(buttonc1, 1,3,11,12)
		
		buttonc2 = gtk.Button("Aplicar")
		buttonc2.show()
		tablec.attach(buttonc2, 5,7,11,12)		

		tablec.show()
		
		window.add(tablec)
		window.show_all()
		
		
def main():
	gtk.main()
	return

if __name__ == "__main__":
    Formulario = Formulario()
    main()
  #2 (permalink)  
Antiguo 05/11/2011, 20:46
Avatar de razpeitia
Moderador
 
Fecha de Ingreso: marzo-2005
Ubicación: Monterrey, México
Mensajes: 7.321
Antigüedad: 19 años, 1 mes
Puntos: 1360
Respuesta: Boton Reset

Código Python:
Ver original
  1. #!/usr/bin/env python
  2. #-*- coding: UTF-8 -*-
  3.  
  4. import pygtk
  5. pygtk.require('2.0')
  6. import gtk
  7.  
  8. class Formulario:
  9.    
  10.     def __init__(self):
  11.        
  12.        
  13.         window = gtk.Window()
  14.         window.connect('destroy', lambda w: gtk.main_quit())
  15.         window.set_size_request(500,400)
  16.         tablec = gtk.Table(12,9,False)
  17.        
  18.  
  19.         labeli = gtk.Label("\tArchivo de Configuracion:")
  20.         labeli.show()
  21.         tablec.attach(labeli, 0,9,0,1)        
  22.  
  23.         labelc11 = gtk.Label("Dominio")
  24.         labelc11.show()
  25.         tablec.attach(labelc11, 0,5,1,2)    
  26.        
  27.         self.entry = gtk.Entry()
  28.         self.entry.set_text("dominio")        
  29.         self.entry.show()        
  30.         tablec.attach(self.entry, 5,9,1,2)    
  31.  
  32.         labelc21 = gtk.Label("Usuario")
  33.         labelc21.show()
  34.         tablec.attach(labelc21, 0,5,2,3)    
  35.        
  36.         self.entryc22 = gtk.Entry()
  37.         self.entryc22.set_text("pylau")
  38.         self.entryc22.show()        
  39.         tablec.attach(self.entryc22, 5,9,2,3)    
  40.  
  41.         labelc31 = gtk.Label("Directorio")
  42.         labelc31.show()
  43.         tablec.attach(labelc31, 0,5,3,4)    
  44.        
  45.         self.entryc32 = gtk.Entry()
  46.         self.entryc32.set_text("pylau")
  47.         self.entryc32.show()        
  48.         tablec.attach(self.entryc32, 5,9,3,4)
  49.        
  50.         labelc41 = gtk.Label("Directorio")
  51.         labelc41.show()
  52.         tablec.attach(labelc41, 0,5,4,5)    
  53.        
  54.         self.entryc42 = gtk.Entry()
  55.         self.entryc42.set_text("/home/laura/proyectos")
  56.         self.entryc42.show()        
  57.         tablec.attach(self.entryc42, 5,9,4,5)
  58.        
  59.         labelc51 = gtk.Label("Nombre")
  60.         labelc51.set_justify(gtk.JUSTIFY_CENTER)
  61.         labelc51.show()
  62.         tablec.attach(labelc51, 0,5,5,6)    
  63.        
  64.         self.entryc52 = gtk.Entry()
  65.         self.entryc52.set_text("Laura Estefania Parra Rodriguez")
  66.         self.entryc52.show()        
  67.         tablec.attach(self.entryc52, 5,9,5,6)                
  68.        
  69.         labelc61 = gtk.Label("Correo")
  70.         labelc61.show()
  71.         tablec.attach(labelc61, 0,5,6,7)    
  72.        
  73.         self.entryc62 = gtk.Entry()
  74.         self.entryc62.set_text("[email protected]")
  75.         self.entryc62.show()        
  76.         tablec.attach(self.entryc62, 5,9,6,7)
  77.  
  78.         labelc71 = gtk.Label("Tu llave pública")
  79.         labelc71.show()
  80.         tablec.attach(labelc71, 0,5,7,8)    
  81.        
  82.         self.entryc72 = gtk.Entry()
  83.         self.entryc72.set_text("")
  84.         self.entryc72.show()        
  85.         tablec.attach(self.entryc72, 5,9,7,8)
  86.        
  87.         labelc81 = gtk.Label("Lugar1")
  88.         labelc81.show()
  89.         tablec.attach(labelc81, 0,5,8,9)    
  90.        
  91.         self.entryc82 = gtk.Entry()
  92.         self.entryc82.set_text("/home/laura/proyectos")
  93.         self.entryc82.show()        
  94.         tablec.attach(self.entryc82, 5,9,8,9)
  95.        
  96.         labelc91 = gtk.Label("Lugar2")
  97.         labelc91.show()
  98.         tablec.attach(labelc91, 0,5,9,10)    
  99.        
  100.         self.entryc92 = gtk.Entry()
  101.         self.entryc92.set_text("/home/laura/proyectos")
  102.         self.entryc92.show()        
  103.         tablec.attach(self.entryc92, 5,9,9,10)
  104.  
  105.         labelc101 = gtk.Label("Lugar3")
  106.         labelc101.show()
  107.         tablec.attach(labelc101, 0,5,10,11)    
  108.        
  109.         self.entryc102 = gtk.Entry()
  110.         self.entryc102.set_text("/home/laura/proyectos")
  111.         self.entryc102.show()        
  112.         tablec.attach(self.entryc102, 5,9,10,11)
  113.  
  114.  
  115.         buttonc1 = gtk.Button("Reset")
  116.         buttonc1.show()
  117.         tablec.attach(buttonc1, 1,3,11,12)
  118.         buttonc1.connect("clicked", self.onReset)
  119.        
  120.         buttonc2 = gtk.Button("Aplicar")
  121.         buttonc2.show()
  122.         tablec.attach(buttonc2, 5,7,11,12)        
  123.  
  124.         tablec.show()
  125.        
  126.         window.add(tablec)
  127.         window.show_all()
  128.        
  129.     def onReset(self, event):
  130.         self.entry.set_text("")
  131.         self.entryc102.set_text("")
  132.         self.entryc22.set_text("")
  133.         self.entryc32.set_text("")
  134.         self.entryc42.set_text("")
  135.         self.entryc52.set_text("")
  136.         self.entryc62.set_text("")
  137.         self.entryc72.set_text("")
  138.         self.entryc82.set_text("")
  139.         self.entryc92.set_text("")
  140.        
  141.        
  142. def main():
  143.     gtk.main()
  144.     return
  145.  
  146. if __name__ == "__main__":
  147.     Formulario = Formulario()
  148.     main()
Suena algo tedioso pero tienes que borrar todos los campos que quieras manualmente.

Etiquetas: reset, botones, formulario
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 22:06.