Determining Presence Of GUI Support
Alex Martelli
aleax at aleax.it
Sat Nov 9 02:24:54 EST 2002
Tim Daneliuk wrote:
> Is there a portable method of determining whether the current runtime
> environment supports a GUI or text-based interface? I would like to
> write a single program which autosenses the presentation environment
> and works accordingly.
Well, you could do something like:
try:
import tkinter # or whatever other GUI toolkit you want
except:
# set things for no-GUI
else:
# set things for yes-GUI
but that depends on what you mean by "support" -- it's conceivable
that tkinter might load but then not be able to display anything
because for example X11 isn't started (a rather platform-specific
issue), or because it's started with parameters inappropriate to
the display so the display is actually showing just a jumble of
color streaks (more and more platform-specific), and so on.
Alex
More information about the Python-list
mailing list