wxpython wxgrid question

rbann11 at hotmail.com rbann11 at hotmail.com
Fri Jun 9 17:43:59 EDT 2006


jean-michel bain-cornu wrote:
> rbann11 at hotmail.com a écrit :
> > Tim Roberts wrote:
> >> rbann11 at hotmail.com wrote:
> >>>  I am looking for example code that consists of just a frame and a
> >>> grid(10x2).  The grid must fill the its parent even if the frame is
> >>> resized.
> >> Have you gone through the wxPython demo application?  It contains examples
> >> of every standard control and almost every behavior you might want.
> >> --
> >> - Tim Roberts, timr at probo.com
> >>   Providenza & Boekelheide, Inc.
> >
> > Yes, and i have even checked out "wxpython in action".  All of the
> > examples tend to leave white space on the right of the frame.  I tried
> > basic a example with sizers and it didnt work.  That why I was
> > wondering if someone had got it to work.
> >
> >
> >    Roger
> >
> Hi Roger,
> A key point is that the Grid manages itself its available space
> according to the size it can have.
> If you just tried to create a simple grid within a simple frame, you
> probably got a grid filling all the frame space, and it's what you want.
> Why that ?
> If you do it (for instance with the script below), and you try to
> manually reduce/increase the size of the window, you should see
> scrollbars at the edge of the window ; these scrollbars come from the
> grid, because they take in account the labels row and col (wxGrid comes
> from wxScrolledWindow). You can see that no more space is available
> beyond the scrollbar, so the grid takes the whole space.
> And why the white space on the right ? This space is not on the right of
> the grid, but on the right of the last col. We could think it's like
> that because it's not possible to compute an appropriate col size for
> the grid cols, but it's not displayed exactly the same in linux and in
> windows. In one case it's over the last col (not enough space) and in
> the other case it's beyond (too much space). I think that as the program
> must work on all the environments, the interface must stay enough
> global, and sometimes the display is not perfectly done.
> The advantage is that if we let wx decide, we won't have to think how to
> set the widgets.
> Regards,
> jm
>
> #----------------------------------------------------------------------
> import wx,wx.grid
> #----------------------------------------------------------------------
> class MainWindow(wx.Frame):
>      def __init__(self,parent,id,title):
>          wx.Frame.__init__(self,parent,wx.ID_ANY,title)
>          #--
>          self.grid= wx.grid.Grid(id=wx.ID_ANY,parent=self)
>          self.grid.CreateGrid(numRows=10,numCols=2)
>          self.grid.Fit()
>          self.Fit()
>          #--
>          self.Show(1)
> #----------------------------------------------------------------------
> app = wx.PySimpleApp()
> frame=MainWindow(None,-1,'Grid sizer')
> app.MainLoop()
> del app
> #----------------------------------------------------------------------

Thanks Tim,

  I knew it was something like that, but I had to ask the question. I
was hoping that there was a way around the problem.

  Roger




More information about the Python-list mailing list