Keep one GUI always on TOP while python code is running

Chris Angelico rosuav at gmail.com
Fri Aug 8 05:32:22 EDT 2014


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 (for instance, on all my
Linux systems, I can hit Ctrl-Alt-F1 to switch away from the GUI
altogether). So I'm dubious about its value for anything that isn't an
absolutely critical alert. With the OS/2 Presentation Manager, I had
SystemModal available as a window flag, and I used it for two
purposes: an out-of-memory alert (or similarly critical resource
shortage), and a pseudo-login screen (it just asked for a name, no
password or anything, and it didn't change what you had access to - it
was for the purposes of logging and messaging identification, nothing
more); and the latter didn't really need to be system modal, it was
just for convenience.

If there's no way to make a wxpython window system modal, I would say
it's no great loss. The chances of the feature being misused are
extremely high; the cases where it's actually needed are extremely
rare. Hence my short answer of "Don't"; honestly, there are more times
when you need to optimize Python code for performance than there are
times to create system modal windows.

ChrisA



More information about the Python-list mailing list