How would you put a widget on the bottom side of a panel which uses a vertical boxsizer?

Hi,

I have a panel, and I use a vertical box sizer to place widgets on it. I would like to place a gauge bar on the bottom side of the panel:

I try:

import wx
from wx.lib.agw import pygauge as

self.progress_gauge = PG.PyGauge(self, -1, size=(150,5),style=wx.GA_HORIZONTAL)

self.panel_sizer = wx.BoxSizer(wx.VERTICAL)
self.panel_sizer.Add(self.progress_gauge, 0, wx.ALIGN_BOTTOM | wx.ALIGN_CENTER_HORIZONTAL)

but the gauge isn’t placed at the bottom of the panel. Instead, it is placed right below to the other widgets, what should I do?

Hi Steve,

Hi,

I have a panel, and I use a vertical box sizer to place widgets on it. I would like to place a gauge bar on the bottom side of the panel:

What about have:
panel1 with your text, button and calendar and have it expand and proportions=1
panel2 with your gauge bar and have it just expand

If you don't know the WIT yet you might want to give it a try, I use it all the time to fix up sizer related challenges I run into.

http://wiki.wxpython.org/Widget%20Inspection%20Tool

Werner

···

On 7/12/2014 12:18, steve wrote:

Is your panel allowed to grow? You could check that with the WIT.
Werner

···

On 7/12/2014 12:18, steve wrote:

Hi,

      I

try:

      import wx

        from wx.lib.agw import pygauge as



        self.progress_gauge = PG.PyGauge(self, -1,

size=(150,5),style=wx.GA_HORIZONTAL)

        self.panel_sizer = wx.BoxSizer(wx.VERTICAL)

        self.panel_sizer.Add(self.progress_gauge, 0, 

wx.ALIGN_BOTTOM | wx.ALIGN_CENTER_HORIZONTAL)

And I think you might need to use FlexGridSizer, it allows different
size cells, instead of BoxSizer.
Werner

···

On 7/12/2014 12:56, Werner wrote:

Is your panel allowed to grow? You could check that with the WIT.

On 7/12/2014 12:18, steve wrote:

Hi,

        I

try:

        import wx

          from wx.lib.agw import pygauge as



          self.progress_gauge = PG.PyGauge(self, -1,

size=(150,5),style=wx.GA_HORIZONTAL)

          self.panel_sizer = wx.BoxSizer(wx.VERTICAL)

          self.panel_sizer.Add(self.progress_gauge, 0, 

wx.ALIGN_BOTTOM | wx.ALIGN_CENTER_HORIZONTAL)

I think the easiest way to accomplish what you want is to add a dummy element (“Spacer”) with size (0,0) and proportoion 1 to your sizer (see code below). This works especially well if all other elements have a proportion of 0.

add calendar to sizer here

self.panel_sizer.Add((0,0), 1, wx.EXPAND)

add gauge to sizer here

···

On Saturday, July 12, 2014 12:18:20 PM UTC+2, steve wrote:

Hi,

I have a panel, and I use a vertical box sizer to place widgets on it. I would like to place a gauge bar on the bottom side of the panel:

did you remember to:

panel.SetSizer(self.panel_sizer)
panel.Layout()

??

But other than that, I would do it with the expandable spacer idea mentioned by nepix32

···

On Saturday, July 12, 2014 6:18:20 AM UTC-4, steve wrote:

Hi,

I have a panel, and I use a vertical box sizer to place widgets on it. I would like to place a gauge bar on the bottom side of the panel:

I try:

import wx
from wx.lib.agw import pygauge as

self.progress_gauge = PG.PyGauge(self, -1, size=(150,5),style=wx.GA_HORIZONTAL)

self.panel_sizer = wx.BoxSizer(wx.VERTICAL)
self.panel_sizer.Add(self.progress_gauge, 0, wx.ALIGN_BOTTOM | wx.ALIGN_CENTER_HORIZONTAL)

but the gauge isn’t placed at the bottom of the panel. Instead, it is placed right below to the other widgets, what should I do?

I’ve had good luck drawing GUI designs on paper by hand, then folding the paper or drawing lines at equal spacings. If I did that to your desired picture that you posted… I think I would have a vertical sizer with the top widgets, then place that in another vertical sizer, add two spacers to that (mySizer.AddStretchSpacer(1)), then add the progress Gauge with wx.ALIGN_BOTTOM.

···

On Saturday, July 12, 2014 3:18:20 AM UTC-7, steve wrote:

Hi,

I have a panel, and I use a vertical box sizer to place widgets on it. I would like to place a gauge bar on the bottom side of the panel:

I try:

import wx
from wx.lib.agw import pygauge as

self.progress_gauge = PG.PyGauge(self, -1, size=(150,5),style=wx.GA_HORIZONTAL)

self.panel_sizer = wx.BoxSizer(wx.VERTICAL)
self.panel_sizer.Add(self.progress_gauge, 0, wx.ALIGN_BOTTOM | wx.ALIGN_CENTER_HORIZONTAL)

but the gauge isn’t placed at the bottom of the panel. Instead, it is placed right below to the other widgets, what should I do?

I’ve had some time to mull it over, and I think the problem is the wx.ALIGN_* flags do not align the widget within the overall spacer, but rather within the area the spacer allocates for the widget. Therefore you’ll only see the effect if the space allocated for that widget is larger than the widget itself.

If all your widgets are put in with proportion 0, they will just be put in “sequentially” whether horizontal or vertical, at their size. And won’t be resized or moved.

Try Add’ing all the widgets into the spacer with proportion 1, expand the frame and see what happens…

···

On Saturday, July 12, 2014 6:18:20 AM UTC-4, steve wrote:

Hi,

I have a panel, and I use a vertical box sizer to place widgets on it. I would like to place a gauge bar on the bottom side of the panel:

I try:

import wx
from wx.lib.agw import pygauge as

self.progress_gauge = PG.PyGauge(self, -1, size=(150,5),style=wx.GA_HORIZONTAL)

self.panel_sizer = wx.BoxSizer(wx.VERTICAL)
self.panel_sizer.Add(self.progress_gauge, 0, wx.ALIGN_BOTTOM | wx.ALIGN_CENTER_HORIZONTAL)

but the gauge isn’t placed at the bottom of the panel. Instead, it is placed right below to the other widgets, what should I do?