[wxPython] Howto 2 wxGrids in one panel

Hello again,

for a database appl., I would like to place 2 grids on
one notebook page. The first problem is: when I derive
the splitter from a wxFrame, resize events are send
the the underlying grids. But to be able to put the 2
grids on a notebook page, I need to place them in a
wxPanel (do I?). But then, the grids get no resize
events.

The second problem is: is there a way to switch the
focus frame on and off? It would make those 2 grids
much more user friendly.

Does anybody have an idea, how to differentiate those
2 grids inside an event handler, beside sub classing?

Thanks for listening
Pete

gt.py (2.21 KB)

···

--
ATTENTION: You have moved your mouse!
Please reboot to make this change take effect...

First problem solved myself(tm):

--- gt.py~ Wed Nov 22 14:52:09 2000
+++ gt.py Wed Nov 22 16:53:33 2000
@@ -47,10 +47,12 @@
        split.SplitHorizontally(grid1, grid2, 220)
        grid1.Refresh()
        grid2.Refresh()
+ self.split = split
        EVT_SIZE(self, self.OnSize)

     def OnSize(self, evt):
        print evt, self.parent.GetClientSize()
+ self.split.SetClientSize(self.parent.GetClientSize())
        evt.Skip()

which let the following question arise: why does wxSplitterWindow()
not take it's parent client space automatically, if it`s a wxPanel.
I should mention, that when omitting the size attributs of the
splitter instance, it renders itself useless.

Rest of questions remain unsolved.

Cheers
FrisPete

···

--
The most effective way to solve problems is: Think! (Hans-Peter Jansen)

_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/mailman/listinfo/wxpython-users

Hi, once again,

3rd version, now really based on a notebook, because this
shows a problem with sliders. In fact, both grids only have
one slider, one horizontal, the other vertical. Robin?!?

Pete

gt.py (2.21 KB)

for a database appl., I would like to place 2 grids on
one notebook page. The first problem is: when I derive
the splitter from a wxFrame,

Not sure what you mean by this, but it probably doesn't matter now that
you've got your third attempt almost working...

resize events are send
the the underlying grids. But to be able to put the 2
grids on a notebook page, I need to place them in a
wxPanel (do I?).

No, you can put the splitter window directly into the notebook. A notebook
page can be any class derived directly or indirectly from wxWindow.

But then, the grids get no resize
events.

Because the wxPanel doesn't have hany default rules to manage the layout of
its children, some window classes do. For example, if a wxFrame has only
one child it will resize it to fill the client area when it gets a size
event, a wxNoteBook will resize each page to fit the page area, a wxSplitter
will resize its two children to fill each side of the splitter, etc.

Other window classes leave it up to you to either tell it how to manage
layout of the children, or expect you to do it yourself. You can either
provide an EVT_SIZE handler that sizes and positions each child explicitly,
or you can use something like sizers or layout constraints and call
SetAutoLayout(true).

In your case (in the first sample you sent) the wxNotebook is resizing the
panel just fine, but you didn't tell the panel how to resize it's children
so it does nothing.

The second problem is: is there a way to switch the
focus frame on and off? It would make those 2 grids
much more user friendly.

I'm not sure what you mean by this. The thick border around the active
cell? If so then I don't think there is a way to do it currently. I don't
think it would be too hard to do, you could enter it as a feature request in
the bug tracker and it will probably show up someday.

Does anybody have an idea, how to differentiate those
2 grids inside an event handler, beside sub classing?

The event object passed to the handler should have the window ID of the grid
that generated the event. You can either use a single handler and get the
ID from the event object and differentiate that way, or use two different
handlers and self.Connect(...) instead of EVT_GRID_* and give the ID
explicitly...

3rd version, now really based on a notebook, because this
shows a problem with sliders. In fact, both grids only have
one slider, one horizontal, the other vertical. Robin?!?

When you say sliders, do you mean the scrollbars? They are partially
obscured when I run the program... That can be fixed by changing your
panel's OnSize to be like this:

    def OnSize(self, evt):
        self.split.SetSize(self.GetSize())

which sets the splitter to be the same size as the panel. As I mentioned
above, you can also put the splitter into the notebook directly without the
panel and then you wouldn't have to mess with size handlers at all.

···

--
Robin Dunn
Software Craftsman
robin@AllDunn.com
http://wxPython.org Java give you jitters?
http://wxPROs.com Relax with wxPython!

_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/mailman/listinfo/wxpython-users