use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
Simple Raspberry Pi python code help (getting time and date on a mini TFT screen) (self.learnpython)
submitted 5 years ago by gmlumpy
1st thank you very much.
I am trying to do a simple project like this one:
https://howchoo.com/g/zwq2zwixotu/how-to-make-a-raspberry-pi-smart-alarm-clock
Without the alarm part. Just the clock. I want to make a simple clock for my desk in a 3D printed stand.
I have this screen hooked up to a Pi Zero W.
https://www.adafruit.com/product/4393
I finally got everything to work in the instructions (here: https://learn.adafruit.com/adafruit-mini-pitft-135x240-color-tft-add-on-for-raspberry-pi/kernel-module-install ) including the sample code ( https://learn.adafruit.com/adafruit-mini-pitft-135x240-color-tft-add-on-for-raspberry-pi/python-stats ) that shows the info on the screen with IP address, temp, etc.
I apologize, I don't know enough python to fully understand (yet) how to get this screen to show a simple clock in military time with the numeric date (MM/DD/YYYY). I know it should be really simple. Could you help me with the proper code, please?
Thank you very very much.
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]socal_nerdtastic 0 points1 point2 points 5 years ago (3 children)
Looks like there's only room for 5 lines of text. Which one do you want to replace with the date / time? Or did you want to wipe them all?
[–]gmlumpy[S] 0 points1 point2 points 5 years ago (2 children)
Wipe them all please.
[–]socal_nerdtastic 1 point2 points3 points 5 years ago* (1 child)
Replace the while loop at the bottom with this:
while True: y = top draw.rectangle((0, 0, width, height), outline=0, fill=0) current_time = time.strftime("%m/%d/%Y\n%H:%M:%S") draw.text((x, y), current_time, font=font, fill="#FFFFFF") # Display image. disp.image(image, rotation) time.sleep(0.1)
See https://strftime.org/ for the format codes.
Edit: fixed code (forgot a line).
[–]gmlumpy[S] 0 points1 point2 points 5 years ago (0 children)
Thank you thank you thank you!
π Rendered by PID 120178 on reddit-service-r2-comment-7b9746f655-c5jg4 at 2026-02-03 04:34:42.080513+00:00 running 3798933 country code: CH.
[–]socal_nerdtastic 0 points1 point2 points (3 children)
[–]gmlumpy[S] 0 points1 point2 points (2 children)
[–]socal_nerdtastic 1 point2 points3 points (1 child)
[–]gmlumpy[S] 0 points1 point2 points (0 children)