Sizers Not Distributing Widgets

Sizers are really simple to understand. But, I've obviously missed
something critical in designing a notebook page's worth of widgets on a
wx.Panel. When the application is run, all widgets are scrunched into the
upper left corner of the page, piled messily one on top of the other. I don't
see why.

   The page is done with no absolute positions set, but a series of
wx.BoxSizers is used to group related widgets and assemble them into the
organization I want.

   I've tried to turn the page into a stand-alone app, but it seg faults on
me, probably because there's no top level window (frame or dialog). My
newness to python is showing.

   I'd greatly appreciate learning why the sizers and widgets are not
distributed across the notebook page as intended. I believe that I've
documented what I'm trying to do here.

   Also, what is the difference between a wx.App() and a wx.PySimpleApp()?

Thanks,

Rich

problemPage.py.gz (2.42 KB)

···

--
Richard B. Shepard, Ph.D. | Author of "Quantifying Environmental
Applied Ecosystem Services, Inc. (TM) | Impact Assessments Using Fuzzy Logic"
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863

Hi Rich,

I don't see any SetSizer in there.

You probably need something like:
self.SetSizer(topLevelBox)

Where self is your panel.

See you
Werner

Rich Shepard wrote:

···

  Sizers are really simple to understand. But, I've obviously missed
something critical in designing a notebook page's worth of widgets on a
wx.Panel. When the application is run, all widgets are scrunched into the
upper left corner of the page, piled messily one on top of the other. I don't
see why.

  The page is done with no absolute positions set, but a series of
wx.BoxSizers is used to group related widgets and assemble them into the
organization I want.

  I've tried to turn the page into a stand-alone app, but it seg faults on
me, probably because there's no top level window (frame or dialog). My
newness to python is showing.

  I'd greatly appreciate learning why the sizers and widgets are not
distributed across the notebook page as intended. I believe that I've
documented what I'm trying to do here.

  Also, what is the difference between a wx.App() and a wx.PySimpleApp()?

Thanks,

Rich

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

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

Werner,

   That was it, exactly. I read about that in the wxWidgets book, but when I
tried SetSizeAndFit(), it didn't work. This is another of the differences
between wxWidgets and wxPython.

   Well! Now that they're better dispersed I can work on getting them properly
sized and positioned.

Many thanks,

Rich

···

On Tue, 29 Nov 2005, Werner F. Bruhin wrote:

I don't see any SetSizer in there.

You probably need something like:
self.SetSizer(topLevelBox)

Where self is your panel.

--
Richard B. Shepard, Ph.D. | Author of "Quantifying Environmental
Applied Ecosystem Services, Inc. (TM) | Impact Assessments Using Fuzzy Logic"
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863

Hi Rich,

Rich Shepard wrote:

I don't see any SetSizer in there.

You probably need something like:
self.SetSizer(topLevelBox)

Where self is your panel.

Werner,

  That was it, exactly. I read about that in the wxWidgets book, but when I
tried SetSizeAndFit(), it didn't work. This is another of the differences
between wxWidgets and wxPython.

Maybe spelling? Either should work, see the new wxPython API doc:
SetSizer(self, sizer, deleteOld)
Sets the window to have the given layout sizer.
SetSizerAndFit(self, sizer, deleteOld)
The same as SetSizer, except it also sets the size hints for the window based on the sizer's minimum size.

BTW, I was surprised to see that you use mainly box sizers. In the past I used mostly flexgridsizer in a toplevel boxsizer, currently I am switching a lot over to gridbagsizer and more then halved the number of sizers needed on some of screens and I think they get better aligned. Although there are some exceptions were things get spaced more then I want and I haven't figured it out yet. What took me a while to figure out that with the gridbagsizer I had to use not only wx.EXPAND, but also use the Span(n, n) and grow column and rows appropriatly.

See you
Werner

···

On Tue, 29 Nov 2005, Werner F. Bruhin wrote:

  Well! Now that they're better dispersed I can work on getting them properly
sized and positioned.

Many thanks,

Rich

Maybe spelling? Either should work, see the new wxPython API doc:
SetSizer(self, sizer, deleteOld) Sets the window to have the given layout
sizer.

Hi Werner,

   Probably incorrect syntax on my side.

