[Fwd: Problems with PyGridTableBase]

Eric_Dexter at msn.com Eric_Dexter at msn.com
Sun Sep 10 22:41:07 CEST 2006


Hopefully this helps keep your post alive..  I looked all over the
internet for examples written with wxgrid and wxgrid with python and
haven't realy found out how to add the other functions to a
boa-constructor program there just isn't anything except the simple
example incuded with boa.  This is as far as I got and I am not sure I
am very close (with my example trying to add the extra functions to the
class instead of inheriting it from grid)

#Boa:Frame:Frame3

import wx
import wx.grid

def create(parent):
    return Frame3(parent)

[wxID_FRAME3, wxID_FRAME3BUTTON1, wxID_FRAME3GRID1,
wxID_FRAME3TEXTCTRL1,
] = [wx.NewId() for _init_ctrls in range(4)]

class Frame3(wx.Frame):
    def _init_ctrls(self, prnt):
        # generated method, don't edit
        wx.Frame.__init__(self, id=wxID_FRAME3, name='', parent=prnt,
              pos=wx.Point(401, 118), size=wx.Size(367, 585),
              style=wx.DOUBLE_BORDER, title=u'')
        self.SetClientSize(wx.Size(361, 579))

        self.grid1 = wx.grid.Grid(id=wxID_FRAME3GRID1, name='grid1',
              parent=self, pos=wx.Point(8, 16), size=wx.Size(80, 392),
              style=wx.WANTS_CHARS | wx.TRANSPARENT_WINDOW |
wx.MINIMIZE_BOX | wx.DOUBLE_BORDER | wx.VSCROLL)

        self.textCtrl1 = wx.TextCtrl(id=wxID_FRAME3TEXTCTRL1,
name='textCtrl1',
              parent=self, pos=wx.Point(112, 16), size=wx.Size(232,
392),
              style=wx.TE_LINEWRAP, value=u'')
        self.textCtrl1.SetThemeEnabled(False)
        self.textCtrl1.SetCursor(wx.CROSS_CURSOR)

        self.button1 = wx.Button(id=wxID_FRAME3BUTTON1, label=u'exit',
              name='button1', parent=self, pos=wx.Point(72, 440),
              size=wx.Size(136, 23), style=0)
        self.button1.Bind(wx.EVT_BUTTON, self.OnButton1Button,
              id=wxID_FRAME3BUTTON1)

    def __init__(self, parent):
        self._init_ctrls(parent)
        self.grid1.CreateGrid(0, 1)

    def OnButton1Button(self, event):
        self.Close()
    def update_instument_list(csndname):
        csdInstrumentList(csndname) #needs to have a file variable..
        noinlist=0
        for number in range(0,noinlist):
             self.grid1.AppendRows(1)
             self.grid1.SetCellValue(number,0,instrlist[number])

http://www.dexrow.com



