I want to control games with python. I need python to act like a game controller and do what i code.
I couldn't find things about this. I'm waiting for your help. Thanks.
edit : I pretty much did it with using PyvJoy library and vJoy software. Its now possible python to act like game controller and press keys. This can be useful while developing machine learning apps.
Here's an example code I used a while ago in order to read inputs from an xbox controller hooked-up via the USB port and use them inside Python:
my GitHub
It relies on the pyGame module:
https://www.pygame.org/news
Related
Im trying to find a way send inputs to XINPUT buttons for a controller that is already plugged in. So the one python repo (vjoy/pygame) wouldn't work since it "adds" a controller.
Does anyone know if this exist?
For a similar comparison I am able to have python trigger buttons on my keyboard by using Direct X scancodes and Sendkeys but I could not find scan codes for Xinput or controllers.
Thanks again!
I think what you want is a virtual xinput controller. If so, you should check out the relatively new but excellent vgamepad library. It's a wrapper around vigem, so you can send your keys to a virtual Xbox controller.
I hope that answers your question.
I am making a facial recognition attendance system using python on a Raspberry Pi. When each person is detected in the frame, I want a beautiful GUI which should display the name of the detected person along with a good morning message and so on. How can I do this in python?
using python? I never succeeded to make something beautiful with PyQt or Tkinter (maybe you too).
You can use a webserveur using, for example, flask and make it beautifull with angular or simple html/CSS code.
Or you can also try Kivy which is quite nice to see and easy to code :
https://kivy.org/#home
here are some examples:
https://kivy.org/#gallery
it's really easy to learn and to use.
Does anybody know of an easy module to interact with MPRIS and write metadata to it?
I'm trying to get a music player working with the OS, and I'm using VLC [python-vlc] as it's backend. If you can help me out find any module that allows me to easily write metadata, thanks.
Modules I've tried:
playerdo - Only reads metadata
playerctl - Only reads metadata
modipy-mpris - Doesn't work
mpris-server - Breaks constantly and generally a pain to set up
vidify - Not what I've wanted
VLC docs: https://www.olivieraubert.net/vlc/python-ctypes/doc/index.html
NOTE: This is not what my player looks like, this is KDE's Applet allowing me to see what is playing. I'm sure windows has something similar, but the most important thing is I need to be able to play and pause music from anywhere in the OS with the play/pause button on my keyboard or bluetooth device
Example of output: KDE Plasma Applet
Use MPRIS-SERVER but read the issues.
Still a pain to set up but at least it works properly.
I am currently working on the final year project for my degree. I have chosen to research and develop a tool to aid the delivery of the new Computing curriculum that is coming to schools next year.
I am using a Raspberry Pi in my development, and I aim to teach extremely basic Python programming to children between the ages of 8 and 10. They are going to be able to control some hardware attached to the Pi using a simple API that I am going to create.
My question is: I would like to be able to create a GUI for the children to work in, which would allow them to write and compile scripts. This is mainly to get away from the unfamiliar interface of Linux and terminals etc, and put them in a friendly, basic interface which will pretty much just allow them to write their code and click a big red button to compile and run it to interact with the hardware. Is it possible to allow for text to be written in a GUI and then compiled when the button is pressed?
I am pretty new to Python myself so I am not as clued up as I'd like to be about the specifics of it. I know that it is possible to have the output of IDLE inside of a tkinter interface, and that it is possible to have text boxes for user input and stuff, but would it actually be possible to compile a script on button press and then run it? I have been thinking that maybe threading is the answer. Perhaps I could create a new thread to do it when the button is pressed?
My apologies if this is incredibly basic, but I am having no luck finding any answers about how I would do this. I think it's mainly because I am unsure on what exactly to ask for.
I appreciate any feedback/help, thank you very much.
Dell
Have your GUi write the Python code to a file, then dynamically import using the imp module. I actually do something similar :-)
import imp
hest = imp.load_source("Name", Path)
So I've been tinkering with a few different GUI's but I haven't been able to even find a point to begin researching this question:
How do I make a GUI like Steam (Digital distribution app) has? More specifically, I'm interested in how they manage to make their SHIFT+TAB menu pop up in-game, without disrupting/pausing/effecting the game. I've been somewhat successful in making a GUI window "stay on top" when a game is in window mode, but Steam pops this little menu up over the top of a running, fullscreen game.
That's what I'm interested in learning about. Any info would be much appreciated. :)
Sorry if this isn't the correct place to post this. I wasn't sure exactly where to ask.
PS> Preferably something I could implement in Python!!!
The Steam overlay/notification system hooks into games via Direct3D or OpenGL in Windows (depending on the game) from my understanding (as it doesn't work for games that aren't Direct3d/OpenGL like Diablo).
It uses the same rendering libraries that the game uses and thus can overlay their menus natively.
As for Python implementations, you can check out http://directpython.sourceforge.net/ and http://pyopengl.sourceforge.net/ as a start (for DirectX and OpenGL libraries respectively) but can I warn you that I don't think this is as simple as you're hoping.
Hmm, that looks very much like they are using Adobe AIR or maybe Flash.