Re: warning when no DISPLAY
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. I provide stubs for widgets that really display things, but the general Wx::App stuff (like Wx::ConfigBase) works okay. Why I'm doing this? I have a big Wx app that has some dialogs that do heavy work and now I can run this exact dialog code to do the work automatically from cron jobs. -- Johan
Re: warning when no DISPLAY
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
Re: warning when no DISPLAY
On Sat, Apr 3, 2010 at 2:53 PM, Johan Vromans jvrom...@squirrel.nl 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. I provide stubs for widgets that really display things, but the general Wx::App stuff (like Wx::ConfigBase) works okay. Why I'm doing this? I have a big Wx app that has some dialogs that do heavy work and now I can run this exact dialog code to do the work automatically from cron jobs. A a slightly rhetorical question: Wouldn't it be better to have a clear separation in your code between things not using Wx that can be run without any piece of Wx and the GUI part that is Wx based? We have been trying that in Padre and so far failed miserably. Most notably we need to call Wx::gettext() in many of our non-Wx modules but there are many other cases when could not (yet?) move all the display related code to Wx modules. I am not sure how to proceed and if it worth the effort. We even have a unit test that checks if Wx is mentioned in any of the modules that should be Wx free but it has a long list of exceptions. The only case when we need to run it without DISPLAY is when we want to make sure it can be cleanly repackaged by downstream. Fedora and maybe other distributions require that all their packaging process will be done without DISPLAY. So basically in every unit test we have if it requires a DISPLAY we simply skip it when there is no DISPLAY. Apparently the test I mentioned was not skipped but it does not really require a DISPLAY either as it passes even without one just emitting those warnings. regards Gabor