Robin Dunn wrote:
Stuart wrote:
[...]
Robin, thank you for the excellent explanation of cause
and fix of the scrollbar anomaly in the grid control when
loaded via an xrc "unknown" control.
A probably better way to take care of this is to not use the unknown
control feature at all. You can use a normal grid class type in the
XRC, and set the subclass attribute to the modulename.classname of your
grid class. That causes the subclass factory to create an instance of
the class, but in all other ways it will be treated as a wx.grid.Grid.
Then there won't be any mysterious container panel created behind the
scenes for you to get in the way. This takes a little tweaking of the
class that will be loaded this way, see the demo for an example.
Yes, I will try doing that next. But since the current code
is so close to working, I want to finish it, if only for my
notes.
The reason there is no sizer in panel2 is that in the
real app, there is also an html control in there,
overlapping the grid, and I will hide one of the other
according to conditions, as per
http://lists.wxwidgets.org/archive/wxPython-users/msg14336.html
Would an "overlap sizer" be a useful addition to wxwidgets?
Most people do this simply by putting all of their page windows into a box sizer, and then hiding all but the one they want shown. When you want to show a different page then just show it, hide the old one and call the sizer's Layout method.
Ahh, it didn't occur to me that the sizer would take the
control's visibility into account but it makes sense that
it would.
I tried follow your suggestion and it almost works but I still
have something wrong. I have an htmlwindow control and an
xrc.AttachUnknownControl attached Grid subclass in the same sizer,
and a button to change their Show() states so that when one is
shown the other is hidden.
One problem is that (as you pointed out in the previous response)
the Grid control is placed in an additional Panel created by the
xrc loader. So I found I had to show/hide that panel rather
than the grid itself, which I do by calling grid.GetParent().Show()
I suppose this is brittle in that XRC might decide to arrange things
differently someday. Is there any better way?
The second bigger (and remaining) problem is that the shown control
is not resized correctly after the show status of the grid and
htmlwindow are swapped (when the Chng View view button in the
sample code is clicked), but, as soon as the frame size is changed,
the shown control is properly resized and everything looks right.
I call the frame's Layout method but it doesn't help. I also
tried to generate a synthetic resize event with various permutation
of ProcessEvent() and CallAfter() but also with no luck, so again
I could use some help.
Attached are the files overlay.py and overlay.xrc. The problem
is evident when the Chng View button is clicked after starting or
after resizing the frame.
BTW, thanks for pointer the InspectionTool, it is fantastic.
Perhaps I am the only person who didn't know about it but in
case there are others, here are my cheat-sheet cut'n'paste notes
on using it, in hopes it will save someone a couple minutes.
...
import wx.lib.inspection as wxi
...
app = wx.Application (...)
wxi.InspectionTool().Show()
app.MainLoop ()
I also wrote in the original post:
I think a notebook control would also work well if I could
get rid of the tabs and control page switching from buttons
and menus. Is getting rid of the tabs possible?
Can I take the lack of an affirmative answer as a negative one?
I looked in the docs and demos and didn't notice anything that
suggested this was doable, but the waters of wxPython run deep...
overlay.py (3.73 KB)
overlay.xrc (1.29 KB)