2
看來,這是特定於Windows,這裏是再現效果的例子:使用Python 2.5.4和爲什麼wxGridSizer在wxDialog上然後在wxFrame上初始化要慢得多?
- 的Windows 7:
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()
我已經嘗試了本上進行如下配置wxPython的2.8.10.1
- Windows XP中使用Python 2.5.2和wxPython的2.8.7.1
- Windows XP中使用Python 2.6.0和wxPython的2.8.9.1
- ü buntu 9.04與Python 2.6.2和wxPython 2.8.9.1
只有在Ubuntu上,wxDialog速度並不慢。