1

I am developing on Ubuntu Linux using wxWidgets and I'm having a problem displaying an html file on the file system within a wxFrame. The wxFrame pops up but there is no HTML content in the window.

Here is a snippet of my OnInit() function:

//wxIMPLEMENT_APP(MyApp);
IMPLEMENT_APP_NO_MAIN(MyApp);
IMPLEMENT_WX_THEME_SUPPORT;

bool MyApp::OnInit()
{    
    MyFrame *frame = new MyFrame();

    wxInitAllImageHandlers();
    wxFileSystem::AddHandler( new wxMemoryFSHandler );
    wxFileSystem::AddHandler( new wxInternetFSHandler );

    HtmlWindow * htmlWindow = new HtmlWindow(frame);
    htmlWindow->SetRelatedFrame(frame, "HTML");
    htmlWindow->SetRelatedStatusBar(0);

    wxString htmlFile = wxString("[FULL_PATH]/file.htm");

    wxFileName htmlFileName(htmlFile);
    htmlWindow->LoadFile(htmlFileName));
    frame->Show(true);
    return true;
}

As an experiment I replaced LoadFile with SetPage and saw content in the wxFrame:

htmlWindow->SetPage("<html><body>"
                    "<h1>TEST</h1>"
                    "Set Page Works"
                    "</body></hmtl>");

When I put file.htm in a browser I see the display fine. For some reason it doesn't want to display within the wxFrame. Please let me know if I'm missing anything. All help is much appreciated.

If someone could post a very simple stripped down wxApp, wxFrame, and wxWindow code that simply displays a local htm file that would be great. I've been struggling for so long it is getting frustrating.

Ankur Shah
  • 125
  • 12
  • what version of wx? what version of gtk? how the wx was configured? can you reproduce it in the html sample? – Igor Aug 01 '18 at 21:00
  • Here is the wx-config output: $ wx-config --libs -L/usr/lib/x86_64-linux-gnu -pthread -lwx_gtk2u_xrc-3.0 -lwx_gtk2u_html-3.0 -lwx_gtk2u_qa-3.0 -lwx_gtk2u_adv-3.0 -lwx_gtk2u_core-3.0 -lwx_baseu_xml-3.0 -lwx_baseu_net-3.0 -lwx_baseu-3.0 – Ankur Shah Aug 01 '18 at 21:10
  • did you build the library yourself? Did you used default configuration? Did you try to debug the application? Is it reproducible in any of html samples? – Igor Aug 01 '18 at 22:47
  • I installed the library for wxWidgets and gtk using Ubuntu "apt-get" I have created a separate application to see if I could get a local htm displaying. – Ankur Shah Aug 01 '18 at 23:42

1 Answers1

1

The file you load is obviously not found. Do you specify it as a valid URI, i.e. using file:///path/file syntax?

VZ.
  • 21,740
  • 3
  • 39
  • 42