monoBOT escribió:
Muchas gracias por tu respuesta, pero siento ser tan torpe que no entiendo esto que me dices:

    - En el método __init__ creas objetos pero no guardas las
    referencias y por lo tanto luego no puedes acceder a ellos. La forma
    habitual de hacerlo es crear una propiedad en la instancia que
    guarde la referencia para poder asi utilizarla mas tarde:

       self.entranombre = wx.TextCtrl(ventana, -1, nombre_en_fichero)


Lo he intentado poniendo self.entranombre... pero seguro que hay algo que se me escapa, lo siento no lo entiendo.

te refieres a meter las variables como argumentos en el constructor del dialogo?
como se haría?


Te adjunto un ejemplo funcional de frame para que observes el funcionamiento, de todas formas formas tu fallo no es wx, sino que no pillas el funcionamiento de clases e instancias en python, date un repaso en eso.

Saludos,
--
Oswaldo Hernández
#!/usr/bin/env python
#coding=utf-8

import wx

class mFrame(wx.Frame):
    def __init__(self, parent, id, *args, **kwds):
        wx.Frame.__init__(self, parent, id, *args, **kwds)
        self.SetTitle("Ejemplo")
        
        # Fondo del Frame y Sizer principal
        fondo = wx.Panel(self, -1)                   
        szFondo = wx.BoxSizer(wx.VERTICAL)
        fondo.SetSizer(szFondo)
        
        # Cabecera de Frame
        cabecera = wx.StaticText(fondo, -1, "Formulario de entrada de datos")
        f = cabecera.GetFont()
        f.SetWeight(wx.FONTWEIGHT_BOLD)
        cabecera.SetFont(f)
        szFondo.Add(cabecera, 0, wx.ALL, 3)
        
        # Datos - Sizer
        szData = wx.FlexGridSizer(-1, 2, 3, 3)
        szData.AddGrowableCol(1)
        szFondo.Add(szData, 2, wx.EXPAND|wx.ALL, 3)
        
        # Datos - Controles
        szData.Add(wx.StaticText(fondo, -1, "Nombre:"))
        self.Nombre = wx.TextCtrl(fondo, -1)
        szData.Add(self.Nombre, 0, wx.EXPAND)
        
        szData.Add(wx.StaticText(fondo, -1, "Otros datos:"))
        self.OtrosDatos = wx.TextCtrl(fondo, -1, style=wx.TE_MULTILINE)
        szData.Add(self.OtrosDatos, 2, wx.EXPAND)
        szData.AddGrowableRow(1)

        # Botones - Sizer
        szBtn = wx.BoxSizer(wx.HORIZONTAL)
        szFondo.Add(szBtn, 0, wx.ALIGN_RIGHT)
        
        # Botones - Controles
        BtnAceptar = wx.Button(fondo, -1, "Aceptar")
        szBtn.Add(BtnAceptar, 0, wx.ALL, 3)
        
        BtnCancelar = wx.Button(fondo, -1, "Cancelar")
        szBtn.Add(BtnCancelar, 0, wx.ALL, 3)
        
        # Captura de Eventos
        BtnAceptar.Bind(wx.EVT_BUTTON, self.OnAceptar)
        BtnCancelar.Bind(wx.EVT_BUTTON, self.OnCancelar)
        
        # MinSize y Layout        
        self.SetMinSize(wx.Size(400, 200))
        self.Fit()        
        self.Layout()
        
        
    def OnAceptar(self, evt):
        print "Aceptado"
        print "Nombre:", self.Nombre.GetValue()
        print "Otros Datos:", self.OtrosDatos.GetValue()
        self.Close()
        evt.Skip()
        
    def OnCancelar(self, evt):
        print "Cancelado"
        self.Close()
        evt.Skip()
        
# Test        
if __name__ == "__main__":
    app = wx.PySimpleApp()
    f = mFrame(None, -1)
    f.Show(True)
    app.MainLoop()
    
        
_______________________________________________
Python-es mailing list
Python-es@python.org
http://mail.python.org/mailman/listinfo/python-es
FAQ: http://python-es-faq.wikidot.com/

Responder a