On Fri, 14 Feb 2020 21:05:30 +0100, "R.Wieser"
declaimed the following:
>As for those links ? I do not really like having to install a different
>version of Python just to be able to check for a key being down. Sorry. (I
>saw that, IIRC, PyGames offered something similar).
>
wxPython is not a "different version of Python". It is a /library/ used
by Python, just as Tkinter is a library.
In either case, the application likely has to start AS a GUI
application, meaning it will have an event loop and /focus/ in order to
detect the keyboard state. It could then, if no modifiers are down, destroy
the event loop and associated GUI window, and revert to a background task
with no user interface features.
Probably easier to set up two shortcut icons -- both of which invoke
the same application, but which have different start-up command lines. One
results in direct/background execution, the other triggers setting up the
GUI.
wulfraed@ElusiveUnicorn:~$ cat background.py
#!/usr/bin/env python3
import sys
import os.path
print(sys.argv[0])
fname = os.path.basename(sys.argv[0])
if fname == "background.py":
print("Not GUI?")
elif fname == "config.py":
print("Do GUI?")
else:
print("I don't know what to do!")
wulfraed@ElusiveUnicorn:~$ ln -s background.py config.py
wulfraed@ElusiveUnicorn:~$ ls -l
total 0
-rwxrwxrwx 1 wulfraed wulfraed 254 Feb 14 19:41 background.py
lrwxrwxrwx 1 wulfraed wulfraed 13 Feb 14 19:41 config.py -> background.py
wulfraed@ElusiveUnicorn:~$ ./background.py
./background.py
Not GUI?
wulfraed@ElusiveUnicorn:~$ ./config.py
./config.py
Do GUI?
wulfraed@ElusiveUnicorn:~$
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com http://wlfraed.microdiversity.freeddns.org/
--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | FidoUsenet Gateway (3:770/3)
|