basic control and button bar frame

Post here wxCrafter related issues / features / bugs
marcusadamski
CodeLite Curious
Posts: 8
Joined: Mon Sep 14, 2015 9:14 pm
Genuine User: Yes
IDE Question: c++
Contact:

basic control and button bar frame

Post 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
DavidGH
CodeLite Plugin
Posts: 819
Joined: Wed Sep 03, 2008 7:26 pm
Contact:

Re: basic control and button bar frame

Post 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
User avatar
eranif
CodeLite Plugin
Posts: 6367
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: basic control and button bar frame

Post 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
Make sure you have read the HOW TO POST thread
marcusadamski
CodeLite Curious
Posts: 8
Joined: Mon Sep 14, 2015 9:14 pm
Genuine User: Yes
IDE Question: c++
Contact:

Re: basic control and button bar frame

Post 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
Post Reply