Python

NAVIGATION
CATEGORIES
REFERRENCE
LINKS
  • ListCtrl and sizers

    5 answers - 924 bytes - related search similar search Add To My Delicious Add To My Stumble Upon Add To My Google Mark Add To My Facebook Add To My Digg Add To My Reddit

    Hi *,
    I have a listctrl centered inside a boxsizer, and when I resize
    the window the list expands only on the right (yuk!), and I want it to
    expand on both sides.
    def allUsers (self, data):
    box = wx.BoxSizer (wx.VERTICAL)
    list = wx.ListCtrl (
    self.edit_panel, -1, style = wx.LC_REPRT | wx.SUNKEN_BRDER)
    list.InsertColumn (-1, "Username")
    list.InsertColumn (-1, "Nome")
    list.InsertColumn (-1, "Cognome")
    list.InsertColumn (-1, "Telefono")
    list.InsertColumn (-1, "Fax")
    for u in data:
    username = list.InsertStringItem (0, u [0])
    name = list.SetStringItem (0, 1, u [1])
    surname = list.SetStringItem (0, 2, u [2])
    telephone = list.SetStringItem (0, 3, u [3])
    fax = list.SetStringItem (0, 4, u [4])
    box.Add (list, 0, wx.EXPAND | wx.ALL | wx.ALIGN_CENTER_VERTICAL, 15)
    self.edit_panel.SetSizer (box)
    self.edit_panel.Layout ()
    TIA,
    ngw
  • No.1 | | 456 bytes | |

    Please put this code in a small, self contained, working example, so we
    can run it and see what you're talking about. Also, it's then easy to
    make a quick modification and test it before making a suggestion.

    Also give your version and platform info.

    Nicholas Wieland wrote:
    the window the list expands only on the right (yuk!)

    I don't' really understand what this means? is it no longer centered?
    -Chris
  • No.2 | | 1390 bytes | |

    - Chris Barker :
    Please put this code in a small, self contained, working example, so we
    can run it and see what you're talking about. Also, it's then easy to
    make a quick modification and test it before making a suggestion.

    , sorry

    import wx

    class Foo (wx.Frame):

    def __init__ (self, parent):
    wx.Frameinit__ (self, parent, -1, size = (700,500))
    box = wx.BoxSizer (wx.VERTICAL)
    list = wx.ListCtrl (self, -1, style = wx.LC_REPRT|wx.SUNKEN_BRDER)
    list.InsertColumn (-1, "Foo")
    list.InsertColumn (-1, "Bar")
    list.InsertStringItem (0, "Yada")
    list.SetStringItem (0, 0, "Yada")
    box.Add (list, 0, wx.EXPAND|wx.ALL|wx.ALIGN_CENTER_VERTICAL, 15)
    self.SetSizer (box)
    self.Layout ()

    class MyApp (wx.App):

    def Init (self):
    frame = Foo (None)
    self.SetTopWindow (frame)
    frame.Show (True)
    return True

    app = MyApp ()
    app.MainLoop ()

    Also give your version and platform info.

    WxWPython 2.6.1.0, Python 2.4.2 on FreeBSD 6.0.

    >the window the list expands only on the right (yuk!)


    I don't' really understand what this means? is it no longer centered?

    I mean the whole widget. I'd like it to stay on the center instead of
    expanding on the right. Maybe it should expand the column labels.

    ngw
  • No.3 | | 2191 bytes | |

    Hi Nicholas,

    What about this way? See attached, I used a second sizer.

    See you
    Werner

    Nicholas Wieland wrote:
    - Chris Barker :

    >
    >>Please put this code in a small, self contained, working example, so we
    >>can run it and see what you're talking about. Also, it's then easy to
    >>make a quick modification and test it before making a suggestion.

    >
    >>

    >
    >, sorry
    >
    >import wx
    >
    >class Foo (wx.Frame):
    >

    def __init__ (self, parent):
    wx.Frameinit__ (self, parent, -1, size = (700,500))
    box = wx.BoxSizer (wx.VERTICAL)
    list = wx.ListCtrl (self, -1, style = wx.LC_REPRT|wx.SUNKEN_BRDER)
    list.InsertColumn (-1, "Foo")
    list.InsertColumn (-1, "Bar")
    list.InsertStringItem (0, "Yada")
    list.SetStringItem (0, 0, "Yada")
    box.Add (list, 0, wx.EXPAND|wx.ALL|wx.ALIGN_CENTER_VERTICAL, 15)
    self.SetSizer (box)
    self.Layout ()
    >
    >
    >class MyApp (wx.App):
    >

    def Init (self):
    frame = Foo (None)
    self.SetTopWindow (frame)
    frame.Show (True)
    return True
    >
    >
    >app = MyApp ()
    >app.MainLoop ()
    >


    >
    >>Also give your version and platform info.

    >
    >>

    >
    >WxWPython 2.6.1.0, Python 2.4.2 on FreeBSD 6.0.
    >


    the window the list expands only on the right (yuk!)


    >>I don't' really understand what this means? is it no longer centered?

    >
    >>

    >
    >I mean the whole widget. I'd like it to stay on the center instead of
    >expanding on the right. Maybe it should expand the column labels.
    >

    ngw

    To unsubscribe, e-mail: wxPython-users-unsubscribe (AT) lists (DOT) wxwidgets.org
    For additional commands, e-mail: wxPython-users-help (AT) lists (DOT) wxwidgets.org
  • No.4 | | 272 bytes | |

    - Werner F. Bruhin :
    Hi Nicholas,
    What about this way? See attached, I used a second sizer.
    Well, it's centered but it doesn't expand anymore :)
    But probably what I asked wasn't really resonable
    Anyway, tank you very much.
    ngw
  • No.5 | | 874 bytes | |

    Hi Nicholas,

    Nicholas Wieland wrote:
    - Werner F. Bruhin :

    >
    >>Hi Nicholas,
    >>
    >>What about this way? See attached, I used a second sizer.

    >
    >>


    >Well, it's centered but it doesn't expand anymore :)


    Yeap, I haven't figured out how to make a listctrl dynamically expand.
    Did you try the "listmix.ListCtrlAutoWidthMixin"?

    See you
    Werner

    >But probably what I asked wasn't really resonable
    >Anyway, tank you very much.
    >

    ngw

    To unsubscribe, e-mail: wxPython-users-unsubscribe (AT) lists (DOT) wxwidgets.org
    For additional commands, e-mail: wxPython-users-help (AT) lists (DOT) wxwidgets.org

Re: ListCtrl and sizers


max 4000 letters.
Your nickname that display:
In order to stop the spam: 8 + 7 =
QUESTION ON "Python"

EMSDN.COM