Jump to content

Python - pygame


InunoTaishou
 Share

Recommended Posts

Got this idea a long time ago to create a really neat project using a raspberry pi, camera, some custom python code, and a monitor I pulled from an old laptop. The idea is to create an interactive and informational display using the monitor and it will hang on my wall. Custom code will display the time, date, weather forecast, and current events. Has a temperature/humidity for the room (also shown on the display) and a motion censor. Censor will be enabled when I enter the pin for when I leave my room, and turned off when I come back and re-enter the pin. Once the censor is enabled (my security feature is enabled) it will activate the camera, taking a snapshot as soon as it's triggered, email me the screenshot, and then continue to snap pictures every second. Once the person has left my room, zips everything up and then emails me the zip file. Figured it was a good way to play with python, play with the raspberry pi, and make sure anyone coming to my room isn't doing anything sneaky (since I live in the dorms)

Started the code today and had to figure out how to draw a string like _GDIPlus_GraphicsDrawStringEx. Because I wanted to define movable areas to render all of my text (so the position of the text is dynamic, and can be moved around and the position changed whenever I want to). Since pygame doesn't have anything like that, and it doesn't support multi-line text, let alone aligned text, I had to come up with how to allow multi line, then moved onto alignment, and make sure everything fit inside the defined area, not drawing any extra text that would "bleed" outside the rect

Here's the progress of the text. The greetings text has the left alignment, top line alignment. Time and date have center and center, and fps actually has the whole screen as the rect but uses right alignment + bottom line alignment, making it show in the bottom right corner

UaQRpra.jpg

PW1o90g.png

Source can be found on github for anyone interested

This is way incomplete, probably gonna take months to get to the final product, but I predict I'll need to draw text in a defined area a lot.

Edited by InunoTaishou
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...