altunyurt
altunyurt

Reputation: 2936

StaticText items disappear in wx.StaticBox

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?

Upvotes: 1

Views: 1355

Answers (2)

altunyurt
altunyurt

Reputation: 2936

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

Upvotes: 1

mghie
mghie

Reputation: 32334

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.

Upvotes: 1

Related Questions