Hello,
I have a wxScrolledWindow to which I'm adding some
controls as a
response to user clicks or automatically during load.
Everything is
working fine only somewhat slow. It takes few seconds
to add five rows. Is there any way to speed this up a
little bit?
I call Freeze() and Thaw() around the for loop and it
helps a little. If I don't call Freeze() the user can
see the controls created in the top corner and then
moved to their specified position!?
···
-----------
class FilterPane(wxScrolledWindow):
...
def load (self, filt):
self.Freeze()
for attr, op, val in filt:
self._add_row(attr, op, val)
self._add_row()
self.Thaw()
def _add_row (self, attr=None, op=None, val=None):
idx = len(self.rowItems)
virty = self._yMargin + idx*self._rowHeight
virtw = self.GetSizeTuple()[0]
virth = virty + self._rowHeight
y = virty -
self.GetViewStart()[1]*self._rowHeight
self.SetVirtualSize(wxSize(virtw, virth))
con = wxCheckBox(id=-1, label='',
parent=self, pos=wxPoint(1, y+4), size=wxSize(13, 13),
style=0)
cattr = wxChoice(choices=self.attrChoices,
id=-1, parent=self, pos=wxPoint(20, y),
size=wxSize(113, 21), style=0,
validator=wxDefaultValidator)
cop = wxChoice(choices=self.attrOps, id=-1,
parent=self, pos=wxPoint(140, y), size=wxSize(73, 21),
style=0, validator=wxDefaultValidator)
cval = wxComboBox(choices=[], id=-1,
parent=self, pos=wxPoint(220, y), size=wxSize(208,
21), style=0, validator=wxDefaultValidator, value='')
EVT_CHECKBOX(con, -1, self.OnCheckbox)
EVT_CHOICE(cattr, -1, self.OnAttrChoice)
if attr and op and val:
con.SetValue(True)
cattr.SetStringSelection(attr)
cop.SetStringSelection(op)
cval.SetValue(val)
self.rowItems.append((con, cattr, cop, cval))
Thanks,
Tvrtko
__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com