expandable grid/table?

thanks in advance

this is what i want:
http://www.lusiya.com/ofstar/attachments/9_1120_1240195219.gif , you
can find the layout struct as
http://www.lusiya.com/ofstar/attachments/9_1120_1240195840.gif
1. I want the upper grid to expand at x-direction, so when I resize
the whole dlg, it autofills horizontally
2.the colomns of the cell table keep their propotion when resize,
until I drag its width; the dragged width propotion keeps till another
drag
3.the upper gird is shown when this dlg is shown

but when I run the python code(at the end of my mail), what I get is
http://www.lusiya.com/ofstar/attachments/9_1120_1240195284.gif , as
you can see, the grid is not here!

So I have to resize the dlg, then I get
http://www.lusiya.com/ofstar/attachments/9_1120_1240195383.gif , that
is not what I desired, since the table in gird only takes a little
space on the x-direction. At the same time, there are too many white
space on the bottom for the grid( I want it to show several rows)

I can drag the column width to
http://www.lusiya.com/ofstar/attachments/9_1120_1240195448.gif , but
don't know how to deal with the extra space at the bottom

Any hints?

[code]
#!/usr/bin/env python
# -*- coding: iso-8859-15 -*-
# generated by wxGlade 0.6.3 on Mon Apr 20 09:56:44 2009

import wx
import wx.grid

# begin wxGlade: extracode
# end wxGlade

class MyDialog(wx.Dialog):
    def __init__(self, *args, **kwds):
        # begin wxGlade: MyDialog.__init__
        kwds["style"] =
wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER|wx.THICK_FRAME|wx.FULL_REPAINT_ON_RESIZE
        wx.Dialog.__init__(self, *args, **kwds)
        self.grid_1 = wx.grid.Grid(self, -1, size=(1, 1))
        self.static_line_1 = wx.StaticLine(self, -1)
        self.label_1 = wx.StaticText(self, -1, "Name")
        self.text_ctrl_1 = wx.TextCtrl(self, -1, "")
        self.label_2 = wx.StaticText(self, -1, "Birthday")
        self.text_ctrl_2 = wx.TextCtrl(self, -1, "")
        self.label_3 = wx.StaticText(self, -1, "E-mail")
        self.text_ctrl_3 = wx.TextCtrl(self, -1, "")

        self.__set_properties()
        self.__do_layout()
        # end wxGlade

    def __set_properties(self):
        # begin wxGlade: MyDialog.__set_properties
        self.SetTitle("dialog_1")
        self.grid_1.CreateGrid(1, 2)
        self.grid_1.SetColLabelValue(0, "Name")
        self.grid_1.SetColLabelValue(1, "Birthday")
        # end wxGlade

    def __do_layout(self):
        # begin wxGlade: MyDialog.__do_layout
        grid_sizer_1 = wx.FlexGridSizer(3, 1, 0, 0)
        grid_sizer_2 = wx.FlexGridSizer(3, 2, 0, 0)
        grid_sizer_1.Add(self.grid_1, 1, wx.EXPAND, 0)
        grid_sizer_1.Add(self.static_line_1, 0, wx.EXPAND, 0)
        grid_sizer_2.Add(self.label_1, 0, wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer_2.Add(self.text_ctrl_1, 0, wx.EXPAND, 0)
        grid_sizer_2.Add(self.label_2, 0, wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer_2.Add(self.text_ctrl_2, 0, wx.EXPAND, 0)
        grid_sizer_2.Add(self.label_3, 0, wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer_2.Add(self.text_ctrl_3, 0, wx.EXPAND, 0)
        grid_sizer_2.AddGrowableRow(0)
        grid_sizer_2.AddGrowableRow(1)
        grid_sizer_2.AddGrowableRow(2)
        grid_sizer_2.AddGrowableCol(1)
        grid_sizer_1.Add(grid_sizer_2, 1, wx.EXPAND, 0)
        self.SetSizer(grid_sizer_1)
        grid_sizer_1.Fit(self)
        grid_sizer_1.AddGrowableRow(0)
        grid_sizer_1.AddGrowableRow(2)
        grid_sizer_1.AddGrowableCol(0)
        self.Layout()
        # end wxGlade

# end of class MyDialog

class MyApp(wx.App):
    def OnInit(self):
        wx.InitAllImageHandlers()
        dialog_1 = MyDialog(None, -1, "")
        self.SetTopWindow(dialog_1)
        dialog_1.Show()
        return 1

# end of class MyApp

if __name__ == "__main__":
    app = MyApp(0)
    app.MainLoop()
[/code]

thanks in advance

this is what i want:

http://www.lusiya.com/ofstar/attachments/9_1120_1240195219.gif , you

can find the layout struct as

http://www.lusiya.com/ofstar/attachments/9_1120_1240195840.gif

  1. I want the upper grid to expand at x-direction, so when I resize

the whole dlg, it autofills horizontally

It is already resizing–what do you mean by autofill?

2.the colomns of the cell table keep their propotion when resize,

until I drag its width; the dragged width propotion keeps till another

drag

I don’t think they track proportion, just absolute column width. They
do retain that reset width, do they not?

3.the upper gird is shown when this dlg is shown

See below…

but when I run the python code(at the end of my mail), what I get is

http://www.lusiya.com/ofstar/attachments/9_1120_1240195284.gif , as

you can see, the grid is not here!

Just comment out this line:
grid_sizer_1.Fit(self)

So I have to resize the dlg, then I get

http://www.lusiya.com/ofstar/attachments/9_1120_1240195383.gif , that

is not what I desired, since the table in gird only takes a little

space on the x-direction. At the same time, there are too many white

space on the bottom for the grid( I want it to show several rows)

If you want to show several blank rows, you can just create a much larger
grid, with more rows and columns. If it runs off the available space, it will
show scrollbars.

I can drag the column width to

http://www.lusiya.com/ofstar/attachments/9_1120_1240195448.gif , but

don’t know how to deal with the extra space at the bottom

That extra space is the part of the wxGrid where there are no futher rows.
You could just add more rows, or make the height of the wxGrid smaller.

I had trouble following your sizers scheme. I’d simplify and just put a

vertical BoxSizer, and put the grid in the top part and a flexGridSizer
in the bottom.

You might also just think about using a ListCtrl in report mode
instead of a wxGrid, particularly with the ListCtrlAutoWidthMixin,

which does expandable columns. I was recently told about that on
this list and it is working well for me (the last column expands width
to take up available space). But the listCtrl doesn’t allow renderers,

AFAIK, so if you need that, use the Grid.

···

On Sun, Apr 19, 2009 at 11:03 PM, oyster lepto.python@gmail.com wrote:

Any hints?


#!/usr/bin/env python

# -*- coding: iso-8859-15 -*-

# generated by wxGlade 0.6.3 on Mon Apr 20 09:56:44 2009



import wx

import wx.grid



# begin wxGlade: extracode

# end wxGlade







class MyDialog(wx.Dialog):

    def __init__(self, *args, **kwds):

        # begin wxGlade: MyDialog.__init__

        kwds["style"] =

wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER|wx.THICK_FRAME|wx.FULL_REPAINT_ON_RESIZE

        wx.Dialog.__init__(self, *args, **kwds)

        self.grid_1 = wx.grid.Grid(self, -1, size=(1, 1))

        self.static_line_1 = wx.StaticLine(self, -1)

        self.label_1 = wx.StaticText(self, -1, "Name")

        self.text_ctrl_1 = wx.TextCtrl(self, -1, "")

        self.label_2 = wx.StaticText(self, -1, "Birthday")

        self.text_ctrl_2 = wx.TextCtrl(self, -1, "")

        self.label_3 = wx.StaticText(self, -1, "E-mail")

        self.text_ctrl_3 = wx.TextCtrl(self, -1, "")



        self.__set_properties()

        self.__do_layout()

        # end wxGlade



    def __set_properties(self):

        # begin wxGlade: MyDialog.__set_properties

        self.SetTitle("dialog_1")

        self.grid_1.CreateGrid(1, 2)

        self.grid_1.SetColLabelValue(0, "Name")

        self.grid_1.SetColLabelValue(1, "Birthday")

        # end wxGlade



    def __do_layout(self):

        # begin wxGlade: MyDialog.__do_layout

        grid_sizer_1 = wx.FlexGridSizer(3, 1, 0, 0)

        grid_sizer_2 = wx.FlexGridSizer(3, 2, 0, 0)

        grid_sizer_1.Add(self.grid_1, 1, wx.EXPAND, 0)

        grid_sizer_1.Add(self.static_line_1, 0, wx.EXPAND, 0)

        grid_sizer_2.Add(self.label_1, 0, wx.ALIGN_CENTER_VERTICAL, 0)

        grid_sizer_2.Add(self.text_ctrl_1, 0, wx.EXPAND, 0)

        grid_sizer_2.Add(self.label_2, 0, wx.ALIGN_CENTER_VERTICAL, 0)

        grid_sizer_2.Add(self.text_ctrl_2, 0, wx.EXPAND, 0)

        grid_sizer_2.Add(self.label_3, 0, wx.ALIGN_CENTER_VERTICAL, 0)

        grid_sizer_2.Add(self.text_ctrl_3, 0, wx.EXPAND, 0)

        grid_sizer_2.AddGrowableRow(0)

        grid_sizer_2.AddGrowableRow(1)

        grid_sizer_2.AddGrowableRow(2)

        grid_sizer_2.AddGrowableCol(1)

        grid_sizer_1.Add(grid_sizer_2, 1, wx.EXPAND, 0)

        self.SetSizer(grid_sizer_1)

        grid_sizer_1.Fit(self)

        grid_sizer_1.AddGrowableRow(0)

        grid_sizer_1.AddGrowableRow(2)

        grid_sizer_1.AddGrowableCol(0)

        self.Layout()

        # end wxGlade



# end of class MyDialog





class MyApp(wx.App):

    def OnInit(self):

        wx.InitAllImageHandlers()

        dialog_1 = MyDialog(None, -1, "")

        self.SetTopWindow(dialog_1)

        dialog_1.Show()

        return 1



# end of class MyApp



if __name__ == "__main__":

    app = MyApp(0)

    app.MainLoop()

wxpython-users mailing list

wxpython-users@lists.wxwidgets.org

http://lists.wxwidgets.org/mailman/listinfo/wxpython-users