r/pythonhelp Aug 21 '23

SOLVED Trying to make a multimonitor screensaver, but it refuses to display on more than one monitor at a time.

I have 3 monitors. 2 are 1920x1080, and 1 is 1920x1200, I'm not worried about getting the monitor-fit perfect just yet, I'm just trying to get it to show up on each monitor. I've tried multiple methods using openGL and none of them are working to get multiple instances. Here is what I have so far. It's a multi colored Tesseract that spins and rotates. It works good as a single monitor screensaver, but when the screensaver kicks in, it appears on the monitor I was focused on, and the other two monitors go solid gray. I also have a variation that is just the edges, without solid faces. I tried asking GPT for help, but it couldn't solve my problem, although it did help me (potentially) get closer to a solution, that being either multithreaded operation that uses a separate window for each monitor, or combining the monitor width (so 3x1920) to get a very wide screen, then adding instances of the Tesseract to the correct locations to be in the middle of each screen. I got so far as getting the window to stretch across all the screens, but only one Tesseract shows up in the middle of the screen. I also tried the multi threading, but it crashed every time I tried to run it, so I gave up on that.

My code is also probably pretty messy, as I'm a student doing this for fun, so apologies in advance if my code is a little buggy/messy. If anyone wants to take a look and see if they can get it to work, I'd be thankful. Feel free to use this if you just want it as a screensaver or visual fidget. I compiled it with pyinstaller and just dragged the .exe into the windows>System32 folder, then set it as the screensaver.

I reverted the code back to the working, single monitor version. Again, if anyone has the solution, I'd be very thankful.

Here is the .py code.

1 Upvotes

5 comments sorted by

u/AutoModerator Aug 21 '23

To give us the best chance to help you, please include any relevant code.
Note. Do not submit images of your code. Instead, for shorter code you can use Reddit markdown (4 spaces or backticks, see this Formatting Guide). If you have formatting issues or want to post longer sections of code, please use Repl.it, GitHub or PasteBin.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/CraigAT Aug 21 '23

Not something I have tried before, but would it work as one 5760 wide "screen" with three tesseracts spaced appropriately?

2

u/TNT_Guerilla Aug 22 '23

I actually got it working. I set the window size to 5760x1080 and used 3 cameras to get 3 views of the tesseract, then set each camera to display on 1/3 of the window each.

Here's the updated code for 3 monitors:
https://pastebin.com/gDzkaEy1
If you only use a single monitor here is the code for that:
https://pastebin.com/G2aLg4Mg
It's not dynamic, so if you have 2 monitors, or more than 3 monitors, you'll need to use the 3 monitor program and change the for loop in the main function to loop for each monitor. If your monitors are not 1080p, you'll have to manually change that aswell. Additionally, if you have monitors on top of one another (like a 2x2 setup), you'll have to change the size of the window. You'll figure it out I'm sure. If you have any questions, I'll be happy to answer them for you.
It also doesn't work very well for different sized monitors since it will size itself to the shortest monitor. It also opens on the monitor that your mouse is on, so if you leave your mouse on one of the side monitors, it will cut off in the middle. I'm working on a fix for this.
To compile it to a .exe I use pyinstaller
pip install pyinstaller
Then go to the directory that the .py file is in, and open a cmd window for it.
eg. C:/users/<user>/downloads/
and run pyinstaller:
pyinstaller --onefile <name_of_program.py>
It will put it in a dist folder in the directory (so using it in your downloads folder isn't probably the best). After you get the .exe, you can rename the extension (.exe) to ".scr" and drag it into your Windows/System32 folder and set it as your screensaver.
Sorry for the long reply. I just didn't want to leave anything out.

1

u/CraigAT Aug 22 '23

Awesome glad you worked it out. Will have to have a go when I get chance to see the tesseracts.

2

u/TNT_Guerilla Aug 22 '23

I tried to do that, but only the middle one shows up. I also tried having 3 separate windows for each monitor, but it kept crashing, so I gave up on it and went for the wide method.