Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # threading_multitask_countdown_demo.py
- from Tkinter import *
- import tkMessageBox
- import threading
- import time
- root = Tk()
- root.geometry("450x250+300+300")
- root.title("Multitask Countdown")
- #print dir(root)
- def myloop():
- global task
- task += 1
- def run():
- count = 60
- tr = task
- while (count > -1) and root.wm_state():
- msg='Thread #%d -- The count is: %d\n' %(tr,count)
- print msg,
- if tr == task:
- print
- count -= 1
- time.sleep(1)
- msg='Thread #%d -- The count has now ended\n' %(tr)
- print msg,
- thread = threading.Thread(target=run)
- thread.start()
- def mymessage():
- tkMessageBox.showinfo(title="Alert", message="Hello World!")
- task = 0
- buttonLoop = Button(root, text="Start Loop", command=myloop)
- buttonLoop.place(x=5, y=15)
- buttonMessage = Button(root, text="Start Loop", command=mymessage)
- buttonMessage.place(x=85, y=15)
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement