but if the window is resized smaller then the width of both layout together, I would like it to move the layout to the right, below the layout on the left like this:
±------------------------+
±---------±---------+ |
label(1) | field(1) | |
±---------±---------+ |
±---------±---------+ |
label(n) | field(n) | |
±---------±---------+ |
±---------±---------+ |
label(n+1)|field(n+1)| |
±---------±---------+ |
±---------±---------+ |
label(n+n)|field(n+n)| |
±---------±---------+ |
±------------------------+
I haven’t find anything like this anywhere so I assume it’s not simple. Can anyone point me in the right direction?
Not to make this too complicated or anything but I also would like to have a minimum overall width of the width one layout, with a vertical scroll bar if both layouts don’t don’t fit vertical.
First, for simplicity in moving these things around, I'd suggest
having two separate panels, one with items 1 to N, and one with items
N+1 to N+N. Then when you need to redo the layout, you just move the
latter from being next to the former to being under it.
You should be able to listen to the resize event by, in your window,
doing something like
self.Bind(wx.EVT_SIZE, self.onResize)
This will call your onResize function every time the window is
resized. Then you should be able to do something like this:
def onResize(self, event):
check current window size
if window is too narrow and we're currently in horizontal view:
create new vertical sizer, put our two panels in it, and set
it to be our sizer
elif window is wide enough and we're currently in vertical view:
create new horizontal sizer, put our two panels in it, and set
it to be our sizer
event.Skip() # Allow normal resizing events to happen
As for scrollbars, just add wx.VSCROLL and wx.HSCROLL to the window's
style to get scrollbars when they're needed. So e.g. use something
like wx.RESIZE_BORDER | wx.FRAME_TOOL_WINDOW | wx.CAPTION | wx.VSCROLL
wx.HSCROLL as the window style.
-Chris
···
On Tue, Jul 19, 2011 at 8:57 AM, David Ruggles <thedavidfactor@gmail.com> wrote:
I'm new to wxPython, but I've been reading hard
I'm trying to create a record editor for a database and what I'd like to do
is have a layout out like this:
+-------------------------------------------------+
> +----------+----------+ +----------+----------+ |
> > label(1) | field(1) | |label(n+1)|field(n+1)| |
> +----------+----------+ +----------+----------+ |
> > ~~~~~~~~ | ~~~~~~~~ | |~~~~~~~~~~|~~~~~~~~~~| |
> +----------+----------+ +----------+----------+ |
> > label(n) | field(n) | |label(n+n)|field(n+n)| |
> +----------+----------+ +----------+----------+ |
+-------------------------------------------------+
but if the window is resized smaller then the width of both layout together,
I would like it to move the layout to the right, below the layout on the
left like this:
+-------------------------+
> +----------+----------+ |
> > label(1) | field(1) | |
> +----------+----------+ |
> > ~~~~~~~~ | ~~~~~~~~ | |
> +----------+----------+ |
> > label(n) | field(n) | |
> +----------+----------+ |
> +----------+----------+ |
> >label(n+1)|field(n+1)| |
> +----------+----------+ |
> >~~~~~~~~~~|~~~~~~~~~~| |
> +----------+----------+ |
> >label(n+n)|field(n+n)| |
> +----------+----------+ |
+-------------------------+
I haven't find anything like this anywhere so I assume it's not simple. Can
anyone point me in the right direction?
Not to make this too complicated or anything but I also would like to
have a minimum overall width of the width one layout, with a vertical scroll
bar if both layouts don't don't fit vertical.
Thanks!
David Ruggles
Hi,
You may try whether wx.WrapSizer() can achieve (some of) that (it was
probably added in some recent wx version, maybe 2.9).
Check the wxpython demo for wx 2.9.1.1
... WIndows layout: WrapSizer
You would need to pair each label+field in inner sizers (e.g.
horizontal BoxSizers), which would be added to the WrapSizer.
However, I haven't used this sizers myself sofar, besides trying the
demo. I am not sure, whether you can limit the maximal number of items
next to each other to 2, like you mentioned.
HTH,
vbr
···
2011/7/19 David Ruggles <thedavidfactor@gmail.com>:
I'm new to wxPython, but I've been reading hard
I'm trying to create a record editor for a database and what I'd like to do
is have a layout out like this:
+-------------------------------------------------+
> +----------+----------+ +----------+----------+ |
> > label(1) | field(1) | |label(n+1)|field(n+1)| |
> +----------+----------+ +----------+----------+ |
> > ~~~~~~~~ | ~~~~~~~~ | |~~~~~~~~~~|~~~~~~~~~~| |
> +----------+----------+ +----------+----------+ |
> > label(n) | field(n) | |label(n+n)|field(n+n)| |
> +----------+----------+ +----------+----------+ |
+-------------------------------------------------+
but if the window is resized smaller then the width of both layout together,
I would like it to move the layout to the right, below the layout on the
left like this:
+-------------------------+
> +----------+----------+ |
> > label(1) | field(1) | |
> +----------+----------+ |
> > ~~~~~~~~ | ~~~~~~~~ | |
> +----------+----------+ |
> > label(n) | field(n) | |
> +----------+----------+ |
> +----------+----------+ |
> >label(n+1)|field(n+1)| |
> +----------+----------+ |
> >~~~~~~~~~~|~~~~~~~~~~| |
> +----------+----------+ |
> >label(n+n)|field(n+n)| |
> +----------+----------+ |
+-------------------------+
I haven't find anything like this anywhere so I assume it's not simple. Can
anyone point me in the right direction?
Not to make this too complicated or anything but I also would like to
have a minimum overall width of the width one layout, with a vertical scroll
bar if both layouts don't don't fit vertical.
Thanks!
David Ruggles