Created
February 3, 2014 16:48
-
-
Save patthoyts/8787532 to your computer and use it in GitHub Desktop.
Tkinter binary clock example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from Tkinter import * | |
import sys,time | |
class App(): | |
def __init__(self, parent): | |
parent.title("Title") | |
parent.geometry("500x500") | |
self.labels = [] | |
self.parent = parent | |
x,y = 50,50 | |
for index in range(3): | |
label = Label(parent, text='0') | |
label.place(x = x, y = y) | |
self.labels.append(label) | |
y += 50 | |
self.parent.after(1000, self.Task) | |
def Task(self): | |
t = time.strftime("%H:%M:%S", time.localtime()) | |
print(t) | |
index = 0 | |
for c in t.split(':'): | |
b = format(int(c), '04b') | |
self.labels[index].configure(text=b) | |
index += 1 | |
self.parent.after(1000, self.Task) | |
def main(): | |
root = Tk() | |
app = App(root) | |
root.mainloop() | |
if __name__=='__main__': | |
sys.exit(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment