wx.Panel doubts...

Hi, I have some doubts with panels…
1: How to put a Sizer exactly in the Middle of the panel? Even if the screen is resized?
2: Can anyone send me a simple anchor example? cuz I cant understand nothing of the demo =(,
I would prefer an example that uses anchors with sizers
3: Why when I dont tell the constructor of the panel its size, the default sizer never shows everything from the panel?
4: How to change panels in the same frame?
For example: I’m on Panel A, then I clik on the menu which changes to Panel B, Also in each panel would have a Forward/Backward button, that will go to the previous Panel, or the post Panel, Just as Web Browsers forward/backward

5: Thank you all =)

Hi David,

The ONE resource that made me truly understand sizers and layout in wx was the wxPython book from http://www.manning.com/rappin/ .

I bought the e-book, its a bargain and you won’t regret it.

Thanks

Kalle

Up!

Hi, I have some doubts with panels…
1: How to put a Sizer exactly in the Middle of the panel? Even if the screen is resized?
2: Can anyone send me a simple anchor example? cuz I cant understand nothing of the demo =(,
I would prefer an example that uses anchors with sizers
3: Why when I dont tell the constructor of the panel its size, the default sizer never shows everything from the panel?
4: How to change panels in the same frame?
For example: I’m on Panel A, then I clik on the menu which changes to Panel B, Also in each panel would have a Forward/Backward button, that will go to the previous Panel, or the post Panel, Just as Web Browsers forward/backward

5: Thank you all =)


wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

Kalle Haglunds

Lead Developer

SAILPORT AB

Mobil +46(0)70374 08 05

Box 5830, 102 48 Stockholm

Besöksadress. Eriksbergsgatan 10.

Email: kalle@sailport.se

···

On May 9, 2008, at 2:29 PM, David Anderson wrote:

On Thu, May 8, 2008 at 9:17 PM, David Anderson zerty.david@gmail.com wrote:

Since I dont have it… Can you answer my questions plz? =D

···

On Fri, May 9, 2008 at 9:37 AM, python@bdurham.com wrote:

The ONE resource that made me truly understand sizers and layout in wx was the wxPython book from http://www.manning.com/rappin/.

I bought the e-book, its a bargain and you won’t regret it.

Another vote for that strategy!

Malcolm


wxpython-users mailing list

wxpython-users@lists.wxwidgets.org

http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

        1: How to put a Sizer exactly in the Middle of the panel? Even
        if the screen is resized?

Here's what I do to center a button across the bottom of a dialog

        sizer = wx.BoxSizer(wx.HORIZONTAL)
        sizer.Add((1,1), 1)
        btn = wx.Button(pnl,id=wx.ID_PRINT)
        sizer.Add(btn, 0, wx.EXPAND)
        sizer.Add((1,1), 1)

With this layout, the widget (button) stays the same size if the panel
is resized, the space is adjusted evenly on either side.

To center vertically, you could use a similar technique with a vertical
BoxSizer and add sizer from above to the center slot

        4: How to change panels in the same frame?
        For example: I'm on Panel A, then I clik on the menu which
        changes to Panel B, Also in each panel would have a
        Forward/Backward button, that will go to the previous Panel,
        or the post Panel, Just as Web Browsers forward/backward

What I would do is make Panels A and B children of another panel. I
would then hide all but the panel of interest and show that. Here's some
code. self.data_window is the parent panel. The panel parameter is the
panel I want displayed.

    def replace_panel(self, panel):
        self.data_window.Freeze()
        try:
            for i in self.data_window.GetChildren():
                i.Hide()
            panel.Show()
            panel.Fit()
            self.data_window.Layout()
        finally:
            self.data_window.Thaw()

Mark

···

On Fri, 2008-05-09 at 09:29 -0300, David Anderson wrote:

1: How to put a Sizer exactly in the Middle of the panel? Even if the screen is resized?

