Search code examples
python-3.xwxpython

Acess Attributes from WX Forms


Given the following code Gist

I'm trying to use attributes from my parent class , but i can't access then.

    src = BluTools.sourceFile.GetValue()
    dest = BluTools.destFile.GetValue()
    codigo_empresa = BluTools.codigo_empresa.GetValue()
    codigo_deposito = BluTools.codigo_deposito.GetValue()
    data = BluTools.data_inicio.GetValue()

But give-me error :

    AttributeError: 'BluTools' object has no attribute 'sourceFile'

Solution

  • You need to read up on how classes work in Python. You do not normally access attributes by calling the class directly. You need to either create an instance of the class:

    blue = BluTools()
    blue.some_attr()
    

    Or in your case, use self instead of BluTools

    src = self.sourceFile.GetValue()
    dest = self.destFile.GetValue()
    codigo_empresa = self.codigo_empresa.GetValue()
    codigo_deposito = self.codigo_deposito.GetValue()
    data = self.data_inicio.GetValue()