new to wxPython, need help with layout

First of all, you can not add the same page window to a book control more than once. Each page should be a new instance.

Secondly, it's not clear from your description above but I think you are saying that you want the other widgets to shown/hidden based on which page is selected in the listbook. IF that is the case then those widgets need to be children of the panels used as pages in the listbook. See the various book samples in the demo for examples.

If you want the same types of widgets on each page, but with different content, then that can still be done with a listbook, but you will have to duplicate the widgets on each page (or better yet, make a new class derived from wx.Panel that encapsulates those widgets and their behaviors, and use a new instance of that class for each page.)

Or you could not use the listbook and instead put just one set of the widgets on the main panel along with a normal listctrl, catch the selection events from the listctrl yourself and change the content of the other widgets as needed from there. That will save you the overhead of making so many instances of the widgets, and may simplify some other things as well.

Finally, learn how to use the WIT. It is very helpful for diagnosing layout problems and many other things as well. http://wiki.wxpython.org/Widget_Inspection_Tool

···

On 9/11/12 10:52 AM, jftuga wrote:

I am new to wxPython and have read over the tutorial, but need help with
my program's layout. I have posted the code and screenshots.
On the left side, there exists a Listbook, that when an item is clicked
on, I want a new Panel which includes the 2nd and 3rd columns. Any help
would be greatly
appreciated.

--
Robin Dunn
Software Craftsman

I didn’t think about doing this: “one set of the widgets on the main panel along with a normal listctrl, catch the selection events from the listctrl yourself and change the content of the other widgets as needed from there. That will save you the overhead of making so many instances of the widgets, and may simplify some other things as well.”

This sounds a lot easier.

I also can’t wait to try out WIT.

Thanks!

-John

···

On Tuesday, September 11, 2012 2:43:42 PM UTC-4, Robin Dunn wrote:

On 9/11/12 10:52 AM, jftuga wrote:

I am new to wxPython and have read over the tutorial, but need help with

my program’s layout. I have posted the code and screenshots.

On the left side, there exists a Listbook, that when an item is clicked

on, I want a new Panel which includes the 2nd and 3rd columns. Any help

would be greatly

appreciated.

First of all, you can not add the same page window to a book control
more than once. Each page should be a new instance.

Secondly, it’s not clear from your description above but I think you are
saying that you want the other widgets to shown/hidden based on which
page is selected in the listbook. IF that is the case then those
widgets need to be children of the panels used as pages in the listbook.
See the various book samples in the demo for examples.

If you want the same types of widgets on each page, but with different
content, then that can still be done with a listbook, but you will have
to duplicate the widgets on each page (or better yet, make a new class
derived from wx.Panel that encapsulates those widgets and their
behaviors, and use a new instance of that class for each page.)

Or you could not use the listbook and instead put just one set of the
widgets on the main panel along with a normal listctrl, catch the
selection events from the listctrl yourself and change the content of
the other widgets as needed from there. That will save you the overhead
of making so many instances of the widgets, and may simplify some other
things as well.

Finally, learn how to use the WIT. It is very helpful for diagnosing
layout problems and many other things as well.
http://wiki.wxpython.org/Widget_Inspection_Tool


Robin Dunn

Software Craftsman

http://wxPython.org

WIT was very helpful. I am almost finished with the layout now. How can I make the left column more narrow?

Also, since I am a wxPython newb, does anyone see anything else that needs to be changed?

http://pastebin.com/FUEaVsM6

Thanks,

-John

Hi John,

WIT was very helpful.

Don't know how we did debugging layouts before Robin did WIT.

  I am almost finished with the layout now. How can I make the left column more narrow?

I assume you are talking about the left column in the listctrl?
http://wxpython.org/Phoenix/docs/html/ListCtrl.html?highlight=listctrl#ListCtrl.SetColumnWidth

Also, since I am a wxPython newb, does anyone see anything else that needs to be changed?

I would wrap all your texts like this _(u"text") and add at the top of your script or app the following:

_ = wx.GetTranslation

This way your future application will be ready to get translated with the gettext module and related utilities.

I would also add the following as the first line in your scripts.

# -*- coding: utf-8 -*-#

Especially if at some point you have non ASCII characters in your source code.

You might also want to look at SizedControls, they help/reduce the code in relation to sizers.

Werner

···

On 11/09/2012 22:35, jftuga wrote:

With a lot of blood, sweat and tears. (Speaking somewhat from my own experience, which is why the WIT was born.)

···

On 9/12/12 12:27 AM, Werner wrote:

Hi John,

On 11/09/2012 22:35, jftuga wrote:

WIT was very helpful.

Don't know how we did debugging layouts before Robin did WIT.

--
Robin Dunn
Software Craftsman