Keep one GUI always on TOP while python code is running

Chris Angelico rosuav at gmail.com
Fri Aug 8 10:20:31 EDT 2014


On Fri, Aug 8, 2014 at 11:58 PM, Steven D'Aprano
<steve+comp.lang.python at pearwood.info> wrote:
> Chris Angelico wrote:
>
>> Yeah; like I said, "Don't" is the short answer. There will be
>> exceptions, some extremely rare situations when system modality is
>> correct; but fundamentally, it's impossible to use GUI software to
>> control what a person does with a computer
>
> There are exceptions, but it's impossible? Impossible except for the
> exceptions, I presume :-P

There are exceptions to the rule "you shouldn't use system modal
windows". It is, however, fundamentally impossible for GUI software to
completely control what the person does - system modality is defined
only to the extent of the GUI.

>> (for instance, on all my
>> Linux systems, I can hit Ctrl-Alt-F1 to switch away from the GUI
>> altogether).
>
> Does that work when xscreensaver or equivalent has locked the system? If so,
> that's a security vulnerability.

Absolutely it works! However, what you get to is a terminal with a
login prompt. If you don't know a valid userid and password, you can't
get in. (And if you *do* know them, you can probably get in through
the GUI, too, although it's possible for a screen saver to lock such
that no other account can log in.)

>> So I'm dubious about its value for anything that isn't an
>> absolutely critical alert.
>
> Well, there's at least two use-cases I can think of:
>
> * screen locking, as in screen savers;
>
> * login screens;

With these two, it's deliberately locking only the GUI, so system
modality could be correct. But really, it's more about covering the
whole screen; system modality is more about disabling the whole
screen. So they're still not a perfect match.

> * exam software;

This is what I'm dubious about. Since you can always log in via some
other method, or brute-force something (eg replace one of the system
accessibility programs with your own tool), it's impossible for the
software to stop you from running something else. And if the computer
you're doing this on is so locked down that you can't pull up your
notes in some other app, it may as well simply be so locked down that
you can't get your notes onto that computer in the first place.

> * emulating full screen arcade games;

Why should that disable access to everything else? Most full screen
games let you alt-tab away from them (preferably auto-pausing the
game). If a game goes system modal on me, I would not be happy.

> * my application is SOOOOO SPECIAL that it deserves to take over the
>   entire GUI Just Because I Can.

And that one is definitely not a reason, as I'm sure you agree :)

> I don't know any platform-independent GUI toolkits which offer this out of
> the box, but I expect that there's probably a way to do it in a platform
> specific way on each platform you wish to support.

There may be; there also may not (that is to say, there may be
platform-specific ways on some, but not all, platforms - I'm not sure
Windows has the functionality). But that's par for the course... if
every platform had the exact same features, we wouldn't need multiple
platforms.

ChrisA



More information about the Python-list mailing list