Il semble que ce soit spécifique aux fenêtres, voici un exemple qui reproduit l'effet:Pourquoi wxGridSizer est-il beaucoup plus lent à s'initialiser sur un wxDialog que sur un wxFrame?
import wx
def makegrid(window):
grid = wx.GridSizer(24, 10, 1, 1)
window.SetSizer(grid)
for i in xrange(240):
cell = wx.Panel(window)
cell.SetBackgroundColour(wx.Color(i, i, i))
grid.Add(cell, flag=wx.EXPAND)
class TestFrame(wx.Frame):
def __init__(self, parent):
wx.Frame.__init__(self, parent)
makegrid(self)
class TestDialog(wx.Dialog):
def __init__(self, parent):
wx.Dialog.__init__(self, parent)
makegrid(self)
class Test(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None)
btn1 = wx.Button(self, label="Show Frame")
btn2 = wx.Button(self, label="Show Dialog")
sizer = wx.BoxSizer(wx.VERTICAL)
self.SetSizer(sizer)
sizer.Add(btn1, flag=wx.EXPAND)
sizer.Add(btn2, flag=wx.EXPAND)
btn1.Bind(wx.EVT_BUTTON, self.OnShowFrame)
btn2.Bind(wx.EVT_BUTTON, self.OnShowDialog)
def OnShowFrame(self, event):
TestFrame(self).Show()
def OnShowDialog(self, event):
TestDialog(self).ShowModal()
app = wx.PySimpleApp()
app.TopWindow = Test()
app.TopWindow.Show()
app.MainLoop()
J'ai essayé sur les configurations suivantes:
- Windows 7 avec Python 2.5.4 et wxPython 2.8.10.1
- Windows XP avec Python et wxPython 2.8.7.1 2.5.2
- Windows XP avec Python 2.6.0 et 2.8.9.1 wxPython
- U buntu 9.04 avec Python 2.6.2 et wxPython 2.8.9.1
Le wxDialog n'était pas lent seulement sur Ubuntu.