StaticText 项目在 wx.StaticBox 中消失

发布于 2024-07-13 08:12:45 字数 2002 浏览 12 评论 0原文

我正在垂直尺寸调整器中创建一个 staticbox 和 staticboxsizer 。 一切对我来说都运行良好,但在客户的环境中却不然。

静态框中的所有内容都会显示,但标签除外。 下面的代码片段显示了我如何构建 staticboxsizer。

    sbox2 = wx.StaticBox(self, wx.ID_ANY, 'CH1 Only')
    sboxsizer2 = wx.StaticBoxSizer(sbox2, wx.VERTICAL)

    gsizer9 = wx.GridBagSizer(1,1)
    gsizer9.Add(comp.MinMaxLabel_21, (1,0), (1,1), wx.ALL, 1)
    gsizer9.Add(comp.MinMax_21, (1,1), (1,1), wx.ALL, 1)

    gsizer9.Add(comp.MinMax_19, (2,1), (1,1), wx.ALL, 1)
    gsizer9.Add(comp.MinMaxLabel_19, (2,0), (1,1), wx.ALL, 1)

    gsizer9.Add(comp.VcOS_15, (3,1), (1,1), wx.ALL, 1)
    gsizer9.Add(comp.MinMaxLabel_22, (3,0), (1,1), wx.ALL, 1)


    gsizer9.Add(comp.MonLabel_18, (0,3), (1,1), wx.ALL, 1)
    gsizer9.Add(comp.MonLabel_21, (0,4), (1,1), wx.ALL, 1)
    gsizer9.Add(comp.MonLabel_17, (0,5), (1,1), wx.ALL, 1)
    comp.MonLabel_22.Wrap(40)
    gsizer9.Add(comp.MonLabel_22, (0,6), (1,1), wx.ALL, 1)
    comp.MonLabel_19.Wrap(40)
    gsizer9.Add(comp.MonLabel_19, (0,7), (1,1), wx.ALL, 1)

    gsizer9.Add(comp.VcOS_10, (1,3), (1,1), wx.ALL, 1)
    gsizer9.Add(comp.VcOS_11, (1,4), (1,1), wx.ALL, 1)
    gsizer9.Add(comp.VcOS_12, (1,5), (1,1), wx.ALL, 1)
    gsizer9.Add(comp.VcOS_13, (1,6), (1,1), wx.ALL, 1)
    gsizer9.Add(comp.VcOS_14, (1,7), (1,1), wx.ALL, 1)

    sboxsizer2.Add(gsizer9, 0,0,0)
    vsizer4.Add(sboxsizer2, 0,0,0)

comp.MinMaxLabel_* 返回一个 wx.StaticText(label='blah'),没什么花哨的,只是一个包装器,它适用于其他 sizer 中的其他约 400 个项目。 但在 StaticBox 或 StaticBoxSizers 中,客户的设置中不显示 StaticText。

通常它在我的设置中显示如下: 替代文本 http://img152.imageshack.us/img152/8758/normalnu9.jpg< /a>

这是我在客户设置中得到的信息: 替代文本 http://img258.imageshack.us/img258/2351/problematiczo2.jpg< /a>

两个设置具有相同的 wxpython 版本,2.8.9.1。 但 2.8.* 也显示在我的环境中。 有什么建议么?

I'm creating a staticbox and a staticboxsizer in a vertical sizer. Everything works fine for me, but not on the customer's environment.

