"Lee Merrill" <justducky (AT) nc (DOT) rr.comwrote:
Hi everyone,
I have a screen that has lots of widgets on it, and the Choice
widgets are taking much longer to create than the other widgets:
choices=["1 second", "5 secs", "10 secs", "15 secs", "20 secs"]
ctrlList = []
prevTime = time.time()
for loopidx in xrange(100):
ctrlList.append(wx.Choice(parent, -1, choices=choices))
print time.time() - prevTime
Now with 1 string (e.g. ["1 second"]) this takes .2 seconds, with 3
strings, .34 secs, with 5 strings, .47 seconds. So you can imagine what
the startup time is for hundreds of Choice widgets! Now I was hoping
for fast performance from wxPython, the other widgets are about three times
faster, but that's still not fast!
But the Choice widgets are my main problem, I have lots of them, with
lots of strings, and this is kind of a roadblock at this point.
Any thoughts appreciated,
Lee
P.S. This is with wxPython 2.6.3 and Python 2.4.2 on Windows XP
Paul Johnston recently asked a similar question about 30 choice controls
with ~1000 entries per control taking around 17 seconds to create. He
was also using Windows XP (in my experience, the slow creation time does
not tend to occur on Windows 2k).
Robin Dunn offered a solution which seems to have solved Paul's problem:
1. ch = wx.Choice(parent, -1, choices=[])
2. ch.Freeze()
3. ch.AppendItems(choices)
4. ch.Thaw()
changing your snippet
choices=["1 second", "5 secs", "10 secs", "15 secs", "20 secs"]
ctrlList = []
prevTime = time.time()
for loopidx in xrange(100):
wx.Choice(self, -1, choices=choices)
choices[-1].Freeze()
choices[-1].AppendItems(choices)
choices[-1].Thaw()
print time.time() - prevTime
In running your original snippet on my machine, it took 0.234 seconds.
Running the changed version above runs in .188 seconds. If instead of
adding 5 items to 100 controls, you were adding 100 items 1000 controls,
your original snippet ran 11.44 seconds on my machine, but with the
.Freeze () and .Thaw(), it ran in 6.35 seconds. You may get more
significant improvements than I have been getting, if only because win2k
seems to run faster without .Freeze() and .Thaw() than XP.
Try .Freeze() and .Thaw() as Robin suggests and get back to us.
- Josiah
To unsubscribe, e-mail: wxPython-users-unsubscribe (AT) lists (DOT) wxwidgets.org
For additional commands, e-mail: wxPython-users-help (AT) lists (DOT) wxwidgets.org