Initial sizing problem

I have a layout/view which is basically this.

- Dialog
--- topPane
----- tpane1
----- tpane2
--- bottomPane
----- auiBook (agw)
-------- multiple notebook panes
----- bpane1

The panes will only be loaded with controls after the view is initialised by the controller and all panes and the dialog are from wx.lib.sized_controls.

First run sizing is fine and after that sizing is controlled through the agw.persist framework.

Now if I change to this:
- SizedDialog
--- splitter
----- topPane
------- tpane1
------- tpane2
----- bottomPaneinitial/first load/run
------- auiBook (agw)
---------- multiple notebook panes
------- bpane1

and instead of using SizedPanel for the panes I use the SizedScrolledPanel (see proposed patch for sized_controls a while back) for some of them, the ones which potentially have a "lot" of controls.

Now my initial size is unusable, i.e. the bottomPane is way to small, so I came up with the following which is called by the controller after all controls are loaded.

BTW, after the controls are loaded for each pane I do pane.Layout(), pane.Fit() before DoSizing is called.

     def DoSizing(self):
         max = 0
         for child in (self.paneName, self.paneContact, self.paneAddress,
                       self.paneNotes, self.paneHistory):
             if child.GetVirtualSize()[1] > max:
                 max = child.GetVirtualSize()[1]

         self._auiBook.SetBestSize((-1, max))
         # adjust for the two lines of tabs
         self.splitter.SetSashPosition(-(max+60))

I am back to something acceptable, although I will have to size the topPane and the Dialog accordingly too, but this feels like a hack.

Is there a better/cleaner way to deal with the initial size when using scrolled and splitter control?

I would also to have the topPane grow more then the bottom, so I added this to the DoSizing method:

         self.splitter.SetSashGravity(0.5)

But this means that the auiBook is way too small again on first run of this dialog.

Any one has some tips/hints on what I could do to improve on this.

Werner

Hi Alex,

···

On 10/24/2011 11:54 AM, Alex Hefner wrote:

  Am Montag, 24. Oktober 2011 11:07:08 UTC+2 schrieb > werner:
      I would also to have the topPane grow more then the bottom,

so I added
this to the DoSizing method:

self.splitter.SetSashGravity(0.5)

      But this means that the auiBook is way too small again on

first run of
this dialog.

      Any one has some tips/hints on what I could do to improve on

this.

Werner

    Hi Werner,



    you can solve this problem by using

self.splitter.SetSashPosition(int), so you can calculate or set
a fix value for the sash position on the first run.

That doesn’t work for me.

I tried SetSashPosition(int) before calling SetSashGravity and I

tried it the other way round too.

Werner