I'm just wondering if an array of buttons can be created via the wxWidgets GUI?
For calculators, keyboards (typing and musical) etc, this would be a neat feature.
If there is no way to do this, does it sound like a reasonable project?
I would think that the user could be prompted for the rows and columns, and then use the existing button interface to generate an array of buttons.
Thanks,
-Mike
Can button arrays be created via the GUI and if so, how? Topic is solved
Re: Can button arrays be created via the GUI and if so, how?
Code: Select all
wxPanel *panel = new wxPanel(this, wxID_ANY);
const int numRows = 8;
const int numCols = 6;
wxFlexGridSizer *fgs = new wxFlexGridSizer( numRows, numCols, 3, 3 );
for(int row = 0; row < numRows; row++ )
{
for(int col = 0; col < numCols; col++ )
{
fgs->Add( new wxButton(panel, wxID_ANY, wxString::Format("%d %d", row, col)) );
}
}
panel->SetSizer(fgs);
Use the source, Luke!
Re: Can button arrays be created via the GUI and if so, how?
Thank you, DoubleMax!
I'm interpreting your reply to mean that button arrays **cannot** be currently created via the GUI, but you are showing the manually entered code to support the array.
Adding the ability to do this graphically is probably best left until I have time to dig into the source code.
Thanks again!
I'm interpreting your reply to mean that button arrays **cannot** be currently created via the GUI, but you are showing the manually entered code to support the array.
Adding the ability to do this graphically is probably best left until I have time to dig into the source code.
Thanks again!
Re: Can button arrays be created via the GUI and if so, how?
That is not on wxWidgets but on the RAD tool such as wxFormBuilder, wxSmith, wxCrafter, or wxGlade.
TBH, the layouts you mentioned are not usually just uniform arrays of buttons.
If you have a nontrivial layout such as this, you are probably better of with code.
TBH, the layouts you mentioned are not usually just uniform arrays of buttons.
If you have a nontrivial layout such as this, you are probably better of with code.
Last edited by PB on Thu Mar 18, 2021 9:27 pm, edited 1 time in total.
Re: Can button arrays be created via the GUI and if so, how?
Sorry, i misunderstood your question. I don't know if there is any RAD tool that can do this, as i never use one. It should be easy to implement, but then again, it's for a very specific use case.
Use the source, Luke!
Re: Can button arrays be created via the GUI and if so, how?
Hi DoubleMax
Thank you for following up, and I agree, once I understand more about how wxWidgets works, it should not be too difficult.
I would politely disagree that creating arrays of buttons is that special a use case, and it does motivate me to dig into the internals.
Right now, I'm just trying to figure out how the existing controls work!
Take care and thank you for you help!
-Mike
Thank you for following up, and I agree, once I understand more about how wxWidgets works, it should not be too difficult.
I would politely disagree that creating arrays of buttons is that special a use case, and it does motivate me to dig into the internals.
Right now, I'm just trying to figure out how the existing controls work!
Take care and thank you for you help!
-Mike