BTW, I was surprised to see that you use mainly box sizers. In the past I
used mostly flexgridsizer in a toplevel boxsizer, currently I am switching
a lot over to gridbagsizer and more then halved the number of sizers needed
on some of screens and I think they get better aligned. Although there are
some exceptions were things get spaced more then I want and I haven't
figured it out yet. What took me a while to figure out that with the
gridbagsizer I had to use not only wx.EXPAND, but also use the Span(n, n)
and grow column and rows appropriatly.

   I thought about this for a while. This particular notebook page has three
rows. The top row has three vertical sizers aligned across the panel. The
middle and bottom row have buttons (and a pair of checkboxes) distributed
across the width. I did not see the benefits of a flexgridsizer or
gridbagsizer over a vertical boxsizer. Of course, it may well be my
inexperience that prevents me from seeing the advantages.

   I'm always open to better approaches to the results I want and need.

Thanks,

Rich

···

On Tue, 29 Nov 2005, Werner F. Bruhin wrote:

--
Richard B. Shepard, Ph.D. | Author of "Quantifying Environmental
Applied Ecosystem Services, Inc. (TM) | Impact Assessments Using Fuzzy Logic"
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863

Rich,

Sizers are really simple to understand.

No, they are not. The principle is fairly simple but the implementation takes a while to wrap your brain around. Everyone struggles with them. There have been a few efforts to simplify the whole thing, primarily by making sizers a default, which would eliminate at least one class of errors, the one you made, forgetting to call SetSizer! Mindwrapper and Dabo.ui are two of these. I'm hoping something like them will become complete and stable, and perhaps the standard way of doing things one day.

The page is done with no absolute positions set,

but a lot of absolute sizes, which makes it HUGE on my screen, too big to fit, so it's hard to tell what you are trying to do. I'd get rid of all the absolute sizes on things like buttons and static text, they should size themselves. You probably do need to set some sizes on things like Panels that don't have natural size, but make them smaller. Get it all to fit in a reasonable size, then post it again for feedback. I suspect you could create classes for some subgroups of controls, but I'm not sure without knowing more about what it all means.

