Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

how I update fields ?

2008-05-22
2013-05-01
  • fernando paiva
    fernando paiva
    2008-05-22

    The not dumb form the values, but the function work successfully.

    See my source code:
    # form one
        def OnGridSearchGridCellLeftDclick(self, event):
            """ Function that catches the code of the customer and orders for the form customers """
           
            import Customer
            customer = Customer.DialogCustomer(self)
            row = event.GetRow()
           
            if customer.IsActive():
                _code = self.gridSearch.GetCellValue(row, 0)
                customer.receiveSearch(_code)           
            self.Destroy()

    # form two
        def receiveSearch(self, code):
            """ Function that receive the value of gridSearch and fill the fields of form """
            self.intctrlCode.SetValue(code)
            value = self.intCtrlCode.GetValue()       

            # here I print the value that came of form one
            print value
            try:
                _sql = """
                        SELECT cli_codigo, cli_nome, cli_cnpj FROM cliente WHERE cli_codigo = %s
                       """ % (self.intCtrlCode.GetValue())
                self.cursor.execute(_sql)
                registers = self.cursor.fetchall()        
                for x in registers:
                    self.textCtrlName.SetValue(x["cli_nome"])
                    self.textCtrlCNPJ.SetValue(x["cli_cnpj"])           
            except MySQLdb.Error, e:
                wx.MessageBox("Error %d: %s" %(e.args[0], e.args[1]))         
            finally:
                self.intCtrlCode.Update()
                self.textCtrlName.Update()
                self.TextCtrlCNPJ.Update()

    The function, receiveSearch is executed successfully, but the fields: intCtrlCode and others do not modify the values.

    Any idea ?