Problem with sizers

try this instead:

      newSizer = wx.BoxSizer(wx.VERTICAL)
      newSizer.Add(stat1sizer,0, wx.EXPAND | wx.ALL, 10)
      newSizer.Add(stat2sizer,0, wx.EXPAND | wx.ALL, 10)
      newSizer.Add(lowerSizer,1, wx.EXPAND | wx.ALL, 5)
      self.SetSizer(newSizer)

···

On Mon, 16 Aug 2004 15:02:25 +0200, Franz Steinhäusler <franz.steinhaeusler@gmx.at> wrote:

Hello wxPython-users,

I have problems with sizers.
(I want to use the boxsizer, but something is wrong).
[...]
    newSizer = wx.BoxSizer(wx.VERTICAL)
    newSizer.Add(stat1sizer,1, wx.EXPAND | wx.ALL, 10)
    newSizer.Add(stat2sizer,1, wx.EXPAND | wx.ALL, 10)
    newSizer.Add(lowerSizer,1, wx.EXPAND | wx.ALL, 5)
    self.SetSizer(newSizer)
[...]

--
Peter Damoc
Hacker Wannabe
http://www.sigmacore.net/

Peter Damoc wrote:

I want, that the two textctrl's are left aligned vertically (begin at
the xposition)
For the right side, they should end on the y position, where the
listctrl ends.
Is this possible and how?

It sure is.

look at GridBagSizer in the demo... might be the best thing for the job.
You could do it with boxsizers too but I think that might be too messy :slight_smile:

That's a fine idea, but using boxsizers isn't too hard either. My first reaction, as soon as I saw your screenshots was that the out sizer should be wxHORIZONTAL. On the left you have your inputs and text box, on the right, your collection of buttons and checkboxes.

I would, however use a FlexGridSizer for the top widgets, like the enclosed code, which I think is what you want.

-Chris

SizerTest2.py (2.35 KB)

···

--
Christopher Barker, Ph.D.
Oceanographer
                                         
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

Hello Chris and Peter,

many thanks, it is working now.

I took Chris's code. thank you. That is exactly, what I wanted.

the ready prototype Dialog looks now:

import wx

class MyFrame(wx.Frame):
  def __init__(self, parent, id, name):
    wx.Frame.__init__ (self, parent, id, name, size = (530, 375), style
= wx.DEFAULT_DIALOG_STYLE | wx.MAXIMIZE_BOX | wx.THICK_FRAME |
wx.RESIZE_BORDER)
    btn1above = wx.Button(self, -1, "Create")
    btn2above = wx.Button(self, -1, "Ok")
    btn1right = wx.Button(self, -1, "Cancel")
    btnbrowser = wx.Button(self, -1, "Browse")
    btnmenu = wx.Button(self, -1, "Menu")
    lst = wx.ListCtrl(self, -1)
    self.chkMatchCase = wx.CheckBox(self, -1, "Match Case")
    self.chkRegularExpression = wx.CheckBox(self, -1,
"RegularExpression")
    self.chkSubDirectories = wx.CheckBox(self, -1, "Subdirectories")

    status = wx.StatusBar(self, -1)
    
    helpsizer = wx.BoxSizer(wx.VERTICAL)
    helpsizer.Add((0, 5), 0, wx.ALL, 0)
    helpsizer.Add(btnbrowser, 0, wx.ALL, 0)
    helpsizer.Add((0, 30), 0, wx.ALL, 0)
    helpsizer.Add(btnmenu, 0, wx.ALL, 0)
    helpsizer.Add((0, 40), 0, wx.ALL, 0)
    helpsizer.Add(btn1above, 0, wx.ALL, 0)
    helpsizer.Add((0, 5), 0, wx.ALL, 0)
    helpsizer.Add(self.chkRegularExpression, 0, wx.ALL, 0)
    helpsizer.Add((0, 25), 0, wx.ALL, 0)
    helpsizer.Add(self.chkMatchCase, 0, wx.ALL, 0)
    helpsizer.Add((0, 5), 0, wx.ALL, 0)
    helpsizer.Add(self.chkSubDirectories, 0, wx.ALL, 0)
    helpsizer.Add((0, 30), 0, wx.ALL, 0)
    helpsizer.Add(btn2above, 0, wx.ALL, 0)
    helpsizer.Add((0, 10), 0, wx.ALL, 0)
    helpsizer.Add(btn1right, 0, wx.ALL, 0)

    stat1 = wx.StaticText(self, -1, "Directory:")
    stat2 = wx.StaticText(self, -1, "File Pattern:")
    stat3 = wx.StaticText(self, -1, "Search For:")
    text1 = wx.ComboBox(self, -1, "")
    text2 = wx.ComboBox(self, -1, "")
    text3 = wx.ComboBox(self, -1, "")

    topsizer = wx.FlexGridSizer(2,2,5,5)
    topsizer.AddGrowableCol(1)
    topsizer.Add(stat1,0)
    topsizer.Add(text1,1,wx.GROW)
    topsizer.Add(stat2,0)
    topsizer.Add(text2,1,wx.GROW)
    topsizer.Add(stat3,0)
    topsizer.Add(text3,1,wx.GROW)

    leftSizer = wx.BoxSizer(wx.VERTICAL)
    leftSizer.Add(topsizer,0, wx.EXPAND | wx.ALL, 5)
    leftSizer.Add(lst,1, wx.EXPAND | wx.ALL, 5)
    
    newSizer = wx.BoxSizer(wx.HORIZONTAL)
    newSizer.Add(leftSizer,1, wx.EXPAND | wx.ALL, 10)
    newSizer.Add(helpsizer,0, wx.ALIGN_TOP | wx.ALL, 10)
    lastSizer = wx.BoxSizer(wx.VERTICAL)
    lastSizer.Add(newSizer,1, wx.EXPAND | wx.ALL, 0)
    lastSizer.Add(status,0, wx.EXPAND | wx.ALL, 0)
    self.SetSizer(lastSizer)
    self.SetSizeHints(355, 370)

    #minsize hints
    self.Show()
    
