Second panel does not show up in wxpython application

Hi,


I want to place 2 panels side by side (horizontally) on another panel, but the second panel does not show up:

import wx
szflags = wx.EXPAND | wx.ALL
min_height = 50
height_ratio = 4
pborder = 10
lborder = 5
    class ChartPanel(wx.Panel):

        def __init__(self, *args, **kwargs):
            wx.Panel.__init__(self, *args, **kwargs)
            self.SetBackgroundColour(wx.Colour(226,226,226))

            self.st = wx.StaticText(self, label='CHART PANEL')
            #self.chart = bar_line.CanvasPanel(self, "320")

            sizer = wx.BoxSizer(wx.VERTICAL)
            sizer.Add(self.st, 1 , szflags , lborder)
            #sizer.Add(self.chart, 1 , szflags)
            self.SetSizer(sizer)

    class NotebookPage(wx.Panel):

        def __init__(self, *args, **kwargs):
            fleet = kwargs.pop('fleet_name', None)
            wx.Panel.__init__(self, *args, **kwargs)

            self.mainPanel = NotebookPage_MainPanel(self, name='Notebook_Page_MainPanel', fleet_name=fleet)
            self.chartPanel = ChartPanel(self, name='Notebook_Page_ChartPanel')

            sizer = wx.BoxSizer(wx.HORIZONTAL)
            sizer.Add(self.mainPanel, 1, wx.EXPAND|wx.ALL,border=10)
            sizer.Add(self.chartPanel, 1, wx.EXPAND|wx.ALL,border=10)
            self.SetSizer(sizer)

Here ChartPanel doesn't show up. What is wrong above?

Hi Steve,

Hi,
  
>I want to place 2 panels side by side (horizontally) on another panel, but the second panel does not show up:
>
Don't know as it does show up for me with the slightly modified code I

attach.

I tested with wxPython Phoenix 3.0.1.dev76271, but I would expect it to behave the same with at least 2.9.5+.

I suspected that it was just too small that is why I used the "WIT" (http://wiki.wxpython.org/Widget%20Inspection%20Tool), just add it to your code and press "ctrl+alt+i" and use the 'Highlight' toolbar button to see what is happening.

Hope this helps
Werner

P.S.
I think that if you attach runnable code you are likelier to get an answer.
http://wiki.wxpython.org/MakingSampleApps

twopanelssidebyside.py (1.27 KB)

···

On 4/14/2014 15:36, steve wrote:

Sir, I used the inspection tool, when I highlight the first child panel , I see that it consumes all main window space (it has red rectangle when I press highlight button). On the other hand, when I try yo highlight second child panel, I don’t see any red rectangles, although the second child panel is listed under the inspection tree.

When I look at the sizes of panels, I see that parent panel has size (840,250), and the position of second child panel is (920,40). Is it a problem?

···

On Monday, April 14, 2014 5:15:52 PM UTC+3, werner wrote:

Hi Steve,

  On 4/14/2014 15:36, steve wrote:

Hi,


I want to place 2 panels side by side (horizontally) on another panel, but the second panel does not show up:

` Don’t know as it does show up for me with the slightly
modified code I attach.

`

`<img src="https://groups.google.com/group/wxpython-users/attach/cd59ae2568988386/fceedgfg.png?part=5&amp;authuser=0" alt="">



  I tested with wxPython Phoenix 3.0.1.dev76271, but I would expect

it to behave the same with at least 2.9.5+.

  I suspected that it was just too small that is why I used the

“WIT” (http://wiki.wxpython.org/Widget%20Inspection%20Tool ), just
add it to your code and press “ctrl+alt+i” and use the ‘Highlight’
toolbar button to see what is happening.

  Hope this helps

  Werner



  P.S.

  I think that if you attach runnable code you are likelier to get

an answer.

  [http://wiki.wxpython.org/MakingSampleApps](http://wiki.wxpython.org/MakingSampleApps)







`

Hi Steve,

Sir,

No Sir needed, Werner will do:-)

I used the inspection tool, when I highlight the first child panel , I see that it consumes all main window space (it has red rectangle when I press highlight button). On the other hand, when I try yo highlight second child panel, I don't see any red rectangles, although the second child panel is listed under the inspection tree.

That indicates that your real code does something different then the code you showed us. I replaced a custom class you had used with a wx.Panel as the custom class was not included, maybe it uses up too much space and so there isn't any for the second panel.

You might want to use e.g. a wx.Splitter to contain the two panels to give the user more control over how space is allocated.

When I look at the sizes of panels, I see that parent panel has size (840,250), and the position of second child panel is (920,40). Is it a problem?

That could be the problem, but it sounds strange to me. Are you sure the parenting is correct, i.e. does it show in the WIT as you expect it to be? Maybe do a parentpanel.Layout() after you added the second child panel.

If you still don't see it do a sample application and I or someone else here will be able to help you.

Werner

···

On 4/14/2014 17:40, steve wrote:

Hi Werner,
I took your suggestion and used a splitter window instead. Then I placed 1 panel on each split. Now it is OK.
However, I want to know how to do it solely with sizers as well. How would you MAKE a panel have a minimum size and adjust its position so that you make sure it is visible?

···

On Monday, April 14, 2014 7:28:26 PM UTC+3, werner wrote:

Hi Steve,

On 4/14/2014 17:40, steve wrote:

Sir,

No Sir needed, Werner will do:-)

I used the inspection tool, when I highlight the first child panel , I
see that it consumes all main window space (it has red rectangle when
I press highlight button). On the other hand, when I try yo highlight
second child panel, I don’t see any red rectangles, although the
second child panel is listed under the inspection tree.

That indicates that your real code does something different then the
code you showed us. I replaced a custom class you had used with a
wx.Panel as the custom class was not included, maybe it uses up too much
space and so there isn’t any for the second panel.

You might want to use e.g. a wx.Splitter to contain the two panels to
give the user more control over how space is allocated.

When I look at the sizes of panels, I see that parent panel has size
(840,250), and the position of second child panel is (920,40). Is it a
problem?

That could be the problem, but it sounds strange to me. Are you sure
the parenting is correct, i.e. does it show in the WIT as you expect it
to be? Maybe do a parentpanel.Layout() after you added the second child
panel.

If you still don’t see it do a sample application and I or someone else
here will be able to help you.

Werner

should do it.
Werner

···

Hi Steve,

  On 4/15/2014 7:54, steve wrote:

Hi Werner,

    I took your suggestion and used a splitter window instead. Then

I placed 1 panel on each split. Now it is OK.

    However, I want to know how to do it solely with sizers as well.

How would you MAKE a panel have a minimum size and
adjust its position so that you make sure it is visible?

http://wxpython.org/Phoenix/docs/html/Window.html?highlight=setminsize#Window.SetMinSize