button positioning

Hello Nicholas,

      try the following code and see if it does what you expect...
Basically, I have added a stretchable spacer *before* the buttons by doing:

h_sizer.Add((1, 0), 1, wx.EXPAND)

And then I have declared that your h_sizer should be expandable in the
horizontal direction inside the v_sizer, with:

v_sizer.Add (h_sizer, 0, wx.EXPAND)

Now the spacer occupies all the left space and the buttons are "right
aligned". Is this what you meant or am I missing something?

HTH.

Andrea.

import wx

class UserPanel (wx.Panel):

  def __init__ (self, parent, id):
    wx.Panel.__init__ (self, parent, id)

    v_sizer = wx.BoxSizer (wx.VERTICAL)

    list = UserList (self, -1)
    v_sizer.Add (list, 1, wx.EXPAND|wx.ALL, 5)

    h_sizer = wx.BoxSizer (wx.HORIZONTAL)

    h_sizer.Add((1, 0), 1, wx.EXPAND)

    addButton = wx.Button (self, -1, "Aggiungi")
    h_sizer.Add (addButton, 0, wx.ALIGN_RIGHT)

    delButton = wx.Button (self, -1, "Cancella")
    h_sizer.Add (delButton, 0, wx.ALIGN_RIGHT)

    v_sizer.Add (h_sizer, 0, wx.EXPAND)

    self.SetSizer (v_sizer)

    self.Layout ()

class UserList (wx.ListCtrl):

  def __init__ (self, parent, id):
    wx.ListCtrl.__init__ (
      self, parent, id, style = wx.LC_REPORT|wx.SUNKEN_BORDER|wx.EXPAND)
    self.populate ()

  def populate (self):
    self.InsertColumn (-1, "Username")
    self.InsertColumn (-1, "Nome")
    self.InsertColumn (-1, "Cognome")
    self.InsertColumn (-1, "Telefono")
    self.InsertColumn (-1, "Fax")

class MyApp (wx.App):

  def OnInit (self):
    f = wx.Frame (None, -1)
    p = UserPanel (f, -1)
    f.Show ()
    return True

app = MyApp ()
app.MainLoop ()

···

_______________________________________________
Andrea Gavana
Reservoir Engineer
MOGI ? Reservoir Characterization and Modeling Dept.
ENI S.p.A. ? Exploration & Production Division
Via Emilia, 1 ? 20097 San Donato Milanese (MI) ? Italy
Phone: +39 02 520 62972
Fax: +39 02 520 61824
E-mail: andrea.gavana@agip.it
Restyled Internet Site: http://xoomer.virgilio.it/infinity77/
____________________________________________________

Eni S.p.A.
Sede legale in Roma,
Piazzale Enrico Mattei 1, 00144 Roma
Tel. centralino: +39 06598.21
www.eni.it
Capitale sociale € 4.002.934.326 i.v.
Registro Imprese di Roma,
Codice Fiscale 00484960588
Part. IVA 00905811006
R.E.A. Roma n. 756453

- andrea.gavana@agip.it :

CUT

Exactly ! Thank you very much !

Ciao,
  ngw

···

--
checking for life_signs in -lKenny... no
  Oh my god, make (1) killed Kenny ! You, bastards !

nicholas_wieland-at-yahoo-dot-it

___________________________________
Yahoo! Mail: gratis 1GB per i messaggi e allegati da 10MB
http://mail.yahoo.it

      try the following code and see if it does what you expect...
Basically, I have added a stretchable spacer *before* the buttons by doing:

h_sizer.Add((1, 0), 1, wx.EXPAND)

And then I have declared that your h_sizer should be expandable in the
horizontal direction inside the v_sizer, with:

v_sizer.Add (h_sizer, 0, wx.EXPAND)

Now the spacer occupies all the left space and the buttons are "right
aligned". Is this what you meant or am I missing something?

HTH.

Andrea.

You do not need to use a stretchable sizer. Just align the h_sizer instead of
the controls it contains. See example below.

HTH

Guido

import wx

class UserPanel (wx.Panel):

  def __init__ (self, parent, id):
    wx.Panel.__init__ (self, parent, id)

    v_sizer = wx.BoxSizer (wx.VERTICAL)

    list = UserList (self, -1)
    v_sizer.Add (list, -1, wx.EXPAND|wx.ALL, 5)

    h_sizer = wx.BoxSizer (wx.HORIZONTAL)

    addButton = wx.Button (self, -1, "Aggiungi")
    # No right_align needed
    h_sizer.Add (addButton, 0)

    delButton = wx.Button (self, -1, "Cancella")
    # No right_align needed
    h_sizer.Add (delButton, 0)

    # align v_sizer
    v_sizer.Add (h_sizer, 0, wx.ALIGN_RIGHT)

    self.SetSizer (v_sizer)

    self.Layout ()

class UserList (wx.ListCtrl):

  def __init__ (self, parent, id):
    wx.ListCtrl.__init__ (
      self, parent, id, style = wx.LC_REPORT|wx.SUNKEN_BORDER|wx.EXPAND)
    self.populate ()

  def populate (self):
    self.InsertColumn (-1, "Username")
    self.InsertColumn (-1, "Nome")
    self.InsertColumn (-1, "Cognome")
    self.InsertColumn (-1, "Telefono")
    self.InsertColumn (-1, "Fax")

class MyApp (wx.App):

  def OnInit (self):
    f = wx.Frame (None, -1)
    p = UserPanel (f, -1)
    f.Show ()
    return True

app = MyApp ()
app.MainLoop ()