Keep one GUI always on TOP while python code is running

Steven D'Aprano steve+comp.lang.python at pearwood.info
Fri Aug 8 09:58:56 EDT 2014


Chris Angelico wrote:

> On Fri, Aug 8, 2014 at 6:57 PM, Paul Rudin <paul.nospam at rudin.co.uk>
> wrote:
>> Chris Angelico <rosuav at gmail.com> writes:
>>
>>> On Fri, Aug 8, 2014 at 3:57 PM, Jaydeep Patil <patil.jay2009 at gmail.com>
>>> wrote:
>>>> I mean to say, One GUI should be always on top from start to end of
>>>> code running. So that user cant do any other operation.
>>>> I am using wxpython
>>>
>>> Ah, that would be called "System Modal", and should be reserved for
>>> absolutely critical system-wide alerts. It's also a feature that's
>>> simply not available to most user-space programs, and not available in
>>> most GUI toolkits.
>>>
>>> Short answer: Don't.
>>
>> There are commercial software packages that do this sort of
>> thing. Examsoft is one - the idea being that people can take exams
>> without access to other software at the same time (so that, for example,
>> they could look at previously prepared notes).
> 
> 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

> (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.


> 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;

* exam software;

Eh, that is, at least three use-cases:

* screen locking;

* login screens;

* exam software;

* emulating full screen arcade games;

Um, among the use-cases are, screen locking, login screens, exam software,
full-screen games, critical system alerts, and, of course, the most popular
reason of all:

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

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. Either that, or the OP
can google for <wxpython "system modal"> (including the quotes) and see
what comes up. I'd do so myself, except some damn fool Javascript code
running on some rubbish web site just crashed my browser. Again.



-- 
Steven




More information about the Python-list mailing list