wx.Notebook Layout Wierdness?

Hello Massimiliano,

      I hope you won't find a bug in your application in the future :wink: I
don't know if your coding is forced by the design of your app, but it is
quite hard to follow and complicated to analyse. Finding and fixing a bug
is almost impossible (at least for me) following your disegn code.
However, everyone has its own coding style :wink:

If I understood you correctly, you would like to have the buttons aligned
to the right. In order to have such a thing, you should prepend a
stretchable spacer *before* the button. If you add to your sizer only the
buttons, wxPython has no way to interpret your wx.ALIGN_RIGHT. Align right
with respect to what? So, I added this line to your code:

nvgSizer = wx.BoxSizer (wx.HORIZONTAL)

# THIS LINE
nvgSizer.Add((1,0), 1, wx.EXPAND)

AddButton (nvgSizer, '|<')
AddButton (nvgSizer, '<')
AddButton (nvgSizer, '>')
AddButton (nvgSizer, '>|')

And now it works as expected. But probably I did not understand your
problem correctly.

HTH.

Andrea.

···

_______________________________________________
Andrea Gavana
Reservoir Engineer
MOGI ? Reservoir Characterization and Modeling Dept.
ENI S.p.A. ? Exploration & Production Division
Via Emilia, 1 ? 20097 San Donato Milanese (MI) ? Italy
Phone: +39 02 520 62972
Fax: +39 02 520 61824
E-mail: andrea.gavana@agip.it
Restyled Internet Site: http://xoomer.virgilio.it/infinity77/
____________________________________________________

Eni S.p.A.
Sede legale in Roma,
Piazzale Enrico Mattei 1, 00144 Roma
Tel. centralino: +39 06598.21
www.eni.it
Capitale sociale € 4.002.934.326 i.v.
Registro Imprese di Roma,
Codice Fiscale 00484960588
Part. IVA 00905811006
R.E.A. Roma n. 756453

Hello Massimiliano,

      I hope you won't find a bug in your application in the future :wink: I
don't know if your coding is forced by the design of your app, but it is
quite hard to follow and complicated to analyse. Finding and fixing a bug
is almost impossible (at least for me) following your disegn code.
However, everyone has its own coding style :wink:

Hello Andrea,
   First of all thanks very much to have at least give it a try :slight_smile:
   You are perfectly right about the code, but it is the result of
   a merge of almost a dozen of classes/subclasses in a twentieth
   of file: it has been the best I managed to do :expressionless:

If I understood you correctly, you would like to have the buttons aligned
to the right. In order to have such a thing, you should prepend a
stretchable spacer *before* the button. If you add to your sizer only the
buttons, wxPython has no way to interpret your wx.ALIGN_RIGHT. Align right
with respect to what?

   You are perfectly right, but the problem to me is quite different:
   I need it works with the line

NAVIGATOR_PROP = 0

   for I do not want it to be growable: I need all the space to be
   left for the label, id est:
   - Label on the left, btnpanel on the right
   - btnpanel has only the space it actually needs
   - label has all the space left

   The question is that it all worked fine until I ported from
   Python 2.2 and wxPython 2.4.2 to Python 2.4 and wxPython 2.6.1
   so I suppose it is something that changed in wxSizer minSize
   and best size management.
   Thanks in advance for you kind attention

···

andrea.gavana@agip.it wrote:

----
   Massimiliano Sartor
   - Hyperborea s.c. -
   Via Giuntini n. 13
   56023 Navacchio(PI)
   050754246-050754241

I found a new hint: I worked on the code trying to
cut out the most of it and I reached a more readable
snippet (on the bottom).

What I found is that the suspected seems to be
the SetScrollBars instruction !!?!
If you comment it out, all seems to works fine
but there are no scrollbars at all in any situation.
If you leave those lines the navigator fades away.

I feel the solution is near but I still can't get it.

Thanx again in advance to everybody helping

···

------------------------------------------------------

import wx

NAVIGATOR_FLAG = wx.GROW|wx.ALIGN_RIGHT|wx.RIGHT
NAVIGATOR_PROP = 0

class testsizerFrm (wx.Frame):
     def __init__ (self, parent):
         wx.Frame.__init__(self, parent, wx.NewId(), 'test notebook sizing')
         mainSizer = wx.BoxSizer(wx.VERTICAL)
         nb = myScheda (self)
         mainSizer.Add(nb, proportion= 1, flag=wx.EXPAND, border=0)
         self.SetSizer (mainSizer)
         self.SetAutoLayout (True)

class myScheda (wx.Notebook):
     def __init__ (self, parent):
         wx.Notebook.__init__(self, parent, wx.NewId(), style=wx.NB_BOTTOM)
         self.SetBackgroundColour(wx.Colour(255, 255, 200))

         page = wx.ScrolledWindow(self, wx.NewId(), style=wx.TAB_TRAVERSAL)
         pageSzr = wx.FlexGridSizer (2, 1)
         pageSzr.AddGrowableCol(0)

         parent = page
         #First of all build static box section wrapper
         sb = wx.StaticBox(parent, wx.NewId())
         #Then build sizer on that static box
         sbSzr = wx.StaticBoxSizer(sb, wx.VERTICAL)
         #Sizer for header, horizontal box is enough
         hdrSzr = wx.BoxSizer(wx.HORIZONTAL)
         #Add label to header
         lbl = wx.StaticText(parent, wx.NewId(), label='---SECTION TITLE----')
         hdrSzr.Add(lbl, flag=wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, proportion=1, border=2)
         lbl.SetBackgroundColour(wx.Colour(200, 200, 100))
         nvg = myNavigator (parent)
         nvg.SetBackgroundColour(wx.RED)
         hdrSzr.Add(nvg, flag=NAVIGATOR_FLAG, proportion=NAVIGATOR_PROP, border=10)
         #Add header to container
         sbSzr.Add (hdrSzr, 0, wx.GROW,0)
         #Add container to parent sizer
         pageSzr.Add(sbSzr, 1, wx.GROW,0)

         page.SetSizer (pageSzr)
         self.AddPage(page, 'NOTEBOOK PAGE')
         page.Layout()
         ####################################
         ### THESE LINES !!#################
         ####################################
         size = page.GetSizer().GetMinSize()
         page.SetScrollbars(5, 5, size.x/5, size.y/5, 0, 0, True)
         ####################################

class myNavigator(wx.Panel):
     """extremely simplified:just a panel with some buttons."""
     def __init__(self, parent):
         wx.Panel.__init__(self, parent, 0)
         def AddButton (sizer, label):
             btn = wx.Button (self, wx.NewId(), label=label, size=wx.Size(20, 20))
             sizer.Add (btn, flag=wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, proportion=0, border=0)

         nvgSizer = wx.BoxSizer (wx.HORIZONTAL)
         AddButton (nvgSizer, '|<')
         AddButton (nvgSizer, '<')
         AddButton (nvgSizer, '>')
         AddButton (nvgSizer, '>|')
         self.SetAutoLayout (True)
         self.SetSizer (nvgSizer)
         nvgSizer.Fit (self)

class myApp(wx.App):
     def OnInit (self):
         testsizerFrm(None).Show()
         return True

myApp(0).MainLoop()

----
   Massimiliano Sartor
   - Hyperborea s.c. -
   Via Giuntini n. 13
   56023 Navacchio(PI)
   050754246-050754241