Skip to content

Instantly share code, notes, and snippets.

@tps2015gh
Last active May 25, 2017 16:41
Show Gist options
  • Save tps2015gh/9abb192def3369cea2bca4b9fe645951 to your computer and use it in GitHub Desktop.
Save tps2015gh/9abb192def3369cea2bca4b9fe645951 to your computer and use it in GitHub Desktop.
#=========================================================================================
# Author: Thitipong Samranvanich
# Since: 25/05/2017
# Platform: Windows10 + Python27 , Editor notepad
# ProgramDesc : DEMO Draw Circle from 1 degree to 360 degree / Simple Animation
# NOTE: Upgrade pip by
# c:\Python27\python.exe -m pip install --upgrade pip
#
#=========================================================================================
#== REFERENCE
#== https://stackoverflow.com/questions/459083/how-do-you-run-your-own-code-alongside-tkinters-event-loop
#== https://stackoverflow.com/questions/2400262/how-to-create-a-timer-using-tkinter
#== https://www.tutorialspoint.com/python/tk_canvas.htm
#== https://stackoverflow.com/questions/459083/how-do-you-run-your-own-code-alongside-tkinters-event-loop
#== https://stackoverflow.com/questions/423379/using-global-variables-in-a-function-other-than-the-one-that-created-them
import Tkinter as tk
#import threading
import time
root = tk.Tk()
root.wm_title("Demo/Test TK GDI")
num = 0
def task():
global num, C
num = num+1
if num >360 :
num =1
C.delete("all")
print("hello " , num )
coord = 10, 50, 240, 210
arc = C.create_arc(coord, start=0, extent=num, fill="red")
C.pack()
root.label.configure(text="degree=%d"%(num)) #modify fix in version 2
#== NEXT LOOP
root.after(10,task)
C = tk.Canvas(root, bg="lightblue", height=250, width=300)
root.label = tk.Label(text="label1")
root.label.pack()
root.after(1000,task)
root.mainloop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment