How to Simulate Key Presses in Python
I have been searching the web but have been unable to find ANYTHING that is for Linux and that can type sentences, not just letters. I have a Tkinter textbox and I have been trying to find out how to make the program be able to type in the Tkinter textbox. For solutions, I have found things like the SendKeys module but these don't work as they are only for Windows. So if anyone knows how to make python code be able to type in a Tkinter textbox, or know a module that simulates keypresses in python, PLEASE let me know. Thanks!
Voters
is this good?
If that doesn't work, then try pyautogui
If neither work, that means repl.it is bad, and you should report to bugs
gl
@Futuristicssend repl
@Futuristicsaweesome gl
@Futuristicssend the error
@FuturisticsFile "main.py", line 5, in
import pyautogui
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/pyautogui/init.py", line 242, in
import mouseinfo
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/mouseinfo/init.py", line 223, in
_display = Display(os.environ['DISPLAY'])
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/Xlib/display.py", line 80, in init
self.display = _BaseDisplay(display)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/Xlib/display.py", line 62, in init
display.Display.init(*(self, ) + args, **keys)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/Xlib/protocol/display.py", line 53, in init
name, host, displayno, screenno = connect.get_display(display)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/Xlib/support/connect.py", line 62, in get_display
return mod.get_display(display)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/Xlib/support/unix_connect.py", line 47, in get_display
raise error.DisplayNameError(display)
Xlib.error.DisplayNameError: Bad display name "MAGIC"
oh, use pygame instead
@Futuristicsoh wait you are already on a repl that has a pre-built display?
@Futuristicsso pygame and tkinter repls have a built-in display
@Futuristicsoh, make a tkinter repl
@FuturisticsError:
Repl.it: Installing fresh packages
ERROR: Can not perform a '--user' install. User site-packages are not visible in this virtualenv.
WARNING: You are using pip version 20.1.1; however, version 20.2.3 is available.
You should consider upgrading via the '/opt/virtualenvs/python3/bin/python3 -m pip install --upgrade pip' command.
Repl.it: package installation failed!