app = wx.PySimpleApp()
Panel = MyFrame(None, -1, "Find Files")

app.MainLoop()

···

On Mon, 16 Aug 2004 11:00:17 -0700, "Chris Barker" <Chris.Barker@noaa.gov> wrote:

Peter Damoc wrote:

I want, that the two textctrl's are left aligned vertically (begin at
the xposition)
For the right side, they should end on the y position, where the
listctrl ends.
Is this possible and how?

It sure is.

look at GridBagSizer in the demo... might be the best thing for the job.
You could do it with boxsizers too but I think that might be too messy :slight_smile:

That's a fine idea, but using boxsizers isn't too hard either. My first
reaction, as soon as I saw your screenshots was that the out sizer
should be wxHORIZONTAL. On the left you have your inputs and text box,
on the right, your collection of buttons and checkboxes.

I would, however use a FlexGridSizer for the top widgets, like the
enclosed code, which I think is what you want.

-Chris

--
Franz Steinhaeusler

Franz Steinhäusler wrote:

many thanks, it is working now.

I took Chris's code. thank you. That is exactly, what I wanted.

I took a look, and I have a comment. You hard coded the size of the Frame, which probably worked on your system, but cut off a bit of a button on mine. I made a couple changes:

Passed in wx.DefaultSize for the Frame size
Called self.Fit() in the Frame constructor right before self.Show()

Fit() makes the Frame whatever minimum size it needs to hold all it's contents. However, this makes the combo boxes pretty small, so I added a hard-coded size to one of them:

text1 = wx.ComboBox(self, -1, "", wx.DefaultPosition, (300,-1))

all the others are adjusted to fit by the Sizers

I've enclosed a version with these small changes.

-Chris

SizerTest2.py (2.6 KB)

···

--
Christopher Barker, Ph.D.
Oceanographer
                                         
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

Chris,

The status bar packed within the vertical boxsizer does not show up under Debian Linux |unstable. It shows up under W2k.

For portability, it will be better to use "self.SetStatusBar(status)" for the main window frame.

Derrick

Chris Barker wrote:

···

Franz Steinhäusler wrote:

many thanks, it is working now.

I took Chris's code. thank you. That is exactly, what I wanted.

I took a look, and I have a comment. You hard coded the size of the Frame, which probably worked on your system, but cut off a bit of a button on mine. I made a couple changes:

Passed in wx.DefaultSize for the Frame size
Called self.Fit() in the Frame constructor right before self.Show()

Fit() makes the Frame whatever minimum size it needs to hold all it's contents. However, this makes the combo boxes pretty small, so I added a hard-coded size to one of them:

text1 = wx.ComboBox(self, -1, "", wx.DefaultPosition, (300,-1))

all the others are adjusted to fit by the Sizers

I've enclosed a version with these small changes.

-Chris

------------------------------------------------------------------------

#!/usr/bin/env python2.3

import wx

