初始wx组件加载缓慢

问题描述

我有一个使用wx库在python中创建的GUI。我发现当GUI最初加载时,我可以目睹每个组件的加载情况。当我转到尚未导航的面板时,这些组件也会在我眼前加载。导航到页面后,该页面会很好地显示组件,并且不需要使用GUI的额外等待时间。这确实很烦人,因为用户需要等待更多时间才能使用GUI。是否有解决此缓慢GUI行为的方法我有一些示例代码。这就是wx处理加载大量组件的方式吗?

class SomePanel(wx.Panel):
def __init__(self,parent):
    # Initialize Panel
    wx.Panel.__init__(self,parent,-1)

    # Sizers
    top_sizer = wx.BoxSizer(wx.VERTICAL)

    # Font
    self.font_bold = wx.Font(pointSize=10,family=wx.DEFAULT,style=wx.norMAL,weight=wx.BOLD)

    grid_value_sizer = wx.GridBagSizer(hgap=5,vgap=5)

    self.enabled_title_st = wx.StaticText(self,wx.ID_ANY,"Enabled")
    grid_value_sizer.Add(self.enabled_title_st,pos=(0,0),flag=wx.EXPAND | wx.ALL,border=0)

    self.enabled_st = wx.StaticText(self,size=(STATICTEXT_WIDTH_VAL,-1),style=wx.ALIGN_RIGHT)
    self.enabled_st.SetFont(self.font_bold)
    self.enabled_st.SetForegroundColour((255,255,255))
    self.enabled_st.SetBackgroundColour((0,0))
    grid_value_sizer.Add(self.enabled_st,1),border=0)
    
    .
    .
    .
    .
    .

    self.other_component_st = wx.StaticText(self,"OtherComponent")
    grid_value_sizer.Add(self.other_component_title_st,pos=(12,2),border=0)

    self.other_component_st = wx.StaticText(self,style=wx.ALIGN_RIGHT)
    self.other_component_st.SetFont(self.font_bold)
    self.other_component_st.SetForegroundColour((255,255))
    self.other_component_st.SetBackgroundColour((0,0))
    grid_value_sizer.Add(self.other_component_st,3),border=0)

    top_sizer.Add(grid_value_sizer,flag=wx.ALL,border=2)

    self.SetSizer(top_sizer)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)