Created
December 14, 2012 08:21
-
-
Save MrValdez/4283618 to your computer and use it in GitHub Desktop.
This is a time machine. This works on Python 2.x and 3.x (tested on 2.5 and 3.2, respectively). What I am proud of: * no classes * very simple code of a time machine running on Tkinter. * does exactly as it says on the tin
This file contains hidden or 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
try: | |
import Tkinter as tkinter | |
import tkFont | |
except ImportError: | |
# python 3 | |
import tkinter | |
import tkinter.font as tkFont | |
import time | |
root = tkinter.Tk() | |
root.overrideredirect(1) | |
def TimeMachineACTIVATOR(): | |
window.config(text=time.strftime("%I:%M:%S")) | |
window.after(1000, TimeMachineACTIVATOR) | |
font = tkFont.Font(family="Helvetica", size=16) | |
window = tkinter.Button(root, | |
text = "THE TIME MACHINE", | |
font=font, | |
command=lambda: root.destroy()) | |
window.pack(fill="both") | |
root.update() | |
width, height = root.winfo_width(), root.winfo_height() | |
x = (root.winfo_screenwidth() / 2) - (width / 2) | |
y = (root.winfo_screenheight() / 2) - (height / 2) | |
root.geometry("%ix%i+%i+%i" % (width, height, x, y)) | |
TimeMachineACTIVATOR() | |
root.mainloop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment