wx.StaticBox - can't click on any controls

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

wx.StaticBox - can't click on any controls

Robert Gravina
The code below displays a panel with a  wx.StaticBox with a wx.Choice  
inside it. For some reason, clicking on the dropdown does nothing.  
Can anyone spot the problem?

I am using Python 2.5, wxPython 2.8.4.2 on Mac OS 10.4.10

Robert
-------------------------
import wx
               
class TestPanel(wx.Panel):
     def __init__(self, parent):
      wx.Panel.__init__(self, parent)
         self.cmb = wx.Choice(self, size=wx.Size(100,-1), choices=
["test1", "test2", "test3"])
         sizer = wx.BoxSizer(wx.VERTICAL)
         box = wx.StaticBox(self, label="Test SaticBox")
         sizerInner = wx.StaticBoxSizer(box, wx.VERTICAL)
         sizerInner.Add(self.cmb)
         sizer.Add(sizerInner)
         self.SetSizer(sizer)
         self.SetAutoLayout(True)

app = wx.App()
frame = wx.Frame(None, -1, "testing static box")
panel = TestPanel(frame)
frame.Show()
app.MainLoop()



C M
Reply | Threaded
Open this post in threaded view
|

Re: wx.StaticBox - can't click on any controls

C M
After I made sure it was indented right, It works for me perfectly.
I'm with Python 2.5, wxPython 2.8.4.2, but using WinXP instead
of Mac.

On 8/30/07, Robert Gravina <[hidden email]> wrote:
The code below displays a panel with a  wx.StaticBox with a wx.Choice
inside it. For some reason, clicking on the dropdown does nothing.
Can anyone spot the problem?

I am using Python 2.5, wxPython 2.8.4.2 on Mac OS 10.4.10

Robert
-------------------------
import wx

class TestPanel(wx.Panel):
     def __init__(self, parent):
        wx.Panel.__init__(self, parent)
         self.cmb = wx.Choice(self, size=wx.Size(100,-1), choices=
["test1", "test2", "test3"])
         sizer = wx.BoxSizer(wx.VERTICAL)
         box = wx.StaticBox(self, label="Test SaticBox")
         sizerInner = wx.StaticBoxSizer(box, wx.VERTICAL)
         sizerInner.Add(self.cmb)
         sizer.Add(sizerInner)
         self.SetSizer(sizer)
         self.SetAutoLayout(True)

app = wx.App ()
frame = wx.Frame(None, -1, "testing static box")
panel = TestPanel(frame)
frame.Show()
app.MainLoop()


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: wx.StaticBox - can't click on any controls

Cody Precord
In reply to this post by Robert Gravina
This is a very strange problem that I struggled with the other day too. I found out that if you define the StaticBox and StaticBoxSizer before the controls you want to put in it then everything will work fine. 

Cody

On Aug 30, 2007, at 7:29 PM, Robert Gravina wrote:

import wx

class TestPanel(wx.Panel):

    def __init__(self, parent):

    wx.Panel.__init__(self, parent)

        self.cmb = wx.Choice(self, size=wx.Size(100,-1), choices=["test1", "test2", "test3"])

        sizer = wx.BoxSizer(wx.VERTICAL)

        box = wx.StaticBox(self, label="Test SaticBox")

        sizerInner = wx.StaticBoxSizer(box, wx.VERTICAL)

        sizerInner.Add(self.cmb)

        sizer.Add(sizerInner)

        self.SetSizer(sizer)

        self.SetAutoLayout(True)


app = wx.App()

frame = wx.Frame(None, -1, "testing static box")

panel = TestPanel(frame)

frame.Show()

app.MainLoop()


Reply | Threaded
Open this post in threaded view
|

Re: wx.StaticBox - can't click on any controls

Robert Gravina

On Aug 31, 2007, at 12:39 PM, Cody Precord wrote:

> This is a very strange problem that I struggled with the other day  
> too. I found out that if you define the StaticBox and  
> StaticBoxSizer before the controls you want to put in it then  
> everything will work fine.
>

Thankyou, you were right! Works now!

Robert



Reply | Threaded
Open this post in threaded view
|

Re: wx.StaticBox - can't click on any controls

Robin Dunn
In reply to this post by Cody Precord
Cody Precord wrote:
> This is a very strange problem that I struggled with the other day too.
> I found out that if you define the StaticBox and StaticBoxSizer before
> the controls you want to put in it then everything will work fine.

Yes, this is required.  The static box must be created before the
widgets that it will 'contain'.

--
Robin Dunn
Software Craftsman
http://wxPython.org  Java give you jitters?  Relax with wxPython!