Current Date/Time [ANSWERED] #36
-
Hey, is it possible to have the current Date/Time displayed at the top or bottom? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 2 replies
-
Yes it wouldn't be too hard to put the time on. It's basically the same code as for the name/date/location but a bit simpler, without fading and probably with a separate thread to refresh it every second. I'll post something here when I get a moment (probably not today now!) |
Beta Was this translation helpful? Give feedback.
-
Hi, this is the kind of thing you could do import threading #this should be at the top with other imports
...
text_bkg.set_shader(back_shader)
text_bkg.set_material((0, 0, 0))
################################################################################
# show time code ###############################################################
tm_text = pi3d.PointText(font, CAMERA, max_chars=10, point_size=config.SHOW_TEXT_SZ)
tm_textblock = pi3d.TextBlock(x=-DISPLAY.width * 0.5 + 50, y=DISPLAY.height * 0.4,
z=0.1, rot=0.0, char_count=9,
text_format="{}".format(" "), size=0.99,
spacing="F", space=0.02, colour=(1.0, 1.0, 1.0, 1.0))
tm_text.add_text_block(tm_textblock)
tm_text_bkg = pi3d.Sprite(w=120, h=40, x=-DISPLAY.width * 0.5 + 100, y=DISPLAY.height * 0.4, z=4.0)
tm_text_bkg.set_shader(back_shader)
tm_text_bkg.set_material((0, 0, 0, 0.3))
def update_tm_text():
while True:
time.sleep(5.0) # only showing HH.MM so accurate to 5s OK
tm = time.localtime()
tm_textblock.set_text(text_format="{:02d}.{:02d}".format(tm.tm_hour, tm.tm_min)) # or put colon in CODEPOINTS
tm_text.regen()
if quit:
break
tm_thread = threading.Thread(target=update_tm_text)
tm_thread.start()
################################################################################
num_run_through = 0
while DISPLAY.loop_running():
...
if len(textblock.text_format.strip()) > 0: #only draw background if text there
text_bkg.draw()
text.draw()
##############################################################################
tm_text_bkg.draw()
tm_text.draw()
##############################################################################
if config.KEYBOARD:
k = kbd.read() So you can see I basically just copied the text, textblock and text_bkg section and changed the location. x,y = (0,0) is in the middle of the screen with x increasing to right and y increasing upwards The threading function breaks when the variable
|
Beta Was this translation helpful? Give feedback.
-
Look at the bottom of PictureFrame2020config.py those CODEPOINTS are the characters available to use. If you want to use a colon just add it to the string! (then just Paddy |
Beta Was this translation helpful? Give feedback.
-
No, I can't see where to enable that. I think |
Beta Was this translation helpful? Give feedback.
-
OK the alternative category is Q&A and that is set up in the mode for ticking answers already. I've moved these two threads from Ideas to Q&A |
Beta Was this translation helpful? Give feedback.
Hi, this is the kind of thing you could do