Search code examples
c++wxwidgets

Making a GUI is hard


I have made these 2 sketches that represents what im trying to make. When I compile the code I want a frame with 1 button that says "start", to appear (aka sketch 1). When I click start the start button goes away and a new button appears that says "pick up" and 3 panels that has a starter value of 0. When you click on the button, 1 of the 3 panels randomly picked will get +1 in value and the value in the panel will update and show the total value in that panel (SKETCH 2).

I hope you understand the idea, and I would like to know if this Is possible first ofc. And if you have an idea of where I could start, I would love to hear it (:

SKETCH 1 Sketch 1 SKETCH 2

Sketch 2


Solution

  • @user13170084,

    You don't need to scale anything!!

    In you wxFrame create a function that will what you want.

    Bind wxEVT_BUTTON to the wxButton click and wxEVT_LEFT_DOWN to the panel. There call that function.

    Now - this will be one weird design. You may need to rethink what you want to do.

    void MyFrame::Handler()
    {
    }
    
    MyFrame::MyFrame()
    {
        panel = new wxPanel();
        button = new wxButton();
        panel->Bind( wxEVT_LEFT_CLICK, &MyFrame::OnClick, this );
        button->Bind( wxEVT_BUTTON, &MyFrame::OnButton, this );
    }
    
    void MyFrame::OnClick()
    {
        Handler();
    }
    
    void MyFrame::OnButton()
    {
        Handler();
    }