Page 1 of 1

basic control and button bar frame

Posted: Mon Sep 14, 2015 10:05 pm
by marcusadamski
Hi all,

I'm looking to make an application in Python, and trying out wxCrafter as the xrc generator.

I'm experimenting by designing a basic multiline text control, at the top of the frame, with two buttons at the bottom (say OK, Cancel). Like most dialogues, I would like the two buttons on the right side of the frame.

For the right alignment of buttons initially I tried
- wxbox sizer, added wxtextcntrl, then a wxStdDialogueButtonSizer
-- I can then add one button to the btn sizer, but the second jumps to the top of the screen ?

- secondly, tried adding a wxfelxgridsizer, with 3 columns, zero rows. I added a spacer first, then two buttons
-- however I could only get the two buttons on left hand side, despite the spacer having proportion 1, and the buttons 0

- finally I used a horizontal box, added two buttons, then simply right aligned it.
-- this worked.

My question, what's the best approach to right align several buttons at the bottom of a frame (as I assume there are a few ways of doing this)?

Many thanks for any advice.
Marcus

Re: basic control and button bar frame

Posted: Tue Sep 15, 2015 1:57 am
by DavidGH
Hi,
- wxbox sizer, added wxtextcntrl, then a wxStdDialogueButtonSizer
-- I can then add one button to the btn sizer, but the second jumps to the top of the screen ?
I don't use wxStdDialogueButtonSizers, but I vaguely recall bug like that. I might be that it would work in the real program (as opposed to the wxCrafter preview).
- secondly, tried adding a wxfelxgridsizer, with 3 columns, zero rows. I added a spacer first, then two buttons
-- however I could only get the two buttons on left hand side, despite the spacer having proportion 1, and the buttons 0
You needed to make the first column expandable with wxFlexGridSizer::AddGrowableRow.
- finally I used a horizontal box, added two buttons, then simply right aligned it.
That's what I normally do. Or you could have given it the wxEXPAND flag and added a wxSpacer first to take all the spare space.
My question, what's the best approach
Whatever works ;)

Regards,

David
Regards,

David

Re: basic control and button bar frame

Posted: Tue Sep 15, 2015 8:42 am
by eranif
marcusadamski wrote:-- I can then add one button to the btn sizer, but the second jumps to the top of the screen ?
This is a bug in wxWidgets. To fix this, you just need to assign the new button a different ID (by default, the newly added button has the wxID_OK ID)
Once new ID is set to the button, it will fix its position


Eran

Re: basic control and button bar frame

Posted: Tue Sep 15, 2015 10:52 am
by marcusadamski
Thanks David / Eran,

I found my mistake using the wxfelxgridsizer - although I added an initial spacer, I failed to assign it a 'size' in the properties. Setting 1,1 did the trick.

Regarding wxStdDialogueButtonSizer, but by adding buttons with different ID's still didn't work. But at least I have two other options.

Thanks very much for your quick help. I think I'll go with the flexgrid and spacer approach, as it obvious from the layout tree in the designer, what's going on.

Best
Marcus