class MyFrame(wx.Frame):
def __init__(self, parent, id, name):
  wx.Frame.__init__ (self,
         parent,
         id,
         name,
         size = wx.DefaultSize,
         style = (wx.DEFAULT_DIALOG_STYLE |
            wx.MAXIMIZE_BOX |
            wx.THICK_FRAME |
            wx.RESIZE_BORDER)
         )
  btn1above = wx.Button(self, -1, "Create")
  btn2above = wx.Button(self, -1, "Ok")
  btn1right = wx.Button(self, -1, "Cancel")
  btnbrowser = wx.Button(self, -1, "Browse")
  btnmenu = wx.Button(self, -1, "Menu")
  lst = wx.ListCtrl(self, -1)
  self.chkMatchCase = wx.CheckBox(self, -1, "Match Case")
  self.chkRegularExpression = wx.CheckBox(self, -1,"RegularExpression")
  self.chkSubDirectories = wx.CheckBox(self, -1, "Subdirectories")

  status = wx.StatusBar(self, -1)
  
  helpsizer = wx.BoxSizer(wx.VERTICAL)
  helpsizer.Add((0, 5), 0, wx.ALL, 0)
  helpsizer.Add(btnbrowser, 0, wx.ALL, 0)
  helpsizer.Add((0, 30), 0, wx.ALL, 0)
  helpsizer.Add(btnmenu, 0, wx.ALL, 0)
  helpsizer.Add((0, 40), 0, wx.ALL, 0)
  helpsizer.Add(btn1above, 0, wx.ALL, 0)
  helpsizer.Add((0, 5), 0, wx.ALL, 0)
  helpsizer.Add(self.chkRegularExpression, 0, wx.ALL, 0)
  helpsizer.Add((0, 25), 0, wx.ALL, 0)
  helpsizer.Add(self.chkMatchCase, 0, wx.ALL, 0)
  helpsizer.Add((0, 5), 0, wx.ALL, 0)
  helpsizer.Add(self.chkSubDirectories, 0, wx.ALL, 0)
  helpsizer.Add((0, 30), 0, wx.ALL, 0)
  helpsizer.Add(btn2above, 0, wx.ALL, 0)
  helpsizer.Add((0, 10), 0, wx.ALL, 0)
  helpsizer.Add(btn1right, 0, wx.ALL, 0)

  stat1 = wx.StaticText(self, -1, "Directory:")
  stat2 = wx.StaticText(self, -1, "File Pattern:")
  stat3 = wx.StaticText(self, -1, "Search For:")
  text1 = wx.ComboBox(self, -1, "", wx.DefaultPosition, (300,-1))
  text2 = wx.ComboBox(self, -1, "")
  text3 = wx.ComboBox(self, -1, "")

  topsizer = wx.FlexGridSizer(2,2,5,5)
  topsizer.AddGrowableCol(1)
  topsizer.Add(stat1,0)
  topsizer.Add(text1,1,wx.GROW)
  topsizer.Add(stat2,0)
  topsizer.Add(text2,1,wx.GROW)
  topsizer.Add(stat3,0)
  topsizer.Add(text3,1,wx.GROW)

  leftSizer = wx.BoxSizer(wx.VERTICAL)
  leftSizer.Add(topsizer,0, wx.EXPAND | wx.ALL, 5)
  leftSizer.Add(lst,1, wx.EXPAND | wx.ALL, 5)
  
  newSizer = wx.BoxSizer(wx.HORIZONTAL)
  newSizer.Add(leftSizer,1, wx.EXPAND | wx.ALL, 10)
  newSizer.Add(helpsizer,0, wx.ALIGN_TOP | wx.ALL, 10)
  lastSizer = wx.BoxSizer(wx.VERTICAL)
  lastSizer.Add(newSizer,1, wx.EXPAND | wx.ALL, 0)
  lastSizer.Add(status,0, wx.EXPAND | wx.ALL, 0)
  self.SetSizer(lastSizer)
  self.SetSizeHints(355, 370)

  #minsize hints
  self.Fit()
  self.Show()
  
app = wx.PySimpleApp()
Panel = MyFrame(None, -1, "Find Files")

app.MainLoop()

------------------------------------------------------------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

Derrick wrote:

The status bar packed within the vertical boxsizer does not show up under Debian Linux |unstable. It shows up under W2k.

That's odd, it shows up on my Gentoo box (wxPython GTK2 1.5.1)

For portability, it will be better to use "self.SetStatusBar(status)" for the main window frame.

However, I didn't write that code, I only tweaked it, and I would use wx.Frame.CreateStatusBar myself.

slightly adjusted version enclosed

-Chris

SizerTest2.py (2.5 KB)

···

--
Christopher Barker, Ph.D.
Oceanographer
                                         
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

Hello all,

thank you again for your answers.
I need to think through the whole sizer business through again :wink:

regards

···

On Tue, 17 Aug 2004 13:52:59 -0700, "Chris Barker" <Chris.Barker@noaa.gov> wrote:

Derrick wrote:

The status bar packed within the vertical boxsizer does not show up
under Debian Linux |unstable. It shows up under W2k.

That's odd, it shows up on my Gentoo box (wxPython GTK2 1.5.1)

For portability, it will be better to use "self.SetStatusBar(status)"
for the main window frame.

However, I didn't write that code, I only tweaked it, and I would use
wx.Frame.CreateStatusBar myself.

slightly adjusted version enclosed

-Chris

--
Franz Steinhaeusler