[Lazarus] Startup environment: to Gui, or not to GUI?

Tony Whyman tony.whyman at mccallumwhyman.com
Tue Apr 11 12:32:25 CEST 2017


This question could be reformulated as "How do I dynamically determine 
the correct GUI to use or whether to use the nogui interface."

My understanding is that Lazarus programs usually do this at link time 
as a result of setting the LCL_PLATFORM environment variable. This 
forces the requested GUI's "interfaces" unit to be included which, in 
turn, has an "initialization" section that calls the "CreateWidgetSet" 
procedure for the selected GUI.

Although I've never tried this, I would have thought it possible to 
build with LVL_PLATFORM=NOGUI and dynamically to test for a platform 
specific GUI. If present, then "FreeWidgetSet" can be used to unload the 
NOGUI and a call to CreateWidgetset used to load the required GUI e.g. 
under Linux:

CreateWidgetset(TGtk2WidgetSet);

with InterfaceBase and Gtk2Int in the uses clauses.

Just an idea,

Tony Whyman

MWA


On 11/04/17 10:15, Mark Morgan Lloyd via Lazarus wrote:
> Apologies if this is an FAQ.
>
> Is there an orthodox way that a Lazarus program can very early on look 
> at how it's been started and decide whether it can usefully fall back 
> to a text mode, e.g. to display help info on stdout rather than a 
> messagebox?
>
> I'm tinkering with something (a media test program for SDCards etc.) 
> which I'd like to either run as a conventional console program, or 
> using a GUI. I've previously written stuff where operation was 
> entirely dependant on command-line options, but haven't tried making 
> the decision completely automatically.
>
> Current operating environment is KDE on Debian on an RPi.
>



More information about the Lazarus mailing list