微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

初始wx组件加载缓慢

如何解决初始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 举报,一经查实,本站将立刻删除。