Day 6/100 100 Days of Code
Info hunter

AKA Chris, is a software developer from Athens, Greece. He started programming with basic when he was very young. He lost interest in programming during school years but after an unsuccessful career in audio, he decided focus on what he really loves which is technology.
He loves working with older languages like C and wants to start programming electronics and microcontrollers because he wants to get into embedded systems programming.
I worked with my web scraper today. I tried to implement a frame that appears when a search is being executed to let the user know what is happening. This solution is quite ugly since a new window needs to appear while the main window just sits there unresponsive.
I think the solution to this is to run the search on another thread. This way, the GUI stays responsive while a search is running in the background. So, the next task I have to complete is to learn about multithreading.
Here's the code I experimented with but I didn't get the results I wanted.
// This frame should run without being affected by the
// scraping process
class PleaseWaitFrame : public wxFrame
{
public:
PleaseWaitFrame();
~PleaseWaitFrame();
// Frame Elements
private:
wxStaticText *waitFrameText = nullptr;
wxButton *stopButton = nullptr;
wxPanel *mainPanel = nullptr;
wxSizer *mainSizer = nullptr;
wxSizer *textHolder = nullptr;
// States
private:
enum elements
{
eID_Panel = 0,
eId_StopButton,
eID_FrameText,
eID_Frame
};
// Methods
private:
void OnExit(wxCommandEvent &event);
};
void PleaseWaitFrame::OnExit(wxCommandEvent &event)
{
close(true);
}
PleaseWaitFrame::PleaseWaitFrame(): wxFrame(nullptr, eID_Frame, "Please wait")
{
mainSizer = new wxBoxSizer(wxHORIZONTAL);
textHolder = new wxBoxSizer(wxVERTICAL);
mainPanel = new wxPanel(this, eID_Panel, wxDefaultPosition);
waitFrameText = new wxStaticText(mainPanel, eID_FrameText, "Please wait while it runs",
wxDefaultPosition, wxDefaultSize, 0);
textHolder->Add(waitFrameText, 1, wxEXPAND);
mainSizer->Add(textHolder, 0 , wxEXPAND);
mainPanel->SetSizerAndFit(mainSizer, true);
}
PleaseWaitFrame::~PleaseWaitFrame()
{
waitFrameText->Destroy();
mainPanel->Destroy();
}
The following code didn't work when a search was running. It did work in other events.
auto getDisplaySize = wxGetDisplaySize();
waitFrame->SetSize(getDisplaySize.GetWidth() * 0.1f,
getDisplaySize.GetHeight() * 0.1f);
waitFrame->Show(true);




