views:

23

answers:

1

Hi, all, I want to draw a rectangular or a container with 20 slots inside. it is like a cd container or archive, with empty slot to insert the cd or book. I choose wxPython. for this 20 horizontal empty slots, i see there is wx.BoxSizer(wx.Horizonal) or other sizers to make the layout.

my question is, Is it possible to have "visible border and grey background" (to represent the empty slots) for the spaces generated by the wx.BoxSizer? It seems to me that, it is not possible. The sizer seems only to do layout, instead of generating visible subwindow.

If it is not possible, I think I need to create a slot window class for this "border and colorful background" feature, and create 20 slot window objects and add into the sizer. Then, I have to use create another window class to represent the book or CD, and insert this CD window to the slot window.

This sounds a bit awkard. I do not know if slot window is necessary or maybe wx.sizer (or other sizer) could achieve the same effect as the slot window.

+1  A: 

I would create a subclass of wx.Panel for each "slot", then manage them with a grid or box sizer.

Bryan Oakley
So you mean, to build this kind of gui, we cannot avode using this "slot window"(which you suggested to derive from wx.Panel). Am I right?
pepero
You can avoid it, but to show a border you need a widget, and sizers aren't widgets so they don't have borders. However, if you have some widget that represents a book or cd, have that widget draw a border, in which case it doesn't need to live inside a panel.
Bryan Oakley
I see. Thank you Bryan, I did not know the fact that "sizer is not a widget". I need visible border of the slot, because the user needs to know which slot to insert. Without border, it would be a blank widespreaded space, and user cannot know where to insert. This is not acceptable for my case. Then, is it possible to further insert/attach window object or maybe changing the background color (to show a cd is inserted) with this derived wx.Panel window? Thank you very much for your advice.
pepero
yes, you can change the background color of a panel, and you can insert other widgets into it.
Bryan Oakley
thanks a lot, Bryan!!
pepero
HI, Bryan, or other people, I still have a question in mind. if I subclass wxpanel for the slot window, what about the container window which hold all these 20 slot windows? can I still use wxpanel? As I still have the main application window, I suppose I should use the wxFrame for it. I do not know if wxPanel (slot window) can be put inside wxPanel (big container window), and then the wxpanel (big container window) be put in wxFrame (main application window). Is it possible or right way to do it?
pepero
OK. I tried myself. it is possible to put a wxpanel into a wxpanel. Thank you guys for the support.
pepero