Use a VERTICAL box sizer and in there a HORIZONTAL one. The VERTICAL
should have the property set that it is alligned CENTRE and the
horizontal box sizer too.

                <flag>wxALIGN_CENTER_HORIZONTAL|wxALL</flag>
                <border>5</border>
                <option>1</option>
                <object class="wxBoxSizer">
                    <orient>wxHORIZONTAL</orient>
                    <object class="sizeritem">
                        <flag>wxALIGN_CENTER_VERTICAL|wxALL</flag>
                        <border>5</border>
                        <object class="wxStaticText" name="wxID_STATIC">
                            <label>This text is centered</label>
                        </object>
                    </object>
                </object>

>> 2: Can anyone send me a simple anchor example? cuz I cant
understand nothing of the demo =(,

Why would you like to use them? Sizers do the trick just fine

3: Why when I dont tell the constructor of the panel its size, the default sizer never shows everything from the panel?

Depends if the minimal size or getbest size of the control reports this properly

4: How to change panels in the same frame?

Either use wx.Wizard which is created for the purpose, or recreate the
panel. First detach the old one, destroy it, then attach the new one
and relayout the window

- Jorgen

The centering stuff I want to do is like this

Label Png Image
>Flex | grid | Sizer|
>|||
>|||
>|||
> |_||

What’s the best way to do this?
I want the Grid centered horizontally like that, just above the label, which I want to be Align Left, and the image, aligned Right…

···

On Fri, May 9, 2008 at 10:49 AM, Jorgen Bodde jorgen.maillist@gmail.com wrote:

1: How to put a Sizer exactly in the Middle of the panel? Even if the screen is resized?

Use a VERTICAL box sizer and in there a HORIZONTAL one. The VERTICAL

should have the property set that it is alligned CENTRE and the

horizontal box sizer too.

            <flag>wxALIGN_CENTER_HORIZONTAL|wxALL</flag>

            <border>5</border>

            <option>1</option>

            <object class="wxBoxSizer">

                <orient>wxHORIZONTAL</orient>

                <object class="sizeritem">

                    <flag>wxALIGN_CENTER_VERTICAL|wxALL</flag>

                    <border>5</border>

                    <object class="wxStaticText" name="wxID_STATIC">

                        <label>This text is centered</label>

                    </object>

                </object>

            </object>

2: Can anyone send me a simple anchor example? cuz I cant

understand nothing of the demo =(,

Why would you like to use them? Sizers do the trick just fine

3: Why when I dont tell the constructor of the panel its size, the default sizer never shows everything from the panel?

Depends if the minimal size or getbest size of the control reports this properly

4: How to change panels in the same frame?

Either use wx.Wizard which is created for the purpose, or recreate the

panel. First detach the old one, destroy it, then attach the new one

and relayout the window

  • Jorgen

wxpython-users mailing list

wxpython-users@lists.wxwidgets.org

http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

David Anderson wrote:

The centering stuff I want to do is like this

Label Png Image
                              >Flex | grid | Sizer|
                              >____|__________|______| >____|__________|______|
                              >____|__________|______|
                              > ___|__________|______|

What's the best way to do this?
I want the Grid centered horizontally like that, just above the label, which I want to be Align Left, and the image, aligned Right...

Horizontal box sizer, containing the label, the flex grid sizer and the png image, with alignment flags as needed.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

David Anderson wrote:

Robin...
Note that:
The grid sizer is below the "row" of the image

Ok, I think I understand now. BTW, if you're going to send ascii art then it's a good idea to send your message in plain text, not html with proportional fonts.

The key to designing layouts with sizers is to simply decompose the desired layout into nested boxes, and then work from the outside to the inside in translating that into sizers. So for your example I would start with a vertical box sizer that contains a horizontal box sizer and the flex grid sizer, and the horizontal box sizer contains the label and the image.

Another thing, i'm using a StaticBitmap, And it always crashes when I try to put inside a sizer, If I dont put, it just appears at the left-top corner of the frame

It may be an issue with improper parentage, or putting it in a sizer that belongs to a different parent window, or something similar. Try to duplicate and isolate the problem in a small sample and if that doesn't help you figure it out then send it here.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!