Hello!
I'm a newbie in wxwidgets! selftaught and teaching, I recently built a calculator app for calculating basic functions and some people complained about how small the labels/Display was.
So I managed to create a wxfont function to increase the size of my wxtextctrl display but I don't seem to be able to find any function relating to the change of the label of my buttons' size to something larger...
Forgive my naivety
Wxbutton label font resize
-
- Knows some wx things
- Posts: 30
- Joined: Tue Dec 11, 2018 1:38 pm
Re: Wxbutton label font resize
I'm not quite sure what you mean by that, but if you managed to set a bigger font for a text control, the same will work for buttons.So I managed to create a wxfont function to increase the size of my wxtextctrl display
If you want a bigger font for all controls, set a bigger font for the parent of these controls *before* creating them. By that they will all inherit the bigger font.
Code: Select all
wxFont font = GetFont(); // get the current font of, e.g. a wxFrame, depending on the context of this code
font.SetPixelSize( wxSize(0,24) );
SetFont( font );
// create child controls here...
Code: Select all
wxFont font = GetFont(); // get the current font of, e.g. a wxFrame, depending on the context of this code
font.SetPixelSize( wxSize(0,24) );
wxButton *button = new wxButton(panel, wxID_ANY, "button one");
button->SetFont( font );
Use the source, Luke!
-
- Knows some wx things
- Posts: 30
- Joined: Tue Dec 11, 2018 1:38 pm
Re: Wxbutton label font resize
Thanks a lot! I just simply used the same layout I used to increase the font size of my wxtextctrl and replaced it with the button! it works! Though it needs me to click the button before the font actually changes, I'm working on this now!doublemax wrote:I'm not quite sure what you mean by that, but if you managed to set a bigger font for a text control, the same will work for buttons.So I managed to create a wxfont function to increase the size of my wxtextctrl display
If you want a bigger font for all controls, set a bigger font for the parent of these controls *before* creating them. By that they will all inherit the bigger font.
Or you can set the new font for individual controls only:Code: Select all
wxFont font = GetFont(); // get the current font of, e.g. a wxFrame, depending on the context of this code font.SetPixelSize( wxSize(0,24) ); SetFont( font ); // create child controls here...
If you use sizers for the layout of the controls (what you should do), then the controls will automatically get sizes that are big enough for the font size.Code: Select all
wxFont font = GetFont(); // get the current font of, e.g. a wxFrame, depending on the context of this code font.SetPixelSize( wxSize(0,24) ); wxButton *button = new wxButton(panel, wxID_ANY, "button one"); button->SetFont( font );
Any ideas would be helpful! And by the way, I used code::blocks drag drop wxwidgets from scratch of my wxwidgets programming career so I have little to no experience with the actual coding process I'm also trying to work on that as well
Re: Wxbutton label font resize
Please show some code, because i have absolutely no idea what you're doing.Thanks a lot! I just simply used the same layout I used to increase the font size of my wxtextctrl and replaced it with the button! it works! Though it needs me to click the button before the font actually changes, I'm working on this now!
Any ideas would be helpful!
Use the source, Luke!
-
- Knows some wx things
- Posts: 30
- Joined: Tue Dec 11, 2018 1:38 pm
Re: Wxbutton label font resize
sorry i took time pasting the code. here it isdoublemax wrote:Please show some code, because i have absolutely no idea what you're doing.Thanks a lot! I just simply used the same layout I used to increase the font size of my wxtextctrl and replaced it with the button! it works! Though it needs me to click the button before the font actually changes, I'm working on this now!
Any ideas would be helpful!
Code: Select all
void projectcalciFrame::OnButton19Click(wxCommandEvent& event)
{
wxFont font1 = Button1->GetFont();
font1.SetPointSize(10);
Button1->SetFont(font1);
wxFont font2 = Button2->GetFont();
font2.SetPointSize(10);
Button2->SetFont(font2);
wxFont font3 = Button3->GetFont();
font3.SetPointSize(10);
Button3->SetFont(font3);
wxFont font4 = Button4->GetFont();
font4.SetPointSize(10);
Button4->SetFont(font4);
wxFont font5 = Button5->GetFont();
font5.SetPointSize(10);
Button5->SetFont(font5);
wxFont font6 = Button6->GetFont();
font6.SetPointSize(10);
Button6->SetFont(font6);
wxFont font7 = Button7->GetFont();
font7.SetPointSize(10);
Button7->SetFont(font7);
wxFont font8 = Button8->GetFont();
font8.SetPointSize(10);
Button8->SetFont(font8);
wxFont font9 = Button9->GetFont();
font9.SetPointSize(10);
Button9->SetFont(font9);
wxFont font10 = Button10->GetFont();
font10.SetPointSize(10);
Button10->SetFont(font10);
wxFont font11 = Button11->GetFont();
font11.SetPointSize(10);
Button11->SetFont(font11);
wxFont font12 = Button12->GetFont();
font12.SetPointSize(10);
Button12->SetFont(font12);
wxFont font13 = Button13->GetFont();
font13.SetPointSize(10);
Button13->SetFont(font13);
wxFont font14 = Button14->GetFont();
font14.SetPointSize(10);
Button14->SetFont(font14);
wxFont font15 = Button15->GetFont();
font15.SetPointSize(10);
Button15->SetFont(font15);
wxFont font16 = Button16->GetFont();
font16.SetPointSize(10);
Button16->SetFont(font16);
wxFont font17 = Button17->GetFont();
font17.SetPointSize(10);
Button17->SetFont(font17);
}
Last edited by doublemax on Wed Dec 19, 2018 1:03 am, edited 1 time in total.
Reason: Added code tags
Reason: Added code tags
Re: Wxbutton label font resize
Thanks.
This is a little more complicated than it needs to be. The font you get from "Button1->GetFont()" is probably the same for all buttons, so you could just change the font size and then set this font for all buttons.
There is however the problem that the buttons won't automatically resize themselves according to the new font size.
The method i proposed earlier should be simpler: Just set a new (bigger) font for the parent window before creating the buttons and they should all inherit that font size.
If you're using a graphical GUI editor, maybe you can even set a bigger font size there??? (I don't know, because i don't use any GUI editor).
This is a little more complicated than it needs to be. The font you get from "Button1->GetFont()" is probably the same for all buttons, so you could just change the font size and then set this font for all buttons.
There is however the problem that the buttons won't automatically resize themselves according to the new font size.
The method i proposed earlier should be simpler: Just set a new (bigger) font for the parent window before creating the buttons and they should all inherit that font size.
If you're using a graphical GUI editor, maybe you can even set a bigger font size there??? (I don't know, because i don't use any GUI editor).
Use the source, Luke!
-
- Knows some wx things
- Posts: 30
- Joined: Tue Dec 11, 2018 1:38 pm
Re: Wxbutton label font resize
thanks a lot for your reply and advice, like i hinted much earlier i use code::blocks' drag n drop wxwidgets editor to create my projects and i'm a hardcore beginner still figuring my own way around so i sincerely plead for your patience with me!!!doublemax wrote:Thanks.
This is a little more complicated than it needs to be. The font you get from "Button1->GetFont()" is probably the same for all buttons, so you could just change the font size and then set this font for all buttons.
There is however the problem that the buttons won't automatically resize themselves according to the new font size.
The method i proposed earlier should be simpler: Just set a new (bigger) font for the parent window before creating the buttons and they should all inherit that font size.
If you're using a graphical GUI editor, maybe you can even set a bigger font size there??? (I don't know, because i don't use any GUI editor).