r/learnpython • u/glof2 • Jan 09 '20
I wrote an application that sets your background to NASA's picture of the day!
After some research I figured out that someone already came up with this idea (Great minds think alike!), but he took slightly different approach to this, and his is more advanced I guess. I just wanted to make something for fun, so don't expect this to be even slightly as good as his. Even if I tried it wouldn't be half as good. You can find his attempt at this here.
---------------------------------------------------------------------------------------------
Anyway mine is windows only, and you can find the code here.
Any adviced would be appreciated.
Thanks in advance!
4
u/panoptictechguy Jan 10 '20
This is really cool, thanks for sharing. Hope you don't mind but I transposed this for Linux (Mint/Ubuntu), the file is here. I also took out the loop, I'll just cron it on Linux :)
Ultimately I'd want to have it OS agnostic and detect the OS (with sys.platform for example) and adjust accordingly
3
u/glof2 Jan 10 '20
That's not a problem, I originally wanted to do that, but I could not figure out how to set a file as wallpaper on Linux (Google didn't give me answers). I was going to use sys.name() if that helps you. Anyway have fun coding!
3
u/panoptictechguy Jan 10 '20
On Ubuntu/Mint you use the "gsettings" command to set it from the command line so I just use the OS module to issue the command line command. There's probably a better way but this was easy and worked.
3
u/glof2 Jan 10 '20
Okay, thanks for telling me, I never used Ubuntu terminal in my life lol, again have fun coding, and make sure to message me once you finish it, I'll be glad to check it out!
4
u/LightUmbra Jan 10 '20
One note. time.sleep() can have problems over long periods of time and normally shouldn't be used for this type of scheduling (I can't really explain the reasons, but there are probably some good articles on it). The best way to do it would be to take advantage of your os's scheduler, Task Scheduler for windows and cron for Linux. You can set it to run pythonw.exe wallpaper_thing.py once every hour and it will run better.
2
5
u/Ertersy Jan 10 '20
hey, this is awesome and i tried to get it to work but it isn't changing the background...
I put it in the appdata file and it's a .py file but doesn't change anything. Anything I'm missing? I would really love it if i could get this to work, thanks!
0
Jan 10 '20
[deleted]
4
u/Ertersy Jan 10 '20
I've set python to default launch but even when i manually launch it, it just doesn't change the background... Thanks for the speedy reply
7
u/glof2 Jan 10 '20
Okay, did you unzip it?
3
u/Ertersy Jan 10 '20
perhaps not... how would i do that?
4
u/glof2 Jan 10 '20
Nevermind I think I know what happened, could you open your command prompt, and drag the .py file over to it? It should automatically type the .py file path for you, from there just click enter and tell me what happens
3
u/Ertersy Jan 10 '20
Traceback (most recent call last):
File "AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\nasa.py", line 2, in <module>
from bs4 import BeautifulSoup
ModuleNotFoundError: No module named 'bs4'
6
u/glof2 Jan 10 '20
Yup, just as i thought, open your command prompt as an administrator and type in "pip install BeautifulSoup4" and then "pip install requests" you should be able to launch the program now!
3
u/Ertersy Jan 10 '20
Thank you so much! Got it!
This is awesome! You have been so helpful, thanks for being a legend!
5
u/glof2 Jan 10 '20
No problem at all! You can add me on Discord: MayooXD#2527 if you ever need help! Also somewhere in this post I posted some learning resource links, you can check them out. Good luck in learning the language, and never give up!
5
2
u/TwoThirteen Jan 10 '20
From this site? https://apod.nasa.gov/apod/astropix.html
1
u/glof2 Jan 10 '20
From this site: https://apod.nasa.gov/ to be more specific, it redirects you to the newest picture of the day, so the program works no matter what day it is!
2
u/killerinstinct101 PhoenixFlame101 Jan 10 '20
That's pretty cool! I do something similar but with the top images from r/wallpapers.
Edit: I suggest you get rid of time.sleep() and use windows task scheduler (or something similar).
1
2
2
u/buleria Jan 10 '20
filepath = getcwd() + r"\\" + filename
You shouldn't do that, even though you target windows only. Check https://docs.python.org/library/os.path.html#os.path.join for a proper way.
1
2
u/pakayahey Jan 10 '20
How to install this ?
2
u/glof2 Jan 10 '20
Go to the github gists link i provided (here), and in the top right corner you have "download as zip". Click that and after it downloads, unzip it. Write back if you have any more issues!
18
Jan 09 '20
That’s such a cool idea. You got me feeling inspired to come up with an idea as good as this one!
10
u/gtmattz Jan 09 '20
Funny, when I was teaching myself python years ago this was one of the things I came up with to learn on, except it was pictures of the sun from the SOHO site.
6
u/RicealiciousRice Jan 09 '20
Woah you can do this?!?! Makes me really want to learn to program!!
0
Jan 09 '20
[deleted]
11
u/RicealiciousRice Jan 10 '20
Lol I’m sorry if I come off sarcastic. I genuinely think this is cool. And thanks!
3
Jan 09 '20
That's dope!
0
Jan 09 '20
[deleted]
2
Jan 09 '20
Trying to get my skills up to snuff with yours hahaha
0
Jan 09 '20
[deleted]
4
Jan 09 '20
Thanks a ton for typing this up
I'm in Jose Portillas Udemy class on DA right now but will be sure to check out automate the boring stuff!
1
Jan 10 '20
This is cool and all that, but display fusion already does this. Not saying your effort and work wasn't necessary, or warrants praise.
I'm glad you did something cool, and I hope you learned something along the way.
0
Jan 10 '20
[deleted]
1
u/glof2 Jan 10 '20
You definitely should, it's fun. So good luck and have fun coding, I'm glad this could inspire you lol, thanks
0
Jan 10 '20
[deleted]
1
u/glof2 Jan 10 '20
"user32.dll is a module that contains Windows API functions related the Windows user interface (Window handling, basic UI functions, and so forth).", " ctypes is a foreign function library for Python. It provides C compatible data types, and allows calling functions in DLLs or shared libraries. "
3
131
u/El_Derogator Jan 10 '20
I work at NASA as a software engineer and I’m going to use this to set my work backgrounds.