Mario Lacunza wrote:
> --------- Mensaje reenviado --------
> De: Mario Lacunza <mario.lacunza at gmail.com>
> Para: Lista Python Ing <python-list at python.org>
> Asunto: Problems with PyGridTableBase
> Fecha: Sat, 09 Sep 2006 00:03:20 -0500
>
> Hello,
>
> I attach two files:frmClientes and frmClientesNE.
>
> frmClientes charge a Grid with resume Costumers data: Name, Commercial
> ID, address, etc. and edition options.
>
> frmClientes in
>
> Line 178
> def OnBtnNuevoButton(self, event):
>
> call to frmClientesNE. Its append a new record to the database and clear
> all controls and when I close it, the grid in frmClientes: grClte must
> be recharge with the new data, but that dont work. Only work when a
> Delete some record.
>
> I couldnt send yours a runable .py version, because both of them files
> pickup data from a Firebird's database.
>
> I try to implement the wxPython Demo model: Grid_MegaExample, follow
> that my class Grilla must be:
>
> Line 224:
> class Grilla(Grid.Grid):
>
> but for the Boa Constructors controls creation I couldnt inherit from
> Grid.Grid, thats my problem, I need your help I try for two days and
> nothing :-( ... some ideas??
>
> Thanks in advance!!
>
> ======================================================================
> FILE: FRMCLIENTES.PY
> ======================================================================
>
> # -*- coding: utf8 -*-#
> #Boa:Frame:frmClientes
>
> __version__='0.5'
> __autor__='Mario Lacunza Vasquez <mlacunza at gmail.com>'
>
> import wx
> import wx.grid
> import modGlobals
> from Conectar import Conectar
> import errores
>
> def create(parent):
>     return frmClientes(parent)
>
> [wxID_FRMCLIENTES, wxID_FRMCLIENTESBRNSALIR, wxID_FRMCLIENTESBTNBORRAR,
>  wxID_FRMCLIENTESBTNEDIT, wxID_FRMCLIENTESBTNNUEVO,
> wxID_FRMCLIENTESGRCLTE,
>  wxID_FRMCLIENTESLBLTITULO, wxID_FRMCLIENTESPANEL1,
> ] = [wx.NewId() for _init_ctrls in range(8)]
>
> class frmClientes(wx.Frame):
>     def _init_coll_fsGrid_Growables(self, parent):
>         # generated method, don't edit
>
>         parent.AddGrowableRow(0)
>
>     def _init_coll_fsGrid_Items(self, parent):
>         # generated method, don't edit
>
>         parent.AddWindow(self.grClte, 0, border=2, flag=wx.EXPAND |
> wx.ALL)
>
>     def _init_coll_fsBtn_Items(self, parent):
>         # generated method, don't edit
>
>         parent.AddWindow(self.btnNuevo, 0, border=2, flag=wx.EXPAND |
> wx.ALL)
>         parent.AddWindow(self.btnEdit, 0, border=2, flag=wx.EXPAND |
> wx.ALL)
>         parent.AddWindow(self.btnBorrar, 0, border=2, flag=wx.EXPAND |
> wx.ALL)
>         parent.AddWindow(self.brnSalir, 0, border=2, flag=wx.EXPAND |
> wx.ALL)
>
>     def _init_coll_fsTit_Items(self, parent):
>         # generated method, don't edit
>
>         parent.AddWindow(self.lblTitulo, 0, border=6, flag=wx.EXPAND)
>
>     def _init_coll_bsClte_Items(self, parent):
>         # generated method, don't edit
>
>         parent.AddWindow(self.panel1, 1, border=0, flag=wx.EXPAND)
>
>     def _init_coll_fsTit_Growables(self, parent):
>         # generated method, don't edit
>
>         parent.AddGrowableRow(0)
>
>     def _init_coll_fsClte_Growables(self, parent):
>         # generated method, don't edit
>
>         parent.AddGrowableRow(0)
>         parent.AddGrowableRow(1)
>         parent.AddGrowableRow(2)
>         parent.AddGrowableCol(0)
>
>     def _init_coll_fsClte_Items(self, parent):
>         # generated method, don't edit
>
>         parent.AddSizer(self.fsTit, 1, border=5,
>               flag=wx.ALIGN_CENTER_HORIZONTAL)
>         parent.AddSizer(self.fsGrid, 1, border=10,
>               flag=wx.ALIGN_CENTER_HORIZONTAL)
>         parent.AddSizer(self.fsBtn, 1, border=5,
>               flag=wx.ALIGN_CENTER_HORIZONTAL)
>
>     def _init_sizers(self):
>         # generated method, don't edit
>         self.bsClte = wx.BoxSizer(orient=wx.VERTICAL)
>
>         self.fsClte = wx.FlexGridSizer(cols=1, hgap=0, rows=0, vgap=0)
>
>         self.fsTit = wx.FlexGridSizer(cols=1, hgap=0, rows=0, vgap=0)
>
>         self.fsGrid = wx.FlexGridSizer(cols=1, hgap=5, rows=0, vgap=5)
>
>         self.fsBtn = wx.FlexGridSizer(cols=4, hgap=0, rows=0, vgap=0)
>
>         self._init_coll_bsClte_Items(self.bsClte)
>         self._init_coll_fsClte_Growables(self.fsClte)
>         self._init_coll_fsClte_Items(self.fsClte)
>         self._init_coll_fsTit_Growables(self.fsTit)
>         self._init_coll_fsTit_Items(self.fsTit)
>         self._init_coll_fsGrid_Growables(self.fsGrid)
>         self._init_coll_fsGrid_Items(self.fsGrid)
>         self._init_coll_fsBtn_Items(self.fsBtn)
>
>         self.SetSizer(self.bsClte)
>         self.panel1.SetSizer(self.fsClte)
>
>     def _init_ctrls(self, prnt):
>         # generated method, don't edit
>         wx.Frame.__init__(self, id=wxID_FRMCLIENTES,
> name=u'frmClientes',
>               parent=prnt, pos=wx.Point(352, 148), size=wx.Size(589,
> 514),
>               style=wx.DEFAULT_FRAME_STYLE, title=u'Clientes')
>         self.SetClientSize(wx.Size(589, 514))
>
>         self.panel1 = wx.Panel(id=wxID_FRMCLIENTESPANEL1, name='panel1',
>               parent=self, pos=wx.Point(0, 0), size=wx.Size(589, 514),
>               style=wx.TAB_TRAVERSAL)
>
>         self.lblTitulo = wx.StaticText(id=wxID_FRMCLIENTESLBLTITULO,
> label=u'',
>               name=u'lblTitulo', parent=self.panel1, pos=wx.Point(258,
> 0),
>               size=wx.Size(72, 19), style=0)
>         self.lblTitulo.Center(wx.HORIZONTAL)
>         self.lblTitulo.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD,
> False,
>               u'Sans'))
>
>         self.grClte = wx.grid.Grid(id=wxID_FRMCLIENTESGRCLTE,
> name=u'grClte',
>               parent=self.panel1, pos=wx.Point(10, 63),
> size=wx.Size(568, 326),
>               style=0)
>         self.grClte.EnableEditing(False)
>         self.grClte.Bind(wx.grid.EVT_GRID_SELECT_CELL,
>               self.OnGrClteGridSelectCell)
>
>         self.btnNuevo = wx.Button(id=wxID_FRMCLIENTESBTNNUEVO,
> label=u'Nuevo',
>               name=u'btnNuevo', parent=self.panel1, pos=wx.Point(118,
> 435),
>               size=wx.Size(85, 34), style=0)
>         self.btnNuevo.SetToolTipString(u'Nuevo Cliente')
>         self.btnNuevo.Bind(wx.EVT_BUTTON, self.OnBtnNuevoButton,
>               id=wxID_FRMCLIENTESBTNNUEVO)
>
>         self.btnEdit = wx.Button(id=wxID_FRMCLIENTESBTNEDIT,
> label=u'Editar',
>               name=u'btnEdit', parent=self.panel1, pos=wx.Point(207,
> 435),
>               size=wx.Size(85, 34), style=0)
>         self.btnEdit.SetToolTipString(u'Editar Cliente')
>         self.btnEdit.Bind(wx.EVT_BUTTON, self.OnBtnEditButton,
>               id=wxID_FRMCLIENTESBTNEDIT)
>
>         self.btnBorrar = wx.Button(id=wxID_FRMCLIENTESBTNBORRAR,
>               label=u'Eliminar', name=u'btnBorrar', parent=self.panel1,
>               pos=wx.Point(296, 435), size=wx.Size(85, 34), style=0)
>         self.btnBorrar.SetToolTipString(u'Eliminar Cliente')
>         self.btnBorrar.Bind(wx.EVT_BUTTON, self.OnBtnBorrarButton,
>               id=wxID_FRMCLIENTESBTNBORRAR)
>
>         self.brnSalir = wx.Button(id=wxID_FRMCLIENTESBRNSALIR,
> label=u'Salir',
>               name=u'brnSalir', parent=self.panel1, pos=wx.Point(385,
> 435),
>               size=wx.Size(85, 34), style=0)
>         self.brnSalir.SetToolTipString(u'Salir')
>         self.brnSalir.Bind(wx.EVT_BUTTON, self.OnBrnSalirButton,
>               id=wxID_FRMCLIENTESBRNSALIR)
>
>         self._init_sizers()
>
>     def __init__(self, parent):
>         self._init_ctrls(parent)
>
>         self.CrearGrid()
>
> #-------------------------------------------------------------------------------
>     def CrearGrid(self):
>         #Setea la Tabla para el Grid
>         self.table = Tabla()
>         self.grClte.SetTable(self.table, True)
>
>         #Setea el ancho de las columnas del Grid
>         self.grClte.SetColSize(0,50)
>         self.grClte.SetColSize(2,150)
>         self.grClte.SetColSize(4,250)
>
> #-------------------------------------------------------------------------------
>
>     def OnBtnNuevoButton(self, event):
>         #Nuevo
>         import frmClientesNE
>         x=frmClientesNE.create(None,"N")
>         x.Show()
>
>     def OnBtnEditButton(self, event):
>         #Editar
>         import frmClientesNE
>         x=frmClientesNE.create(None,"E",self.Valor)
>         x.Show()
>
>     def OnBtnBorrarButton(self, event):
>         self.oD=D_Cltes()
>
>         dlg=wx.MessageDialog(self,u'¿Está seguro de eliminar este
> Cliente?', \
>         'PymeGestor',wx.YES_NO | wx.ICON_QUESTION)
>         rpta=dlg.ShowModal()
>         if (rpta==wx.ID_YES):
>             self.oD.Borrar(self.Valor)
>             dlg2=wx.MessageDialog(self,u'El Cliente fue el eliminado con
> éxito.', \
>             'PymeGestor',wx.OK | wx.ICON_INFORMATION)
>             dlg2.ShowModal()
>             dlg2.Destroy()
>         else:
>             pass
>
>         dlg.Destroy()
>
>     def OnBrnSalirButton(self, event):
>         self.Close(True)
>
>     def OnGrClteGridSelectCell(self, event):
>         #Obtiene el valor de la celda seleccionada.
>         self.R=event.GetRow()
>         #Fija como 0 la celda q contiene el campo ID.
>         self.C = 0
>
>         self.Valor=self.table.GetValue(self.R,self.C)
>
>         event.Skip()
>
>
> #-------------------------------------------------------------------------------
> #-------------------------------------------------------------------------------
> class Tabla(wx.grid.PyGridTableBase):
>     """Clase que maneja la grilla de Datos."""
>
>     def __init__(self):
>         wx.grid.PyGridTableBase.__init__(self)
>
>         self.oCltes=D_Cltes()
>         self.data=self.oCltes.CargarClientes()
>
>         #Setea el Numero de Columnas a mostrar por el SQL
>         self.Columnas=7
>
>         #Setea los titulos del Grid
>         self.colLabels = ["ID", "CODIGO", "CLIENTE", "NRO.DOC.",
> "DIRECCION", "TELEFONO","EMAIL"]
>
>     def GetNumberRows(self):
>         r=len(self.data)
>         return r
>
>     def GetNumberCols(self):
>         return self.Columnas
>
>     def IsEmptyCell(self, row, col):
>         return False
>
>     def GetValue(self, row, col):
>         #Muestra los datos devueltos por el Recordset
>         value=self.data[row][col]
>         if value is not None:
>             return value
>         else:
>             return ''
>
>     def SetValue(self, row, col, value):
>         try:
>             self.data[row][col] = value
>         except IndexError:
>             # add a new row
>             self.data.append([''] * self.GetNumberCols())
>             self.SetValue(row, col, value)
>             # tell the grid we've added a row
>             msg = wxGridTableMessage(self,            # The table
>                     wxGRIDTABLE_NOTIFY_ROWS_APPENDED, # what we did to
> it
>                     1                                       # how many
>                     )
>             self.GetView().ProcessTableMessage(msg)
>
>     def GetColLabelValue(self, col):
>         return self.colLabels[col]
>
> #-------------------------------------------------------------------------------
> #-------------------------------------------------------------------------------
>
> class O_Cltes:
>     """Clase de Negocios para el manejo de los Clientes."""
>     def __init__(self):
>         """ Constructor."""
>
>
> #-------------------------------------------------------------------------------
> #-------------------------------------------------------------------------------
>
> class D_Cltes:
>     """Maneja las operaciones con clientes."""
>
>     mCodigo=None
>     mNombre=None
>     mTipoDoc=None
>     mNumDoc=None
>     mDireccion=None
>     mPostal=None
>     mFono1=None
>     mFono2=None
>     mFax=None
>     mEmail=None
>     mCelular=None
>     mWeb=None
>     mLinCredito=None
>
>     def __init__(self):
>         """ Constructor."""
>
>         #Instancia la Clase
>         self.cnn=Conectar()
>
>         #Obtiene cadena de Conexion
>         self.cnn.__class__.cnn=modGlobals.CNN
>
> #-------------------------------------------------------------------------------
>
>     def CargarClientes(self):
>         """Genera lista de Clientes."""
>
>         sql="Select ID, Codigo, Nombre, NumDoc, Direccion, Fono1, Email
> from tblClientes"
>         self.cnn.__class__.SQL=sql
>
>         try:
>             rs=self.cnn.EjecutarSQL()
>             return rs
>
>         except errores.ConexionError, err:
>             print "Error:",err.mensaje
>         except errores.ConexionEjecucionError, err:
>             print "Error:",err.msgEjec
> #-------------------------------------------------------------------------------
>     def Borrar(self, mCod):
>         """Borra Cliente de la Bd."""
>
>         sql="Delete from tblClientes Where ID=%d"%(mCod)
>         self.cnn.__class__.SQL=sql
>
>         try:
>             rs=self.cnn.EjecutarSQL('Delete')
>             return True
>
>         except errores.ConexionError, err:
>             print "Error:",err.mensaje
>         except errores.ConexionEjecucionError, err:
>             print "Error:",err.msgEjec
> #-------------------------------------------------------------------------------
>
>     def CargaTDoc(self):
>
>         sql="Select ID, Detalle from tblTipoDoc"
>         self.cnn.__class__.SQL=sql
>
>         try:
>             rs=self.cnn.EjecutarSQL()
>             return rs
>
>         except errores.ConexionError, err:
>             print "Error:",err.mensaje
>         except errores.ConexionEjecucionError, err:
>             print "Error:",err.msgEjec
>
> #-------------------------------------------------------------------------------
>
>     def Graba(self):
>         """Graba los datos."""
>
>         #Obtiene el codigo
>         self.__class__.mCodigo=self.GeneraCod()
>
>         sql="Insert into tblClientes(ID, CODIGO, NOMBRE, TIPODOC,
> NUMDOC, DIRECCION, POSTAL,\
>         FONO1,FONO2,FAX, EMAIL, CELULAR, WEB, LINCREDITO)\
>         VALUES(GEN_ID(GEN_TBLCLIENTES_ID,1),\
>         '%s', '%s', %d, '%s', '%s','%s','%s','%s','%s','%s','%s','%s',%
> d)"\
>         %(self.__class__.mCodigo, self.__class__.mNombre,
> self.__class__.mTipoDoc, self.__class__.mNumDoc,\
>         self.__class__.mDireccion, self.__class__.mPostal,
> self.__class__.mFono1,\
>         self.__class__.mFono2, self.__class__.mFax,
> self.__class__.mEmail,\
>         self.__class__.mCelular, self.__class__.mWeb,
> self.__class__.mLinCredito)
>
>         self.cnn.__class__.SQL=sql
>
>         try:
>             rs=self.cnn.EjecutarSQL('Insert')
>             if rs==False:
>                 return False
>             else:
>                 return True
>
>         except errores.ConexionError, err:
>             print "Error:",err.mensaje
>         except errores.ConexionEjecucionError, err:
>             print "Error:",err.msgEjec
>
>         self.CargarClientes()
> #-------------------------------------------------------------------------------
>
>     def GeneraCod(self):
>         """Genera el Codigo Unico para este cliente."""
>
>         sql="Select MAX(Codigo) from tblClientes"
>         self.cnn.__class__.SQL=sql
>
>         try:
>             rs=self.cnn.EjecutarSQL()
>         except errores.ConexionError, err:
>             print "Error:",err.mensaje
>         except errores.ConexionEjecucionError, err:
>             print "Error:",err.msgEjec
>
>         #Si es el primer registro en la Tabla
>         if rs[0][0]==None:
>             cod=modGlobals.CrearCodigo('', 'C',9)
>         else:
>             cod=modGlobals.CrearCodigo(rs[0][0],'C', 9)
>
>         return cod
>
> #-------------------------------------------------------------------------------
>
>     def Edita(self, mCod):
>         """Edita los datos."""
>
>         sql="Update Where ID=%d" %(mCod)
>
>         self.cnn.__class__.SQL=sql
>
>         try:
>             rs=self.cnn.EjecutarSQL('Update')
>             if rs==False:
>                 return False
>             else:
>                 return True
>
>
>         except errores.ConexionError, err:
>             print "Error:",err.mensaje
>         except errores.ConexionEjecucionError, err:
>             print "Error:",err.msgEjec
>
> #-------------------------------------------------------------------------------
>     def BuscarClte(self,mCod):
>
>         sql="Select * From tblClientes Where ID=%d" %(mCod)
>
>         self.cnn.__class__.SQL=sql
>
>         try:
>             rs=self.cnn.EjecutarSQL()
>             return rs
>         except errores.ConexionError, err:
>             print "Error:",err.mensaje
>         except errores.ConexionEjecucionError, err:
>             print "Error:",err.msgEjec
>
>
> ======================================================================
> ======================================================================
> ======================================================================
>
>
> ======================================================================
> FILE: FRMCLIENTESNE.PY
> ======================================================================
>
> # -*- coding: utf8 -*-#
> #Boa:Frame:Frame1
>
> import wx
> import modGlobals
> from Conectar import Conectar
> import errores
> from frmClientes import D_Cltes
>
> def create(parent, mTipo, mCodClte=''):
>     return Frame1(parent, mTipo, mCodClte)
>
> [wxID_FRAME1, wxID_FRAME1BTNOK, wxID_FRAME1BTNSALIR,
> wxID_FRAME1CBOTIPODOC,
>  wxID_FRAME1LBLCEL, wxID_FRAME1LBLCOD, wxID_FRAME1LBLCODIGO,
> wxID_FRAME1LBLCP,
>  wxID_FRAME1LBLCTE, wxID_FRAME1LBLDIREC, wxID_FRAME1LBLEMAIL,
>  wxID_FRAME1LBLF1, wxID_FRAME1LBLF2, wxID_FRAME1LBLFAX,
> wxID_FRAME1LBLLIN,
>  wxID_FRAME1LBLNUM, wxID_FRAME1LBLTD, wxID_FRAME1LBLWEB,
> wxID_FRAME1PANEL1,
>  wxID_FRAME1TXTCELU, wxID_FRAME1TXTCLTE, wxID_FRAME1TXTDIREC,
>  wxID_FRAME1TXTEMAIL, wxID_FRAME1TXTFAX, wxID_FRAME1TXTFONO1,
>  wxID_FRAME1TXTFONO2, wxID_FRAME1TXTLINCRE, wxID_FRAME1TXTNUMDOC,
>  wxID_FRAME1TXTPOSTAL, wxID_FRAME1TXTWEB,
> ] = [wx.NewId() for _init_ctrls in range(30)]
>
> class Frame1(wx.Frame):
>     TipoOper=None
>     CodClte=None
>
>     def _init_coll_fsClte_Growables(self, parent):
>         # generated method, don't edit
>
>         parent.AddGrowableRow(0)
>         parent.AddGrowableRow(1)
>         parent.AddGrowableCol(0)
>
>     def _init_coll_fsCtrls_Items(self, parent):
>         # generated method, don't edit
>
>         parent.AddWindow(self.lblCod, 0, border=5, flag=0)
>         parent.AddWindow(self.lblCodigo, 0, border=5, flag=0)
>         parent.AddWindow(self.lblCte, 0, border=5, flag=0)
>         parent.AddWindow(self.txtClte, 0, border=5, flag=0)
>         parent.AddWindow(self.lblTD, 0, border=5, flag=0)
>         parent.AddWindow(self.cboTipoDoc, 0, border=5, flag=0)
>         parent.AddWindow(self.lblNum, 0, border=5, flag=0)
>         parent.AddWindow(self.txtNumDoc, 0, border=5, flag=0)
>         parent.AddWindow(self.lblDirec, 0, border=5, flag=0)
>         parent.AddWindow(self.txtDirec, 0, border=5, flag=0)
>         parent.AddWindow(self.lblCP, 0, border=5, flag=0)
>         parent.AddWindow(self.txtPostal, 0, border=5, flag=0)
>         parent.AddWindow(self.lblF1, 0, border=5, flag=0)
>         parent.AddWindow(self.txtFono1, 0, border=5, flag=0)
>         parent.AddWindow(self.lblF2, 0, border=5, flag=0)
>         parent.AddWindow(self.txtFono2, 0, border=5, flag=0)
>         parent.AddWindow(self.lblFax, 0, border=5, flag=0)
>         parent.AddWindow(self.txtFax, 0, border=5, flag=0)
>         parent.AddWindow(self.lblEmail, 0, border=5, flag=0)
>         parent.AddWindow(self.txtEmail, 0, border=5, flag=0)
>         parent.AddWindow(self.lblWeb, 0, border=5, flag=0)
>         parent.AddWindow(self.txtWeb, 0, border=5, flag=0)
>         parent.AddWindow(self.lblCel, 0, border=5, flag=0)
>         parent.AddWindow(self.txtCelu, 0, border=5, flag=0)
>         parent.AddWindow(self.lblLin, 0, border=5, flag=0)
>         parent.AddWindow(self.txtLinCre, 0, border=5, flag=0)
>
>     def _init_coll_fsClte_Items(self, parent):
>         # generated method, don't edit
>
>         parent.AddSizer(self.fsCtrls, 1, border=5,
>               flag=wx.ALIGN_CENTER_HORIZONTAL)
>         parent.AddSizer(self.fsBtn, 1, border=5,
>               flag=wx.ALIGN_CENTER_HORIZONTAL)
>
>     def _init_coll_fsBtn_Items(self, parent):
>         # generated method, don't edit
>
>         parent.AddWindow(self.btnOk, 0, border=5, flag=wx.ALL |
> wx.EXPAND)
>         parent.AddWindow(self.btnSalir, 0, border=5, flag=wx.ALL |
> wx.EXPAND)
>
>     def _init_coll_bsClte_Items(self, parent):
>         # generated method, don't edit
>
>         parent.AddWindow(self.panel1, 0, border=0, flag=wx.EXPAND)
>
>     def _init_sizers(self):
>         # generated method, don't edit
>         self.bsClte = wx.BoxSizer(orient=wx.VERTICAL)
>
>         self.fsClte = wx.FlexGridSizer(cols=0, hgap=0, rows=2, vgap=0)
>
>         self.fsCtrls = wx.FlexGridSizer(cols=2, hgap=1, rows=0, vgap=2)
>
>         self.fsBtn = wx.FlexGridSizer(cols=2, hgap=0, rows=0, vgap=0)
>
>         self._init_coll_bsClte_Items(self.bsClte)
>         self._init_coll_fsClte_Items(self.fsClte)
>         self._init_coll_fsClte_Growables(self.fsClte)
>         self._init_coll_fsCtrls_Items(self.fsCtrls)
>         self._init_coll_fsBtn_Items(self.fsBtn)
>
>         self.SetSizer(self.bsClte)
>         self.panel1.SetSizer(self.fsClte)
>
>     def _init_ctrls(self, prnt):
>         # generated method, don't edit
>         wx.Frame.__init__(self, id=wxID_FRAME1, name='', parent=prnt,
>               pos=wx.Point(629, 243), size=wx.Size(263, 353),
>               style=wx.DEFAULT_FRAME_STYLE, title=u'Clientes')
>         self.SetClientSize(wx.Size(263, 353))
>
>         self.panel1 = wx.Panel(id=wxID_FRAME1PANEL1, name='panel1',
> parent=self,
>               pos=wx.Point(0, 0), size=wx.Size(263, 348),
>               style=wx.TAB_TRAVERSAL)
>
>         self.lblCte = wx.StaticText(id=wxID_FRAME1LBLCTE,
> label=u'Cliente',
>               name=u'lblCte', parent=self.panel1, pos=wx.Point(4, 14),
>               size=wx.Size(35, 12), style=0)
>
>         self.txtClte = wx.TextCtrl(id=wxID_FRAME1TXTCLTE,
> name=u'txtClte',
>               parent=self.panel1, pos=wx.Point(58, 14),
> size=wx.Size(200, 22),
>               style=0, value=u'')
>         self.txtClte.SetToolTipString(u'Nombre o Raz\xf3n Social')
>
>         self.lblTD = wx.StaticText(id=wxID_FRAME1LBLTD, label=u'Tipo
> Doc.',
>               name=u'lblTD', parent=self.panel1, pos=wx.Point(4, 38),
>               size=wx.Size(45, 12), style=0)
>
>         self.cboTipoDoc = wx.ComboBox(choices=[],
> id=wxID_FRAME1CBOTIPODOC,
>               name=u'cboTipoDoc', parent=self.panel1, pos=wx.Point(58,
> 38),
>               size=wx.Size(198, 24), style=0, value=u'')
>         self.cboTipoDoc.SetLabel(u'')
>         self.cboTipoDoc.Bind(wx.EVT_COMBOBOX, self.OnCboTipoDocCombobox,
>               id=wxID_FRAME1CBOTIPODOC)
>
>         self.lblNum = wx.StaticText(id=wxID_FRAME1LBLNUM, label=u'N
> \xfamero',
>               name=u'lblNum', parent=self.panel1, pos=wx.Point(4, 64),
>               size=wx.Size(38, 12), style=0)
>
>         self.txtNumDoc = wx.TextCtrl(id=wxID_FRAME1TXTNUMDOC,
> name=u'txtNumDoc',
>               parent=self.panel1, pos=wx.Point(58, 64), size=wx.Size(80,
> 22),
>               style=0, value=u'')
>         self.txtNumDoc.SetToolTipString(u'N\xfamero de Documento')
>
>         self.lblDirec = wx.StaticText(id=wxID_FRAME1LBLDIREC,
>               label=u'Direcci\xf3n', name=u'lblDirec',
> parent=self.panel1,
>               pos=wx.Point(4, 88), size=wx.Size(47, 12), style=0)
>
>         self.txtDirec = wx.TextCtrl(id=wxID_FRAME1TXTDIREC,
> name=u'txtDirec',
>               parent=self.panel1, pos=wx.Point(58, 88),
> size=wx.Size(200, 22),
>               style=0, value=u'')
>         self.txtDirec.SetToolTipString(u'Direcci\xf3n')
>
>         self.lblCP = wx.StaticText(id=wxID_FRAME1LBLCP,
> label=u'Cod.Postal',
>               name=u'lblCP', parent=self.panel1, pos=wx.Point(4, 112),
>               size=wx.Size(52, 12), style=0)
>
>         self.txtPostal = wx.TextCtrl(id=wxID_FRAME1TXTPOSTAL,
> name=u'txtPostal',
>               parent=self.panel1, pos=wx.Point(58, 112),
> size=wx.Size(80, 24),
>               style=0, value=u'')
>         self.txtPostal.SetToolTipString(u'C\xf3digo Postal')
>
>         self.lblF1 = wx.StaticText(id=wxID_FRAME1LBLF1, label=u'Tel
> \xe9fono',
>               name=u'lblF1', parent=self.panel1, pos=wx.Point(4, 138),
>               size=wx.Size(39, 12), style=0)
>
>         self.txtFono1 = wx.TextCtrl(id=wxID_FRAME1TXTFONO1,
> name=u'txtFono1',
>               parent=self.panel1, pos=wx.Point(58, 138),
> size=wx.Size(80, 22),
>               style=0, value=u'')
>
>         self.lblF2 = wx.StaticText(id=wxID_FRAME1LBLF2, label=u'Tel
> \xe9fono',
>               name=u'lblF2', parent=self.panel1, pos=wx.Point(4, 162),
>               size=wx.Size(39, 12), style=0)
>
>         self.txtFono2 = wx.TextCtrl(id=wxID_FRAME1TXTFONO2,
> name=u'txtFono2',
>               parent=self.panel1, pos=wx.Point(58, 162),
> size=wx.Size(80, 22),
>               style=0, value=u'')
>
>         self.lblFax = wx.StaticText(id=wxID_FRAME1LBLFAX, label=u'Fax',
>               name=u'lblFax', parent=self.panel1, pos=wx.Point(4, 186),
>               size=wx.Size(16, 12), style=0)
>
>         self.txtFax = wx.TextCtrl(id=wxID_FRAME1TXTFAX, name=u'txtFax',
>               parent=self.panel1, pos=wx.Point(58, 186),
> size=wx.Size(80, 22),
>               style=0, value=u'')
>
>         self.lblEmail = wx.StaticText(id=wxID_FRAME1LBLEMAIL,
> label=u'Email',
>               name=u'lblEmail', parent=self.panel1, pos=wx.Point(4,
> 210),
>               size=wx.Size(27, 12), style=0)
>
>         self.txtEmail = wx.TextCtrl(id=wxID_FRAME1TXTEMAIL,
> name=u'txtEmail',
>               parent=self.panel1, pos=wx.Point(58, 210),
> size=wx.Size(192, 22),
>               style=0, value=u'@')
>
>         self.lblWeb = wx.StaticText(id=wxID_FRAME1LBLWEB,
> label=u'Website',
>               name=u'lblWeb', parent=self.panel1, pos=wx.Point(4, 234),
>               size=wx.Size(36, 12), style=0)
>
>         self.txtWeb = wx.TextCtrl(id=wxID_FRAME1TXTWEB, name=u'txtWeb',
>               parent=self.panel1, pos=wx.Point(58, 234),
> size=wx.Size(192, 22),
>               style=0, value=u'http://')
>
>         self.lblCel = wx.StaticText(id=wxID_FRAME1LBLCEL,
> label=u'Celular',
>               name=u'lblCel', parent=self.panel1, pos=wx.Point(4, 258),
>               size=wx.Size(35, 12), style=0)
>
>         self.txtCelu = wx.TextCtrl(id=wxID_FRAME1TXTCELU,
> name=u'txtCelu',
>               parent=self.panel1, pos=wx.Point(58, 258),
> size=wx.Size(80, 22),
>               style=0, value=u'9')
>
>         self.lblLin = wx.StaticText(id=wxID_FRAME1LBLLIN,
>               label=u'Lin.Cr\xe9dito', name=u'lblLin',
> parent=self.panel1,
>               pos=wx.Point(4, 282), size=wx.Size(53, 12), style=0)
>
>         self.txtLinCre = wx.TextCtrl(id=wxID_FRAME1TXTLINCRE,
> name=u'txtLinCre',
>               parent=self.panel1, pos=wx.Point(58, 282),
> size=wx.Size(80, 22),
>               style=0, value=u'0')
>         self.txtLinCre.SetToolTipString(u'Linea de Cr\xe9dito')
>
>         self.btnOk = wx.Button(id=wxID_FRAME1BTNOK, label=u'Aceptar',
>               name=u'btnOk', parent=self.panel1, pos=wx.Point(41, 309),
>               size=wx.Size(85, 34), style=0)
>         self.btnOk.SetToolTipString(u'Acepta cambios')
>         self.btnOk.Bind(wx.EVT_BUTTON, self.OnBtnOkButton,
> id=wxID_FRAME1BTNOK)
>
>         self.btnSalir = wx.Button(id=wxID_FRAME1BTNSALIR,
> label=u'Salir',
>               name=u'btnSalir', parent=self.panel1, pos=wx.Point(136,
> 309),
>               size=wx.Size(85, 34), style=0)
>         self.btnSalir.SetToolTipString(u'Salir')
>         self.btnSalir.Bind(wx.EVT_BUTTON, self.OnBtnSalirButton,
>               id=wxID_FRAME1BTNSALIR)
>
>         self.lblCod = wx.StaticText(id=wxID_FRAME1LBLCOD, label=u'C
> \xf3digo',
>               name=u'lblCod', parent=self.panel1, pos=wx.Point(4, 0),
>               size=wx.Size(34, 12), style=0)
>
>         self.lblCodigo = wx.StaticText(id=wxID_FRAME1LBLCODIGO,
> label=u'',
>               name=u'lblCodigo', parent=self.panel1, pos=wx.Point(58,
> 0),
>               size=wx.Size(150, 12), style=0)
>         self.lblCodigo.SetToolTipString(u'C\xf3digo Cliente')
>         self.lblCodigo.SetAutoLayout(False)
>
>         self._init_sizers()
>
>     def __init__(self, parent, mTipo, mCodClte):
>         self._init_ctrls(parent)
>
>         self.__class__.TipoOper=mTipo
>         self.__class__.CodClte=mCodClte
>
>
>         #Setea tamaños minimos
>         self.fsClte.Fit(self)
>         self.fsClte.SetSizeHints(self)
>
>         self.oClte=D_Cltes()
>
>         #Estableve el Encoding
>         self.encode='utf8'
>
>         self.CargarCombo()
>         self.CargaForm()
>
> #-------------------------------------------------------------------------------
>
>     def CargaForm(self):
>
>         if self.__class__.TipoOper=="E":
>             self.dat=self.oClte.BuscarClte(self.__class__.CodClte)
>             self.CargarCtrls()
>
> #-------------------------------------------------------------------------------
>
>     def CargarCtrls(self):
>
>         self.lblCodigo.SetLabel(self.dat[0][1])
>         self.txtClte.SetValue(self.dat[0][2])
>         self.cboTipoDoc.SetSelection(self.dat[0][3]-1)
>         self.txtNumDoc.SetValue(self.dat[0][4])
>         self.txtDirec.SetValue(self.dat[0][5])
>         self.txtPostal.SetValue(self.dat[0][6])
>         self.txtFono1.SetValue(self.dat[0][7])
>         self.txtFono2.SetValue(self.dat[0][8])
>         self.txtFax.SetValue(self.dat[0][9])
>         self.txtEmail.SetValue(self.dat[0][10])
>         self.txtCelu.SetValue(self.dat[0][11])
>         self.txtWeb.SetValue(self.dat[0][12])
>         self.txtLinCre.SetValue(str(self.dat[0][13]))
>
> #-------------------------------------------------------------------------------
>     def CargarCombo(self):
>
>         rs=self.oClte.CargaTDoc()
>
>         self.cboTipoDoc.Clear()
>
>         i=0
>
>         for it in rs:
>             x=unicode(rs[i][1],self.encode)
>             self.cboTipoDoc.Append(x,rs[i][0])
>             i+=1
>
>         if self.__class__.TipoOper=="N":
>             #Vacia el 1er elemento mostrado para q el user se vea
> obligado a escoger
>             self.cboTipoDoc.SetValue('')
>         elif self.__class__.TipoOper=="E":
>             #Pinta el registro seleccionado
>             pass
>
> #-------------------------------------------------------------------------------
>     def ObtieneValores(self):
>         self.oClte.__class__.mNombre=self.txtClte.GetValue()
>         self.oClte.__class__.mTipoDoc=int(self.kTipoDoc)
>         self.oClte.__class__.mNumDoc=self.txtNumDoc.GetValue()
>         self.oClte.__class__.mDireccion=self.txtDirec.GetValue()
>         self.oClte.__class__.mPostal=self.txtPostal.GetValue()
>         self.oClte.__class__.mFono1=self.txtFono1.GetValue()
>         self.oClte.__class__.mFono2=self.txtFono2.GetValue()
>         self.oClte.__class__.mFax=self.txtFax.GetValue()
>         self.oClte.__class__.mEmail=self.txtEmail.GetValue()
>         self.oClte.__class__.mCelular=self.txtCelu.GetValue()
>         self.oClte.__class__.mWeb=self.txtWeb.GetValue()
>         self.oClte.__class__.mLinCredito=int(self.txtLinCre.GetValue())
>
> #-------------------------------------------------------------------------------
>
>     def BorrarCtrls(self):
>         self.txtClte.Clear()
>         self.txtNumDoc.Clear()
>         self.txtDirec.Clear()
>         self.cboTipoDoc.Clear()
>         self.txtPostal.Clear()
>         self.txtFono1.Clear()
>         self.txtFono2.Clear()
>         self.txtFax.Clear()
>         self.txtEmail.Clear()
>         self.txtCelu.Clear()
>         self.txtWeb.Clear()
>         self.txtLinCre.Clear()
>
> #-------------------------------------------------------------------------------
>
>     def OnBtnOkButton(self, event):
>
>         self.ObtieneValores()
>
>         if self.__class__.TipoOper=="N":
>             if self.oClte.Graba()==True:
>                 dlg=wx.MessageDialog(self,u'Se ingresó el nuevo
> Cliente.', \
>                 'PymeGestor',wx.OK | wx.ICON_EXCLAMATION)
>                 dlg.ShowModal()
>                 dlg.Destroy()
>                 self.BorrarCtrls()
>                 self.txtClte.SetFocus()
>
>             else:
>                 dlg=wx.MessageDialog(self,u'Hubo un error al ingresar
> los datos.\
>                 Corrija y vuelva a intentarlo.','PymeGestor',wx.OK |
> wx.ICON_ERROR)
>                 dlg.ShowModal()
>                 dlg.Destroy()
>                 self.txtClte.SetFocus()
>
>         elif self.__class__.TipoOper=="E":
>             self.oClte.Edita()
>         else:
>             pass
>
> #-------------------------------------------------------------------------------
>
>     def OnBtnSalirButton(self, event):
>         self.Close(True)
>
> #-------------------------------------------------------------------------------
>
>     def OnCboTipoDocCombobox(self, event):
>         cb = event.GetEventObject()
>         #Obtengo el Key
>         self.kTipoDoc = cb.GetClientData(cb.GetSelection())
>
> #-------------------------------------------------------------------------------
>
> =============================================================================
> =============================================================================
> 
> -- 
> Mario Lacunza <mario.lacunza at gmail.com>




More information about the Python-list mailing list