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
@Coder100 Thanks for the speedy answer. But no, I have tried that already and for some reason it brnigs up some errors in Tkinter for Repl
@Coder100 Ok let me test it
gl @Futuristics
@Coder100 Thanks! But for some reason its taking forever to load
send repl @Futuristics
@Coder100 Wait its starting let me check it
aweesome gl @Futuristics
@Coder100 Pyautogui doesn't work
@Coder100 First of all it took 20 minutes for everything to load, second of all when run it gave an error. I'm gonna try it one las ttime to see if it works
send the error @Futuristics
@Coder100 Traceback (most recent call last):
File "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"
@Coder100 I sent you the error
oh, use pygame instead @Futuristics
@Coder100 Would Pygame be compatible with tkinter?
oh wait you are already on a repl that has a pre-built display? @Futuristics
@Coder100 What do you mean?
so pygame and tkinter repls have a built-in display @Futuristics
@Coder100 I made a python project, and am using tkinter in it
oh, make a tkinter repl @Futuristics
@Coder100 And what would that fix?
@Coder100 When I put it in Tkinter, I got an error when trying to import some modules.
Error:
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!
@Coder100 Please answer quickly. Thanks!