def __init__(self, padre):
     self.padre = padre
     arch = leerglade.leer('frm_depositos_1.glade')
     self.frm = arch.get_object
     self.frm('window1').set_title('Depositos Bancarios')
     self.frm('window1').set_default_size(800, -1)
     self.entity = DepositosBancarios()
     self.cheque_depositos = ChequeDepositosBancarios()
     self.cuentas = CuentasBancarias()
     self.cheques = ChequeTerceros()
     self.frm('window1').set_transient_for(self.padre.main('window1'))
     self.frm('window1').set_position(1)
     self.frm('window1').set_border_width(5)
     self.frm('window1').set_modal(True)
     self.frm('window1').show_all()
     arch.connect_signals(self)
     self.inicializar_campos()
class RegDepositos:
    def __init__(self, padre):
        self.padre = padre
        arch = leerglade.leer('frm_depositos_1.glade')
        self.frm = arch.get_object
        self.frm('window1').set_title('Depositos Bancarios')
        self.frm('window1').set_default_size(800, -1)
        self.entity = DepositosBancarios()
        self.cheque_depositos = ChequeDepositosBancarios()
        self.cuentas = CuentasBancarias()
        self.cheques = ChequeTerceros()
        self.frm('window1').set_transient_for(self.padre.main('window1'))
        self.frm('window1').set_position(1)
        self.frm('window1').set_border_width(5)
        self.frm('window1').set_modal(True)
        self.frm('window1').show_all()
        arch.connect_signals(self)
        self.inicializar_campos()
        #self.frm('window1').maximize()

    def inicializar_campos(self):
        self.frm('entry1').set_text('')
        self.frm('entry2').set_text('')
        self.frm('entry3').set_text('')
        self.frm('entry4').set_text('')
        self.frm('entry5').set_text('')
        self.frm('liststore2').clear()
        self.frm('label9').set_text('0')
        self.frm('entry1').grab_focus()

    def pegar_cuentas(self, widget, event):
        if event.keyval == 65470:
            datos = self.cuentas.cuentas_all_2('')
            busquedas.Buscar(self, datos, widget)

    def pegar_cheques(self, widget, event):
        if event.keyval == 65470:
            datos = self.cheques.list_cheques()
            busquedas.Buscar(self, datos, widget)

    def set_focus(self, widget):
        widget.get_toplevel().child_focus(Gtk.DirectionType.TAB_FORWARD)

    def confirmar_cb(self, widget):
        self.entity.numero = self.frm('entry1').get_text()
        self.entity.fecha = self.frm('entry2').get_text()
        self.entity.efectivo = self.frm('entry4').get_text()
        if len(self.entity.efectivo) == 0:
            self.entity.efectivo = 0
        self.entity.nro_cuenta = self.frm('entry3').get_text().split(':::')[0]
        self.entity.idbanco = self.frm('entry3').get_text().split(':::')[1].split('-')[0]
        self.entity.save()

        for row in self.frm('liststore2'):
            self.cheque_depositos.nro_cheque = row[0].split(':::')[1]
            self.cheque_depositos.nro_cuenta = row[0].split(':::')[2]
            self.cheque_depositos.numero = self.frm('entry1').get_text()

            if self.cheque_depositos.save():
                pass
            else:
                print "error guardando datos de cheques "
                return

        self.inicializar_campos()

    def aceptar_cheque_cb(self, widget):
        if len(self.frm('entry5').get_text()) == 0:
            self.frm('entry5').grab_focus()
            return

        self.append_formas('CHEQUE:::'+
            self.frm('entry5').get_text().split('-')[0],
            self.frm('entry5').get_text().split('-')[1]
        )

    def pegar_fechas(self, widget, icon_pos, event):
        Calendar.Pegar(self.frm('window1'), widget)

    def append_formas(self, forma, monto):
        if len(self.frm('entry4').get_text()) > 0:
            efectivo = float(self.frm('entry4').get_text())
        else:
            efectivo = 0
        total_docs = float(self.frm('label99').get_text().replace(',', ''))
        self.frm('liststore2').append([forma, str(monto)])
        #calculando totales de las formas de pago
        total = 0.0 + efectivo
        for row in self.frm('liststore2'):
            total += float(row[1])

        self.frm('label99').set_text(Format.number(total))



    def cancelar_cb(self, widget):
        self.frm('window1').destroy()