Also, you could probably remove a few sizers by add space (with wx.ALL, wx.RIGHT, etc flags around the items instead.

One final comment, and I've said this before: START SMALL. Add a couple items at time to your panel. It's much easier to find problems, and easier for us to help you find them, when you've got less on there.

  I've tried to turn the page into a stand-alone app, but it seg faults on
me, probably because there's no top level window (frame or dialog).

Yup. you need a Frame to put your panel in. This works:

if __name__ == "__main__":
   problem = wx.PySimpleApp(0)
   f = wx.Frame(None)
   panel_1 = modFzySet(f, -1)
   problem.SetTopWindow(f)
   f.fit() # if you want the Frame sized to fit everything in it.
   f.Show()
   problem.MainLoop()

  Also, what is the difference between a wx.App() and a wx.PySimpleApp()?

An wx.App() requires an OnInit method, that gets run when the app starts up. If you don't need to do anything special when the app starts up, wx.PySimpleApp() is easier.

-Chris

···

--
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 Barker wrote:

An wx.App() requires an OnInit method, that gets run when the app starts up. If you don't need to do anything special when the app starts up, wx.PySimpleApp() is easier.

Yesterday, I thought the same thing. But I just discovered (tracking down a different problem) that you no longer need the OnInit():

pmcnett@sol:~/projects/dabo/dabo/ui/uiwx$ python
Python 2.4.2 (#2, Sep 30 2005, 21:19:01)
[GCC 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu8)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import wx
>>> app = wx.App()
>>> frm = wx.Frame(None, -1, "hello")
>>> frm.Show()
True
>>> app.MainLoop()

So... the question remains: just what *is* the difference, these days, between wx.PySimpleApp and wx.App?

···

--
Paul McNett
http://paulmcnett.com
http://dabodev.com

Sizers are really simple to understand.

No, they are not.

Chris,

   Simple to understand; difficult to implement properly. :slight_smile:

... the one you made, forgetting to call SetSizer!

   That's in the wxWidgets book but the syntax is different in wxPython and I
didn't guess the proper syntax. Werner showed me how it's done.

but a lot of absolute sizes, which makes it HUGE on my screen, too big to fit, so it's hard to tell what you are trying to do. I'd get rid of all the absolute sizes on things like buttons and static text, they should size themselves. You probably do need to set some sizes on things like Panels that don't have natural size, but make them smaller. Get it all to fit in a reasonable size, then post it again for feedback. I suspect you could create classes for some subgroups of controls, but I'm not sure without knowing more about what it all means.

   I was under the impression that I needed to set minimum sizes; again, from
reading the wxWidgets book. Now I'm working on fixing things; your
suggestion to remove explicit sizes is helping. I'm going through the code
one widget at a time and learning by trying different things. One major
factor in the display size issue is setting the .Add expandable factor to '1'
rather than '0' and having wx.EXPAND where it should not be. I'm stripping
off superfluous code and will post a working example when I'm done. Probably
tomorrow, as I have a long meeting with clients this afternoon.

Also, you could probably remove a few sizers by add space (with wx.ALL, wx.RIGHT, etc flags around the items instead.

   I am modifying these, too.

An wx.App() requires an OnInit method, that gets run when the app starts up. If you don't need to do anything special when the app starts up, wx.PySimpleApp() is easier.

   Thank you. That makes it much clearer.

Rich

···

On Tue, 29 Nov 2005, Chris Barker wrote:

--
Richard B. Shepard, Ph.D. | Author of "Quantifying Environmental
Applied Ecosystem Services, Inc. (TM) | Impact Assessments Using Fuzzy Logic"
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863

Rich Shepard wrote:

I did not see the benefits of a flexgridsizer or
gridbagsizer over a vertical boxsizer.

I think of it this way:

If you have a column of items, use vertical box sizer

If you have a row of items, use a horizontal box sizer

If you have both rows and columns, use one of the grid sizers.

What's key here is if you have multiple rows (columns), if the items in each row(column) need to line up with items in the other rows(columns) then you should use a grid sizer.

To some extent, the GridBagSizer is a superset of all the others, so you could, in principle, use it for everything, but if you have multiple GridBagSizers that each have only one row, you might as well use a boxsizer.

-chris

···

--
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

... but a lot of absolute sizes, which makes it HUGE on my screen, too big to
fit, so it's hard to tell what you are trying to do.

Chris, et al.:

   I have it fixed up and working. The stand-alone app invokes quite small,
but pulling on the lower right corner resizes it so everything is visible.

Get it all to fit in a reasonable size, then post it again for feedback. I
suspect you could create classes for some subgroups of controls, but I'm
not sure without knowing more about what it all means.

   It's attached. Suggestions on how to optimize it are certainly welcome.

   Once I have this page fixed up I'll go fix the others.

Thanks,

Rich

problemPage.py.gz (2.21 KB)

···

On Tue, 29 Nov 2005, Chris Barker wrote:

--
Richard B. Shepard, Ph.D. | Author of "Quantifying Environmental
Applied Ecosystem Services, Inc. (TM) | Impact Assessments Using Fuzzy Logic"
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863

Tuesday, November 29, 2005, 1:42:12 PM, Werner F. Bruhin wrote:

(...) I was surprised to see that you use mainly box sizers. In the
past I used mostly flexgridsizer in a toplevel boxsizer, currently I
am switching a lot over to gridbagsizer and more then halved the
number of sizers needed on some of screens and I think they get
better aligned. Although there are some exceptions were things get
spaced more then I want and I haven't figured it out yet. What took
me a while to figure out that with the gridbagsizer I had to use not
only wx.EXPAND, but also use the Span(n, n) and grow column and rows
appropriatly.

Gridbagsizers may space controls more than we want for a couple of
non-obvious reasons.

The first thing you might wish to check is the empty cell size.
Gridbagsizers have a default empty cell size value of (10, 20). It
means that:

  - If you add a small control to a gridbagsizer, say, a 5x5 button,
  the sizer cell will always occupy at least 10x20.

  - If you add controls to non-adjacent rows, say, to rows 5 and 7,
  and don't add anything to row #6, the row #6 will be a 20px-height
  empty space. In an analogous way, empty cols will always have a
  width of 10px.

  - You can change the default empty cell size value using the
  SetEmptyCellSize(width, height) method of the GridbagSizer. Passing
  a width, height of 0, 0, for example, would make the rows 5 and 7 I
  mentioned above look like they are adjacent (and the 5x5 button
  would be placed in a 5x5 cell).

The second thing is related to spanning. Consider the following
gridbagsizer (the cell/empty cell sizes now won't make difference):

···

+--------+--------+--------+--------+--------+

       > > > > >

+--------+--------+--------+--------+--------+

       > > > > >

+--------+--------+--------+--------+--------+

       > > > > >

+--------+--------+--------+--------+--------+

Now if you add something with a width of 100px to pos (0, 0) with a
span of (1, 2), the gridbagsizer will use 100px/2 = 50px as the
minimum width of all cells below the spanned cell:

+--------+--------+--------+--------+--------+

  <-100 px-> | | | |

+--------+--------+--------+--------+--------+

<50px> | <50px> | | | |

+--------+--------+--------+--------+--------+

<50px> | <50px> | | | |

+--------+--------+--------+--------+--------+

Now for the tricky thing. If you add something with a width of 75px to
pos (1, 0), the gridbagsizer will still use at least 50px for the
other cells, no matter if you add something to them or not:

+---------------------+--------+--------+--------+

     <-125 px-> | | | |

+-------------------- +--------+--------+--------+

<-75 px -> | <50px> | | | |

+------------+--------+--------+--------+--------+

  <50px> | <50px> | | | |

+------------+--------+--------+--------+--------+

A way to work around this would be to "split" cells; Since the
standard gridbagsizer hasn't a Split() method, in this example you'll
need to increase the span of (0, 0):

+--------+--------+--------+--------+--------+

          <-100 px-> | |

+--------+--------+--------+--------+--------+

<25px> | <25px> | <25px> | <25px> | |

+--------+--------+--------+--------+--------+

<25px> | <25px> | <25px> | <25px> | |

+--------+--------+--------+--------+--------+

And now if you add something with a width of 75px to pos (1, 0), the
gridbagsizer will use at least 25px for the other cells. (And things
will look closer).

And yes, the pictures above refer only to horizontal spanning, but
vertical spanning behaves the same way.

-- tacao

No bits were harmed during the making of this e-mail.

tacao,

   Thank you for a valuable lesson.

Rich

···

On Tue, 29 Nov 2005, E. A. Tacao wrote:

Gridbagsizers may space controls more than we want for a couple of
non-obvious reasons.

--
Richard B. Shepard, Ph.D. | Author of "Quantifying Environmental
Applied Ecosystem Services, Inc. (TM) | Impact Assessments Using Fuzzy Logic"
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863

Hi Tacao,

E. A. Tacao wrote:

Tuesday, November 29, 2005, 1:42:12 PM, Werner F. Bruhin wrote:

Gridbagsizers may space controls more than we want for a couple of
non-obvious reasons.

Thanks for all this info, it sounds like it might solve my problems.

See you
Werner

Chris Barker wrote:
> An wx.App() requires an OnInit method, that gets run when the app starts
> up. If you don't need to do anything special when the app starts up,
> wx.PySimpleApp() is easier.

Yesterday, I thought the same thing. But I just discovered (tracking down a
different problem) that you no longer need the OnInit():

pmcnett@sol:~/projects/dabo/dabo/ui/uiwx$ python
Python 2.4.2 (#2, Sep 30 2005, 21:19:01)
[GCC 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu8)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import wx
>>> app = wx.App()
>>> frm = wx.Frame(None, -1, "hello")
>>> frm.Show()
True
>>> app.MainLoop()

So... the question remains: just what *is* the difference, these days, between
wx.PySimpleApp and wx.App?

Today, nothing, and wx.PySimpleApp remains for backwards compatability
reasons. Once upon a time, wx.App didn't have a default OnInit, and
then it did have one but didn't call wx.InitAllImageHandlers, and now
theres not really any difference at all.

···

On 11/29/05, Paul McNett <p@ulmcnett.com> wrote:

--
Paul McNett
http://paulmcnett.com
http://dabodev.com

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

Chris Mellon wrote:

Today, nothing, and wx.PySimpleApp remains for backwards compatability
reasons.

Well then, let's all start using wx.App() in our examples.

Thanks, Chris.

One of these days we should have a virtual sprint to modernize all the code in the Demo and Wiki!

-Chris

···

--
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

Tacao,

This is a very nice explanation, please put it in the Wiki!

···

Gridbagsizers may space controls more than we want for a couple of
non-obvious reasons.

The first thing you might wish to check is the empty cell size.
Gridbagsizers have a default empty cell size value of (10, 20). It
means that:

  - If you add a small control to a gridbagsizer, say, a 5x5 button,
  the sizer cell will always occupy at least 10x20.

  - If you add controls to non-adjacent rows, say, to rows 5 and 7,
  and don't add anything to row #6, the row #6 will be a 20px-height
  empty space. In an analogous way, empty cols will always have a
  width of 10px.

  - You can change the default empty cell size value using the
  SetEmptyCellSize(width, height) method of the GridbagSizer. Passing
  a width, height of 0, 0, for example, would make the rows 5 and 7 I
  mentioned above look like they are adjacent (and the 5x5 button
  would be placed in a 5x5 cell).

The second thing is related to spanning. Consider the following
gridbagsizer (the cell/empty cell sizes now won't make difference):

+--------+--------+--------+--------+--------+
> > > > > >
+--------+--------+--------+--------+--------+
> > > > > >
+--------+--------+--------+--------+--------+
> > > > > >
+--------+--------+--------+--------+--------+

Now if you add something with a width of 100px to pos (0, 0) with a
span of (1, 2), the gridbagsizer will use 100px/2 = 50px as the
minimum width of all cells below the spanned cell:

+--------+--------+--------+--------+--------+
> <-100 px-> | | | |
+--------+--------+--------+--------+--------+
> <50px> | <50px> | | | |
+--------+--------+--------+--------+--------+
> <50px> | <50px> | | | |
+--------+--------+--------+--------+--------+

Now for the tricky thing. If you add something with a width of 75px to
pos (1, 0), the gridbagsizer will still use at least 50px for the
other cells, no matter if you add something to them or not:

+---------------------+--------+--------+--------+
> <-125 px-> | | | |
+-------------------- +--------+--------+--------+
> <-75 px -> | <50px> | | | |
+------------+--------+--------+--------+--------+
> <50px> | <50px> | | | |
+------------+--------+--------+--------+--------+

A way to work around this would be to "split" cells; Since the
standard gridbagsizer hasn't a Split() method, in this example you'll
need to increase the span of (0, 0):

+--------+--------+--------+--------+--------+
> <-100 px-> | |
+--------+--------+--------+--------+--------+
> <25px> | <25px> | <25px> | <25px> | |
+--------+--------+--------+--------+--------+
> <25px> | <25px> | <25px> | <25px> | |
+--------+--------+--------+--------+--------+

And now if you add something with a width of 75px to pos (1, 0), the
gridbagsizer will use at least 25px for the other cells. (And things
will look closer).

And yes, the pictures above refer only to horizontal spanning, but
vertical spanning behaves the same way.

-- tacao

No bits were harmed during the making of this e-mail.

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

--
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

Rich Shepard wrote:

  I have it fixed up and working. The stand-alone app invokes quite small,
but pulling on the lower right corner resizes it so everything is visible.

Add a frame.Fit(), or a SetSizerAndFit() -- that tells the frame to Fit itself to its contents. You have to call it after adding everything however.

Even though it's a matter of taste, I highly suggest 4 spaces for indenting -- it's a pretty solid standard for Python.

  It's attached. Suggestions on how to optimize it are certainly welcome.

Looking good. A few comments:

- You're not using panel_1 anymore, it's all on the frame.

- By putting a little more space around everything in outerBox, I could eliminate topLevelBox.

- Adding a wx.EXPAND flag when you add the bottomBox allows the space to expand, and the checkbox to move to the right, so you don't have to make the spacer any particular size:

     outerBox.Add(bottomButtonBox, 0, wx.EXPAND|wx.ALL, 10)

-You don't need to set a size for the dataChkBox, it will fit the label you give it.

- Form custom classes to the groupings. I may misunderstand how this all going to work, but it looks to me like you could have the plot window in a panel with the "update plot" and "Curve parameters" buttons, and maybe the checkbox too. Maybe the "show all fuzzy sets" belongs there too.

You do know about matplotlib, I hope.

I've enclosed my slightly edited version.

-Chris

problemPage.py (10.4 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

Rich Shepard wrote:
> I have it fixed up and working. The stand-alone app invokes quite small,
> but pulling on the lower right corner resizes it so everything is visible.

Add a frame.Fit(), or a SetSizerAndFit() -- that tells the frame to Fit
itself to its contents. You have to call it after adding everything however.

Even though it's a matter of taste, I highly suggest 4 spaces for
indenting -- it's a pretty solid standard for Python.

> It's attached. Suggestions on how to optimize it are certainly welcome.

Looking good. A few comments:

- You're not using panel_1 anymore, it's all on the frame.

One small thing - it's generally good practice not to put all your
controls on the frame.On Windows, frames have a different background
than panels and theres a couple other issues with regards to tab
traversal and focus (ie, it doesn't work). Putting them on a panel is
the "correct" thing to do.

- By putting a little more space around everything in outerBox, I could
eliminate topLevelBox.

- Adding a wx.EXPAND flag when you add the bottomBox allows the space to
expand, and the checkbox to move to the right, so you don't have to make
the spacer any particular size:

     outerBox.Add(bottomButtonBox, 0, wx.EXPAND|wx.ALL, 10)

-You don't need to set a size for the dataChkBox, it will fit the label
you give it.

- Form custom classes to the groupings. I may misunderstand how this all
going to work, but it looks to me like you could have the plot window in
a panel with the "update plot" and "Curve parameters" buttons, and maybe
the checkbox too. Maybe the "show all fuzzy sets" belongs there too.

Yes, it can help alot with complex layouts to group related controls
together into wxPanel subclasses. This can also be nice later on for
modularity. If having all these extra panels gets to you, consider
wrapping up functions that create all the controls and return the
top-level sizer around them, similiar to how
wx.Dialog.CreateStdButtonSizer works.

If it were me, I'd arrange it so that the graph was what grew and took
up available space as the dialog was resized. This looks wierd with
the "Show all fuzzy sets", "Update plot", and "Curve Parameters"
buttons so I'd put them somewhere else, maybe vertically on the left
side, underneath the list boxes. robably put the checkbox over there
too.

···

On 11/29/05, Chris Barker <Chris.Barker@noaa.gov> wrote:

You do know about matplotlib, I hope.

I've enclosed my slightly edited version.

-Chris

Add a frame.Fit(), or a SetSizerAndFit() -- that tells the frame to Fit itself to its contents. You have to call it after adding everything however.

Chris,

   Ah! That's what I forgot to add to the stand-alone version.

- You're not using panel_1 anymore, it's all on the frame.

   That's because I took what goes in a panel on the notebook page and made it
a separate application. In it's real work it's only one of eight notebook
pages.

- By putting a little more space around everything in outerBox, I could eliminate topLevelBox.

   That'll do nicely.

- Adding a wx.EXPAND flag when you add the bottomBox allows the space to expand, and the checkbox to move to the right, so you don't have to make the spacer any particular size:

   outerBox.Add(bottomButtonBox, 0, wx.EXPAND|wx.ALL, 10)

   Thank you. I took that out when I was futzing with it.

-You don't need to set a size for the dataChkBox, it will fit the label you give it.

   I wondered about that, but didn't want to break what worked.

- Form custom classes to the groupings. I may misunderstand how this all
going to work, but it looks to me like you could have the plot window in a
panel with the "update plot" and "Curve parameters" buttons, and maybe the
checkbox too. Maybe the "show all fuzzy sets" belongs there too.

   Yes, the plot window and the two buttons do go together. They're not used
on any other page in the application so I don't know if there is an advantage
to making a custom class for them.

You do know about matplotlib, I hope.

   Yes. After I get the display done I start learning matplotlib.

I've enclosed my slightly edited version.

   Thanks.

Rich

···

On Tue, 29 Nov 2005, Chris Barker wrote:

--
Richard B. Shepard, Ph.D. | Author of "Quantifying Environmental
Applied Ecosystem Services, Inc. (TM) | Impact Assessments Using Fuzzy Logic"
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863

This small example was extracted from the main UI. In its real life it
lives in a panel on a notebook page.

Rich

···

On Tue, 29 Nov 2005, Chris Mellon wrote:

One small thing - it's generally good practice not to put all your controls
on the frame.On Windows, frames have a different background than panels and
theres a couple other issues with regards to tab traversal and focus (ie,
it doesn't work). Putting them on a panel is the "correct" thing to do.

--
Richard B. Shepard, Ph.D. | Author of "Quantifying Environmental
Applied Ecosystem Services, Inc. (TM) | Impact Assessments Using Fuzzy Logic"
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863