• Lunes 29 de Abril de 2024, 04:09

Autor Tema:  TABLAS EN BOA CONSTRUCTOR  (Leído 2077 veces)

jorgeortega10

  • Nuevo Miembro
  • *
  • Mensajes: 13
    • Ver Perfil
TABLAS EN BOA CONSTRUCTOR
« en: Lunes 29 de Diciembre de 2008, 22:44 »
0
SI ALGUIEN ME PODRIA AYUDAR CON TABLAS EN BOA COMO EN DELPHI PARA INSERTAR FILAS

RadicalEd

  • Moderador
  • ******
  • Mensajes: 2430
  • Nacionalidad: co
    • Ver Perfil
Re: TABLAS EN BOA CONSTRUCTOR
« Respuesta #1 en: Martes 30 de Diciembre de 2008, 14:10 »
0
Qué tipo de tablas, las que maneja el control sheet???, checa este código
Extraido de zetcode
Código: Python
  1. #!/usr/bin/python
  2.  
  3. # notebook.py
  4.  
  5. import wx
  6. import wx.lib.sheet as sheet
  7.  
  8.  
  9. class MySheet(sheet.CSheet):
  10.     def __init__(self, parent):
  11.         sheet.CSheet.__init__(self, parent)
  12.         self.SetNumberRows(50)
  13.         self.SetNumberCols(50)
  14.  
  15. class Notebook(wx.Frame):
  16.     def __init__(self, parent, id, title):
  17.         wx.Frame.__init__(self, parent, id, title, size=(600, 500))
  18.         menubar = wx.MenuBar()
  19.         file = wx.Menu()
  20.         file.Append(101, 'Quit', '' )
  21.         menubar.Append(file, '&File')
  22.         self.SetMenuBar(menubar)
  23.  
  24.         wx.EVT_MENU(self, 101, self.OnQuit)
  25.  
  26.         nb = wx.Notebook(self, -1, style=wx.NB_BOTTOM)
  27.         self.sheet1 = MySheet(nb)
  28.         self.sheet2 = MySheet(nb)
  29.         self.sheet3 = MySheet(nb)
  30.  
  31.         nb.AddPage(self.sheet1, 'Sheet1')
  32.         nb.AddPage(self.sheet2, 'Sheet2')
  33.         nb.AddPage(self.sheet3, 'Sheet3')
  34.  
  35.         self.sheet1.SetFocus()
  36.         self.StatusBar()
  37.         self.Centre()
  38.         self.Show()
  39.  
  40.     def StatusBar(self):
  41.         self.statusbar = self.CreateStatusBar()
  42.  
  43.     def OnQuit(self, event):
  44.         self.Close()
  45.  
  46. app = wx.App()
  47. Notebook(None, -1, 'notebook.py')
  48. app.MainLoop()
  49.  
  50.  
El pasado son solo recuerdos, el futuro son solo sueños

jorgeortega10

  • Nuevo Miembro
  • *
  • Mensajes: 13
    • Ver Perfil
Re: TABLAS EN BOA CONSTRUCTOR
« Respuesta #2 en: Martes 30 de Diciembre de 2008, 17:00 »
0
HOLA CON LO QUE ME AYUDASTE ME AYUDO EN UNA PARTE DE MI SISTEMA PERO LA PARTE QUE MAS O MENOS NECESITO ES DE LA SIGUIENTE MANERA
TENDO UN WX.CHOICE QUE INSERTO UN CODIGO Y EN UN TEXT ME DA LA DESCRIPCION DESPUES TENGO UN TEX DONDE INSERTO LA CANTIDA Y EL PRECIO DESPUES TENGO UNOS BOTONES PARA INSERTAR MODIFICAR O ELIMINAL, LO QUE NESECITO ES SABER COMO HAGO PARA QUE DESPUES EN LA PARTE DE MAS ABAJO SE INSERTE UNA FILA CON TODO LO ANTERIOR MAS EL TOTAL CON UN PUNTERO PARA PODER MODIFICAR O ELIMINAR

RadicalEd

  • Moderador
  • ******
  • Mensajes: 2430
  • Nacionalidad: co
    • Ver Perfil
