Hang in ListCtrl LC_VIRTUAL
Oswaldo Hernández
listas at soft-com.es
Fri Jun 29 04:57:19 PDT 2007
Hello all,
I have a problem with ListCtrl style=3DLC_VIRTUAL. Attach a sample demo.
You can recreate the hang in tree ways:
1.
- Run the program,
- pres TAB for navigation with keyboard to set the focus on hte ListCtrl
- Pres any key (except arrows an letter 'L').
If before the navigation you click on the ListCtrl none occurs, only if the=
first focus is set with =
TAB key.
2.
- Run the program
- Click on 'SetFocus' button to set the focus by code on ListCtrl
- Pres any key (except arrows an letter 'L').
3.
- Run the program
- Click on ListCtrl, pres keys, tab, etc .. (all OK)
- Click on 'Fill and SetFocus' button
- Pres any key (except arrows an letter 'L').
On all cases the ListCtrl enter in an infinite loop searchig the text that =
begin with the key pressed.
I don'n know if the hangs is because i forgot to set any propperty, neither=
know how to disable the =
automatic search when press a key.
It's a bug?
Thanks.
-- =
*****************************************
Oswaldo Hern=E1ndez
oswaldo (@) soft-com (.) es
*****************************************
-------------- next part --------------
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import wx
class mDataListCtrl(wx.ListCtrl):
def __init__(self, parent, id):
wx.ListCtrl.__init__(self, parent, id, style=3Dwx.LC_REPORT|wx.LC_V=
IRTUAL|wx.LC_HRULES|wx.LC_VRULES|wx.LC_SINGLE_SEL)
self.InsertColumn(0, "Descripcion")
self.InsertColumn(1, "N=C3=BAmero")
self.SetItemCount(0)
self.mdata =3D []
for x in range(100):
self.mdata.append(("line %s" % x, str(x)))
=
self.filldata()
def OnGetItemText(self, item, col):
print "GetItem %d %d" % (item, col)
return self.mdata[item][col]
=
def OnGetItemImage(self, item):
return -1
=
def OnGetItemAttr(self, item):
return None
def filldata(self):
self. DeleteAllItems()
self.SetItemCount(100)
self.Select(5)
=
=
class mFrame(wx.Frame):
def __init__(self, *args, **kwds):
kwds["style"] =3D wx.DEFAULT_FRAME_STYLE
wx.Frame.__init__(self, *args, **kwds)
=
sizer_frame =3D wx.BoxSizer(wx.HORIZONTAL)
self.SetSizer(sizer_frame)
=
self.panel =3D wx.Panel(self, -1)
sizer_frame.Add(self.panel, 1, wx.EXPAND, 0) =
=
sizer_panel =3D wx.BoxSizer(wx.VERTICAL)
self.panel.SetSizer(sizer_panel)
sizer_cabecera =3D wx.StaticBoxSizer(wx.StaticBox(self.panel, -1, "=
"), wx.HORIZONTAL)
sizer_panel.Add(sizer_cabecera, 0, wx.EXPAND)
=
self.label_1 =3D wx.StaticText(self.panel, -1, "Buscar : ")
self.fil_valor =3D wx.TextCtrl(self.panel, -1, "", style=3Dwx.TE_PR=
OCESS_ENTER )
sizer_cabecera.Add(self.label_1, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL=
, 3)
sizer_cabecera.Add(self.fil_valor, 1, wx.ALL|wx.EXPAND, 3)
self.lista =3D mDataListCtrl(self.panel, -1)
sizer_panel.Add(self.lista, 2, wx.EXPAND)
=
self.btn =3D wx.Button(self.panel, -1, "Fill and SetFocus")
sizer_panel.Add(self.btn,0)
=
self.btn2 =3D wx.Button(self.panel, -1, "SetFocus")
sizer_panel.Add(self.btn2,0)
=
sizer_frame.SetSizeHints(self)
sizer_frame.Fit(self)
self.SetAutoLayout(True)
self.Layout()
=
self.SetSize((500, 350))
self.btn.Bind(wx.EVT_BUTTON, self.OnBtnFill)
self.btn2.Bind(wx.EVT_BUTTON, self.OnBtnSetFocus)
=
def OnBtnFill(self, evt):
self.lista.filldata()
self.lista.SetFocus()
evt.Skip()
=
def OnBtnSetFocus(self, evt):
self.lista.SetFocus()
evt.Skip()
=
=
if __name__ =3D=3D "__main__":
app =3D wx.PySimpleApp(0)
wx.InitAllImageHandlers()
frame_1 =3D mFrame(None, -1, "")
app.SetTopWindow(frame_1)
frame_1.Show()
app.MainLoop()
More information about the wxpython-users
mailing list