Python curses with scrolling terminal - python

I want to build an app on my raspberry pi using Python that uses a curses-style display over part of the screen and keeping the terminal visible (whilst printing scrolling status messages in it) over the rest of the screen. I also want to be able to take user input from the terminal prompt. Is this possible and how would I go about implementing this?

Related

Interact with website without sending keystrokes to window (Python, Windows)?

Is it possible to interact with a webpage loaded into a web browser (such as Chrome) without the window being active and without sending keystrokes to it? For example, suppose I have SoundCloud loaded in chrome and the chrome window minimized, but I want to create a hotkey on my computer (such as through Autohotkey) which acts as a play/pause button for the track. Would it be possible to have a Python script somehow interact with the browser to obtain that functionality without having to send it a keystroke?
The reason I'm trying to avoid having to send keystrokes is because it would require the Window to become briefly maximized and active. I can already do this in autohotkey. For example, I have an ahk script that iterates over all the windows, finds one with Soundcloud in the title, maximizes the window if it is minimized, sends the spacebar keystroke (which acts as play/pause on Soundcloud), and then minimizes the Window again if it was minimized to begin with.
This has the undesirable effect of making the Window flash briefly if it was minimized, or if virtual desktops are used, all the Windows flash if the Chrome window with Soundcloud is located on another virtual desktop other than the active one.
Ideally I could just write some program that runs silently in the background to send some kind of the request to the site that has the same effect as pressing the play/pause button without having to use the janky keystroke method I suggested above. But I am not sure if this is possible. What is actually happening when I click the play/pause button on Soundcloud, and is there some way write a program to get Chrome to do that without using keystrokes?
Any suggestions? I would prefer to do this without any browser plugins if possible.

Is there a way my program can detect if my microphone is being used by any programs? (Windows 10)

SHORT VERSION:
I'm attempting to detect when my microphone is being captured by a program like Discord, preferably in Python, but I can't figure out how to do it. Any suggestions?
LONG VERSION:
I'm trying to write a program that will turn on an "On Air" light whenever my microphone is being used. Typically this would either be for Discord or Twitch. This is something Windows already monitors as well (Windows 10) because it displays a microphone icon down in the notifications tray and tells you what programs are using your microphone. Basically, whenever that icon notification is up, I want my light to be turned on.
The light is currently being run by sending serial commands through Python to an Arduino Nano, but I can only manually tell it to turn on or off.
I can't find a way to access windows privacy monitoring status or make any headway on just checking if a microphone is in use with Python. Any suggestions?
You can lock if the MicrophonIcon is displayed. Presice write an Pythonscript that locks if Pixel at the Position of the MicrophoneIcon having the Color off the MicrophonIcon. qt can do this. It has a python binding.
Get the Position of the MicrophonIcon( you can hover over it with the mouse and use a program to look the position up)
Get some Pixel Colors off the aria with qt
write a loop that checks if the Pixel Colors at the moment are equal to messured ones.
Con: if the Position off the Microphon changes(Screensize, other options that push it, not visable( fullscreen)) It will not work.
If you checke the yello lines in 2 loops it should define the Microphone icon nearly failsafe if the position isnt changing

Uncomplicated window interface for displaying status in python

I am trying to create a window in python where I will be displaying the status of a large system, a bunch of numbers or some LEDs. The idea is that the system sends messages to the display thread and the thread updates different parts of the window, like displaying a number or turning the color of a field. More importantly, the user interacts with system via command line of python interpreter, e.g. executing commands or updating variables.
One may simply suggest that I need to use one of the GUI packages, like pyqt or xwpython. But these modules are designed to build GUIs, that means they have plenty of resources to handle events moues clicks and so on, which I don't need. Also, these modules run a event loop which is a waste of resources as well as in many cases they block the python shell.
I tried to use pyqt without running the main loop. But when I do this windows thinks my application is not responding, and I get a bunch of problems. For example the close button on the window does not work, and any effort on closing it crashes my python session.
Any ideas on how I can implement my application?
Maybe you should consider to use the Apache's Superset dashboard.
Check this up:
https://superset.incubator.apache.org/installation.html
It makes amazing dashboards incredibly easy and useful.

Emulate a mouse click without using the actual mouse on linux

I am working with a program that collects a lot of data then shows it to you in the program. Unfortunately, the program is poorly designed and requires you to "approve" each bit of data collected manually by clicking a checkbox to approve it. In order to automate this process, I wrote a small script that scans for a checkbox, clicks it, then clicks "next item".
Unfortunately, this requires moving the actual mouse, meaning I can't use my computer until the program has finished. There are other questions that reference automating this with the winapi, however none of these work on Linux. What is a way to automate this on Linux?
You can simply start the program in a separate X server, for example using xvfb with
xvfb-run YOUR_PROGRAM
If you want to wrap just the instrumented program, that's possible too:
export DISPLAY=:42
Xvfb :42
THE_INSTRUMENTED_PROGRAMM
xdotool mousemove 1 1 click 1 # your instrumentation goes here

Display fullscreen jpeg on X Server (of Raspberry Pi) using Python 3

I am developing a software in Python that generates static jpeg files, which are written to the file system. The software ist running at startup and gets triggered by some external and internal events, generates the corresponding jpeg image and should show it in fullscreen on the connected HDMI-screen without any visible user control or menu bar.
There is no window manager (Gnome, KDE, ...) installed and running. The device is a passive one and remotely controlled.
I am currently starting a feh process in order to view an image, and kill it before the next one is shown. It works, but is not very satisfying.
Do you have any better idea how I can get my Python 3 program to display the jpeg on the X Server?
Do you really need an X-Server? If you don't any GUI or mouse, you may be better writing the pictures into the framebuffers without X-Server. You can simply use fbi for this.
Use feh with one of the --bg- options. This sets the background of the root X window, and then exits. So you don't have to deal with killing feh to restart it, just call the command every time you want to change the image.
feh --bg-scale image1.jpeg
This doesn't work with some desktop environments (kde, gnome, xfce, and others), but will work with lightweight window managers (evilwm, goomwwm, etc.) and will also work with no window manager.

Categories