“We program crutches and bicycles as best we can.”
The history of the emergence of “brilliant” ideas
Walking through the vast rubble on my working slot, I realized that something was missing from it. And so the “brilliant” idea came to decorate the background of the desktop in any way. And of course, I decided to use python – easy, angrily.
Pillow- generate the picture itself on the wallpaper.
ctypes – needed to get screen resolution, mouse position and actions.
win32gui – keeping track of the current window.
To begin with, I just wanted to display the day of the week and time in the center of the screen. So I did, but this was not enough and I decided to output the load on the CPU and RAM. But I had to refresh the desktop frequently (every second), and this turned out to be not the best idea due to the load on the CPU, and even with my i3.
As a result, I had to go back to the every minute update. However, I decided to add exchange rates And weather. And it turned out something like this.
But this was not enough for me, having figured out how to track the position and status of the mouse, I decided to make a “functioning” wallpaper that would respond to clicks ??? Sounds stupid and weird, but why not.
By adding a check for mouse clicks and clicks on certain parts of the screen (Buttons) during the wait, I managed to do this:
When you click on the name of the city, in the same place this appears:
And here, by clicking on the desired city, you can select it and the weather will be displayed from this city.
As it turned out later, I did not take into account the fact that the reaction to pressing will always occur, with any open window.
Gust of the Internet for half an hour – found the library win32gui allowing to get the focused application thus now we react only when the focus is on the desktop.
Why not make a “change theme” button?
After a while we have a button Change the topic in the lower right corner.
Adding your own themes is quite easy and simple.
I also hastily added saving settings and configuration that you can edit yourself by opening the file “\resources\cache\settings.json” as text.
You can change both cities with weather and currencies. The functionality is small, but you can implement a huge number of ideas, you only need imagination.
To autoload along with Windows, it is enough to put one .bat file into autoload.
We go into startup: Win + R -> “shell: startup”.
We create a .bat file in the “Startup” folder and write it there.
Python version may vary. pythonw.exe – runs python files without a console (in the background) An example of a batch file will be in the source code.