Site Sponsors:
zPython Clock, Revisited 
Here is an upgrade for zClock:



from tkinter import *
import time

zProgram = Tk()
zProgram.title("zPython Clock - Soft9000.com")
zClock = Label(zProgram,
font=('ariel', 72, 'bold'),
bg='gold',
fg='white')

zDay = Label(zProgram,
font=('ariel', 36, 'bold'),
bg='gold',
fg='green')

zDate = Label(zProgram,
font=('ariel', 36, 'bold'),
bg='gold',
fg='blue')

zClock.pack(fill=BOTH, expand=1)
zDay.pack(side='left', fill=X, expand=1)
zDate.pack(side='right', fill=X, expand=1)


def zTimer():
zClock.config(text=time.strftime('%H:%M:%S'))
zDay.config(text=time.strftime('%a'))
zDate.config(text=time.strftime('%m/%d/%y'))
zClock.after(500, zTimer)


zTimer()
zProgram.mainloop()


Here is zVideo :-)


[ add comment ] ( 113 views )   |  permalink  |  related link
zClock: Python3 Clock in 11 Statements 
When the atomic clock went on the fritz lately (probably was the first popular commercial version ever available!) I went lookin'.

Finding a few for under $20, it occurred to me that - attached as we are to the DST-capable world-time-zone, that I could easily slap one together in Python.



Looking for a way to keep braggin' over how easy it is to get things done using Python 3, I decided to see just how few lines I could use to encode the idea.

Here is what I came up with:

from tkinter import *
import time


zProgram = Tk()
zProgram.title("zClock: Python3 Clock in 11 Statements")
zClock = Label(zProgram,
font=('ariel', 72, 'bold'),
bg='gold',
fg='white')
zClock.pack(fill=BOTH, expand=1)


def zTimer():
zClock.config(text=time.strftime('%H:%M:%S'))
zClock.after(500, zTimer)


zTimer()
zProgram.mainloop()


While I could have written the above in even fewer lines using Turtle Graphics, having just cobbled-together a training offering on the same I thought that using TK would make for a refreshingly different blog post.


Here is a link to zVideo :-)


Enjoy the Journey!

-Rn

p.s: Feel free to add more features (date, day... temperature probe support for your Raspberry Pi) as your time and obsession(s) may allow.



[ add comment ] ( 93 views )   |  permalink  |  related link

<<First <Back | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | Next> Last>>