Johan Vromans wrote:
Mattia Barbon <mattia.bar...@libero.it> writes:

On the one hand it would be nice if "use Wx" wouldn't require a
display. On the other hand, creating a Wx::App will always require a
display, and I'm not sure which wxWidgets classes can be used
without a Wx::App instance.

I'm reasonably successful in running Wx apps without DISPLAY. At
least, apart from the message "Unable to initialize gtk, is DISPLAY
set properly?" nothing seems to blow up.

Strange. I (mis?)remembered the initialization code exiting with an error when it could not access the display.

I provide stubs for widgets that really display things, but the
general Wx::App stuff (like Wx::ConfigBase) works okay.

I was wrong on another account: the classes in the wxBase library are guaranteed to work without a display. This includes wxConfigBase and wxMimeTypesManager.

So the correct answer to Gabor is: if that test only uses classes in the non-GUI part of the library (as it likely does) it should always work.

I'm not sure how to avoid the warning though: for GTK it is emitted by wxApp::Initialize, which is called from the initialization code in wxEntryStart. I'm fairly sure wxEntryStart needs to be called even for console applications; the only difference between the two is that console applications use wxAppConsole as the base class for the application (either explicitly or by using the wxDummyConsoleApp defined inside wxWidgets).

  The way I see to avoid the warning is:
- wxPerl must expose wxConsoleApp
- the call to wxEntryStart must be removed from the loading code and
  moved "later" (probably in Wx::App::new)
- console-only scripts must explicitly use Wx::ConsoleApp or declare in
  some way that they do not want to use the GUI

one problem with this approach is that delaying the initialization might create problems if some wxWidgets classes are used before Wx::App is instantiated.

Regards,
Mattia

Reply via email to