07/01/2011, 14:21
|
| | Fecha de Ingreso: abril-2008
Mensajes: 68
Antigüedad: 16 años, 7 meses Puntos: 0 | |
Respuesta: wx.ListCtrl.Append columnas vacias self es la clase que cree MyList que es un ListCtrl con columnSortenMixin, todavia no probe sacar el ordenamiento de columnas porque tambien observe que en linux me ordena-
1
2
3
11
22
y en windows
1
11
2
22
3
osea lo toma como string en windows....
Código:
class MyList(wx.ListCtrl, listmix.ColumnSorterMixin):
def __init__(self, parent,style= wx.LC_REPORT
| wx.BORDER_SIMPLE
| wx.LC_SORT_ASCENDING
| wx.LC_SINGLE_SEL
| wx.LC_AUTOARRANGE):
wx.ListCtrl.__init__(self,parent,style = style)
self.myEVT_ITEMSEL = wx.NewEventType()
self.EVT_ITEMSEL = wx.PyEventBinder(self.myEVT_ITEMSEL, 1)
self.il16 = Custom.Il_16(self)
self.il = wx.ImageList(16, 16)
self.sm_up = self.il.AddWithColourMask(self.il16.sm_up, "blue")
self.sm_dn = self.il.AddWithColourMask(self.il16.sm_dw, "blue")
self.AssignImageList(self.il, wx.IMAGE_LIST_SMALL)
self.__Events__()
self.data = {}
self.li = [] # Lista cargada actualmente
self.colums= []
self.conn = Conn.GestorBD()
def __Events__(self):
self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnDoubleClick)
self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnDoubleClick)
# Used by the ColumnSorterMixin, see wx/lib/mixins/listctrl.py
def GetListCtrl(self):
return self
def GetSortImages(self):
return (self.sm_dn, self.sm_up)
def OnDoubleClick(self, event):
id = event.m_itemIndex
id = self.GetItemText(id)
event = MyEvent(self.myEVT_ITEMSEL, self.GetId())
event.SetMyVal(id)
self.GetEventHandler().ProcessEvent(event)
def Insert_Columns(self,cols):
for i,c in enumerate(cols):
self.InsertColumn(i,c)
def Load_from_sql(self,sql):
resultado = self.conn.Query(sql,2)
if not resultado == False:
self.Load_from_list(resultado)
def Load_from_list(self,list,preserve_list = False):
self.DeleteAllColumns()
self.DeleteAllItems()
self.data.clear()
if not preserve_list:
self.li = list
self.Insert_Columns(self.colums)
for i,registro in enumerate(list):
index = self.Append(registro)
self.data[i]=registro
self.SetItemData(index, index)
self.itemDataMap = self.data
listmix.ColumnSorterMixin.__init__(self, len(self.colums))
for i,c in enumerate(self.colums):
self.SetColumnWidth(i, wx.LIST_AUTOSIZE_USEHEADER)
def filter(self, st,col=None):
newli = []
if not st:
self.Load_from_list(self.li,True)
return
st = st.lower()
for reg in self.li:
if col == None:
for r in reg:
if st in str(r).lower():newli.append(reg)
else:
if st in str(reg[col]).lower():newli.append(reg)
self.Load_from_list(newli,True)
|