Everything in the staticbox is displayed, but labels. snippet below shows how i construct the staticboxsizer.

    sbox2 = wx.StaticBox(self, wx.ID_ANY, 'CH1 Only')
    sboxsizer2 = wx.StaticBoxSizer(sbox2, wx.VERTICAL)

    gsizer9 = wx.GridBagSizer(1,1)
    gsizer9.Add(comp.MinMaxLabel_21, (1,0), (1,1), wx.ALL, 1)
    gsizer9.Add(comp.MinMax_21, (1,1), (1,1), wx.ALL, 1)

    gsizer9.Add(comp.MinMax_19, (2,1), (1,1), wx.ALL, 1)
    gsizer9.Add(comp.MinMaxLabel_19, (2,0), (1,1), wx.ALL, 1)

    gsizer9.Add(comp.VcOS_15, (3,1), (1,1), wx.ALL, 1)
    gsizer9.Add(comp.MinMaxLabel_22, (3,0), (1,1), wx.ALL, 1)


    gsizer9.Add(comp.MonLabel_18, (0,3), (1,1), wx.ALL, 1)
    gsizer9.Add(comp.MonLabel_21, (0,4), (1,1), wx.ALL, 1)
    gsizer9.Add(comp.MonLabel_17, (0,5), (1,1), wx.ALL, 1)
    comp.MonLabel_22.Wrap(40)
    gsizer9.Add(comp.MonLabel_22, (0,6), (1,1), wx.ALL, 1)
    comp.MonLabel_19.Wrap(40)
    gsizer9.Add(comp.MonLabel_19, (0,7), (1,1), wx.ALL, 1)

    gsizer9.Add(comp.VcOS_10, (1,3), (1,1), wx.ALL, 1)
    gsizer9.Add(comp.VcOS_11, (1,4), (1,1), wx.ALL, 1)
    gsizer9.Add(comp.VcOS_12, (1,5), (1,1), wx.ALL, 1)
    gsizer9.Add(comp.VcOS_13, (1,6), (1,1), wx.ALL, 1)
    gsizer9.Add(comp.VcOS_14, (1,7), (1,1), wx.ALL, 1)

    sboxsizer2.Add(gsizer9, 0,0,0)
    vsizer4.Add(sboxsizer2, 0,0,0)

comp.MinMaxLabel_* returns a wx.StaticText(label='blah'), nothing fancy, just a wrapper, which works fine for other ~400 items in other sizers. but in StaticBox or StaticBoxSizers, no StaticText displayed on customer's setup.

normally it is displayed as this in my setup:
alt text http://img152.imageshack.us/img152/8758/normalnu9.jpg

this is what i get on customer's setup:
alt text http://img258.imageshack.us/img258/2351/problematiczo2.jpg

both setups have the same wxpython versions, 2.8.9.1. but 2.8.* also displays on my environment.
any suggestions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

七度光 2024-07-20 08:12:45

wxStaticBox的源代码在绘制代码中做了不同的事情,具体取决于是否启用XP主题。 在没有主题的屏幕截图中,一切看起来都正常,在启用了主题的屏幕截图中,标签丢失了。 您能否在启用主题的系统上尝试一下,看看标签是否显示正常? 或者您的客户可以暂时禁用主题并检查是否可以解决问题?

另外,您使用什么作为标签的父级 - 框架/对话框还是静态框? 我无法从发布的代码中看到它,但我会使用静态框。 也许这也会有所作为。

The source code of wxStaticBox does different things in painting code, depending on whether XP themes are enabled. In the screen shot without themes everything looks OK, in the one with themes enabled the labels are missing. Could you try on your system with themes enabled, and see whether labels display OK? Or can your customer temporarily disable themes and check whether that fixes the problem?

Also, what do you use as the parent for the labels - the frame / dialog or the static box? I can't see it from the posted code, but I would use the static box. Maybe this will make a difference too.

2024-07-20 08:12:45

comp.Component 使用主面板 -ScrolledPanel- 作为父面板

class MyBackground(ScrolledPanel):
    def __init__(self, parent, components):
        ScrolledPanel.__init__(self, parent, -1, style=wx.TAB_TRAVERSAL)
        self.setFont()
        comp = Components(components, self)

...
...
app = wx.PySimpleApp(0)
wx.InitAllImageHandlers()
frame = wx.Frame(None, -1, 'Set Limits', size=(800,600), style=wx.DEFAULT_FRAME_STYLE)
panel = MyBackground(frame, components)

作为临时但成功的解决方案,我已删除 staticboxes 并将 staticboxsizer 更改为 gridbagsizer,一切正常:) 正如您所说,最有可能的问题与主题有关,我我猜改变标签的前景色可能会起作用。

感谢您的回复

comp.Component uses the main panel -ScrolledPanel- as the parent

class MyBackground(ScrolledPanel):
    def __init__(self, parent, components):
        ScrolledPanel.__init__(self, parent, -1, style=wx.TAB_TRAVERSAL)
        self.setFont()
        comp = Components(components, self)

...
...
app = wx.PySimpleApp(0)
wx.InitAllImageHandlers()
frame = wx.Frame(None, -1, 'Set Limits', size=(800,600), style=wx.DEFAULT_FRAME_STYLE)
panel = MyBackground(frame, components)

as a temporary but succesful solution, i've removed staticboxes and changed staticboxsizer to gridbagsizer, everything works fine :) most probably problem is related to theme as you've said and i guess changing the foreground color for labels might just work.

thanks for reply

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文