Re: TABLAS EN BOA CONSTRUCTOR
« Respuesta #3 en: Martes 30 de Diciembre de 2008, 17:38 »
0
Busca info acerca de SetCellValue, el ejemplo de esta página está bastante claro. wx.lib.sheet
Acá te copio el ejemplo
Código: Python
  1. # use wxPython's wx.lib.sheet.CSheet widget
  2. # to create a simple spread sheet
  3.  
  4. import wx
  5. import wx.lib.sheet
  6.  
  7. class MySheet(wx.lib.sheet.CSheet):
  8.     instance = 0
  9.     def __init__(self, parent, rows, cols, data_list):
  10.         wx.lib.sheet.CSheet.__init__(self, parent)
  11.         self.SetRowLabelAlignment(wx.ALIGN_CENTRE, wx.ALIGN_CENTRE)
  12.         self.text = ''
  13.        
  14.         # set the rows and columns of the sheet
  15.         self.SetNumberRows(rows)
  16.         self.SetNumberCols(cols)
  17.        
  18.         # set row height and column width
  19.         row_size = 20
  20.         for row in range(self.GetNumberRows()):
  21.             self.SetRowSize(row, row_size)
  22.         col_size = 60
  23.         for col in range(self.GetNumberCols()):
  24.             # make name and role columns wider
  25.             if col < 2:
  26.                 self.SetColSize(col, col_size + 80)
  27.             else:
  28.                 self.SetColSize(col, col_size)
  29.                
  30.         # set column lable titles at the top
  31.         for ix, title in enumerate(data_list[0]):
  32.             self.SetColLabelValue(ix, title)
  33.            
  34.         # create reusable attribute objects for all cells
  35.         self.attr = wx.grid.GridCellAttr()
  36.         self.attr.SetTextColour('black')
  37.         self.attr.SetBackgroundColour('yellow')
  38.         self.attr.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL))
  39.        
  40.         # now load the data_list into the spread sheet cells
  41.         self.loadCells(data_list)
  42.        
  43.     def loadCells(self, data_list):
  44.         # find rows and columns the data needs
  45.         self.drows = len(data_list)
  46.         self.dcols = len(data_list[0])
  47.         # note that the title row=0 is taken
  48.         for row in range(1, self.drows):
  49.             # set cell attributes for the whole row
  50.             self.SetRowAttr(row-1, self.attr)
  51.             for col in range(self.dcols):
  52.                 value = data_list[row][col]
  53.                 #print row, col, value  # testing ...
  54.                 self.SetCellValue(row-1, col, value)
  55.                 # align numbers to the right
  56.                 if col > 1:
  57.                     self.SetCellAlignment(row-1, col,wx.ALIGN_RIGHT, wx.ALIGN_CENTRE)
  58.        
  59.         # optional extra information at the end
  60.         self.SetCellTextColour(row, 0, 'red')
  61.         self.SetCellBackgroundColour(row, 0, 'white')
  62.         # wx.Font(pointSize, family, style, weight, underline=false,
  63.         # faceName="", encoding=wx.FONTENCODING_DEFAULT)
  64.         # family: wx.DEFAULT, wx.DECORATIVE, wx.ROMAN, wx.SCRIPT, wx.SWISS,
  65.         # wx.MODERN
  66.         # style: wx.NORMAL, wx.SLANT or wx.ITALIC
  67.         # weight: wx.NORMAL, wx.LIGHT or wx.BOLD
  68.         font = wx.Font(8, wx.ROMAN, wx.ITALIC, wx.NORMAL)
  69.         self.SetCellFont(row, 0, font)
  70.         text = "The cast of Hallo Yankee Mama"
  71.         self.SetCellValue(row, 0, text)
  72.        
  73.     def OnLeftClick(self, event):
  74.         """
  75.        a CSheet method
  76.        cell is left-clicked, get cell data
  77.        """
  78.         r = event.GetRow()
  79.         c = event.GetCol()
  80.         text = self.GetCellValue(r, c)
  81.         self.GetParent().SetTitle(text)  # test ...
  82.         # move the cursor to the selected cell
  83.         self.SetGridCursor(r, c)
  84.        
  85. class MyFrame(wx.Frame):
  86.     def __init__(self, parent, mytitle, mysize, data_list):
  87.         wx.Frame.__init__(self, parent, wx.ID_ANY, mytitle, size=mysize)
  88.        
  89.         # create the spread sheet
  90.         # give it enough rows and columns to fit all the data
  91.         rows = 18
  92.         cols = 4
  93.         self.sheet1 = MySheet(self, rows, cols, data_list)
  94.         self.sheet1.SetFocus()
  95.        
  96. # this data string could have been loaded from a file
  97. data_str = """
  98. Name, Role, Age, Height
  99. Gladys Day, Mama, 55, 64
  100. Alfonso Day, Papa, 60, 67
  101. Doris Night, Neighbor, 51, 68
  102. Jonathan Summer, Neighbor, 60, 66
  103. Elke Winter, Sweety, 51, 70
  104. Frank Ferkel Day, Son, 25, 74
  105. Karl Arm, Friend, 32, 73
  106. Mark Marlboro, Thief, 26, 72
  107. Larry Lark, Policeman, 22, 69
  108. Gustav Gurgel, Pizzaman, 19, 61
  109. Monika Kleinbrust, Niece, 23, 62
  110. Paul Porkough, Council, 45, 58"""
  111.  
  112. # create a data list from the data string
  113. # this makes it easier to load the spread sheet
  114. data_list = []
  115. for line in data_str.split('n'):
  116.     line_list = line.split(',')
  117.     data_list.append(line_list)
  118.  
  119. app = wx.App(0)
  120. mytitle = "a simple spread sheet"
  121. width = 450
  122. height = 380
  123. MyFrame(None, mytitle, (width, height), data_list).Show()
  124. app.MainLoop()
  125.  

Cualquier inquietud no dudes en hacerla, yo creo que este código está mucho más sencillo que el anterior y más comentado, sino sabes ingles ¿QUE ESPERAS PARA APRENDERLO? :devil:  :devil:
El pasado son solo recuerdos, el futuro son solo sueños