title: how to call function after MainWindow fully rendered
body: <p>I would like to call a function when the mainwindow is fully rendered. The problem is that if I call a function (here <code>LoadVideo</code>) at the end of MainWindow, the function is called but the window is not fully rendered (toolbar or background image is missing). It is fully rendered when <code>LoadVideo</code> function is finished. It does the same issue with <code>CallAfter</code></p>
  <pre><code>MainWindow::MainWindow(const wxString&amp; title) : wxFrame(NULL, wxID_ANY, title, wxPoint(0, 0), wxSize(800,600))
  {
      SetIcon(wxIcon(&quot;icon.ico&quot;, wxBITMAP_TYPE_ICO));
      wxBitmap png_1t(wxT(&quot;icon-1.png&quot;), wxBITMAP_TYPE_PNG);
      wxBitmap png_2(wxT(&quot;icon-2.png&quot;), wxBITMAP_TYPE_PNG);
      wxBitmap png_3(wxT(&quot;icon-3.png&quot;), wxBITMAP_TYPE_PNG);
      wxBitmap png_4(wxT(&quot;icon-4.png&quot;), wxBITMAP_TYPE_PNG);
      wxBitmap png_5(wxT(&quot;icon-5.png&quot;), wxBITMAP_TYPE_PNG);
      wxBitmap png_6(wxT(&quot;icon-6.png&quot;), wxBITMAP_TYPE_PNG);
  
      menuBar = new wxMenuBar();
      fileMenu = new wxMenu();
      cameraMenu = new wxMenu();
      toolsMenu = new wxMenu();
  
      menuBar-&gt;Append(fileMenu, _T(&quot;&amp;File&quot;));
      menuBar-&gt;Append(cameraMenu, _T(&quot;&amp;Camera&quot;));
      menuBar-&gt;Append(toolsMenu, _T(&quot;&amp;Tools&quot;));
      SetMenuBar(menuBar);
  
      fileMenu-&gt;Append(wxID_EXIT, _T(&quot;Exit&quot;));
  
      this-&gt;SetBackgroundColour(*wxWHITE);
  
      wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL);
      m_renderWindow = new wxImagePanel(this, wxT(&quot;Logo.png&quot;), wxBITMAP_TYPE_PNG);
  
      sizer-&gt;Add(m_renderWindow, 1, wxSHAPED | wxALIGN_CENTER);
      this-&gt;SetSizer(sizer);
      this-&gt;Layout();
  
      toolbar-&gt;AddTool(10007, _T(&quot;ClosedDevice&quot;), png_1);
      toolbar-&gt;AddSeparator();
      toolbar-&gt;AddTool(10006, _T(&quot;Snapshot&quot;), png_2);
      toolbar-&gt;AddTool(10001, _T(&quot;ContinuousShot&quot;), png_3);
      toolbar-&gt;AddSeparator();
      toolbar-&gt;AddTool(10002, _T(&quot;Pause&quot;), png_4);
      toolbar-&gt;AddTool(10003, _T(&quot;Record&quot;), png_5);
      toolbar-&gt;AddTool(10004, _T(&quot;Stop&quot;), png_6);
      
      toolbar-&gt;Realize();
      Layout();
  
      this-&gt;GetToolBar()-&gt;EnableTool(10006, false);
      this-&gt;GetToolBar()-&gt;EnableTool(10002, false);
      this-&gt;GetToolBar()-&gt;EnableTool(10003, false);
      this-&gt;GetToolBar()-&gt;EnableTool(10004, false);
      this-&gt;GetToolBar()-&gt;EnableTool(10001, false);
  
      CallAfter(&amp;MainWindow::LoadVideo, true);
  }
  </code></pre>
  <p>EDIT :</p>
  <p>Solution :</p>
  <pre><code>Bind(wxEVT_TIMER, [](wxTimerEvent&amp; event) {
    LoadVideo();
  });
  m_timer.SetOwner(this);
  m_timer.StartOnce(2000);
  </code></pre>