In the program I am writing, there is a tkinter window that is constantly loaded with data manually, and is not part of mainloop. It should also track the location of the mouse. I havn't found a workaround for mouse tracking outside mainloop yet, but if you have one, please let me know.
from Tkinter import * import random import time def getCoords(event): xm, ym = event.x, event.y str1 = "mouse at x=%dy=%d" % (xm, ym) print str1 class iciclePhysics(object): def __init__(self, fallrange, speed=5): self.speed = speed self.xpos = random.choice(range(0,fallrange)) self.ypos = 0 def draw(self,canvas): try: self.id = canvas.create_polygon(self.xpos-10, self.ypos, self.xpos+10, self.ypos, self.xpos, self.ypos+25, fill = 'lightblue') except: pass def fall(self,canvas): self.ypos+=self.speed canvas.move(self.id, 0, self.ypos) root = Tk() mainFrame = Frame(root, bg= 'yellow', width=300, height=200) mainFrame.pack() mainCanvas = Canvas(mainFrame, bg = 'black', height = 500, width = 500, cursor = 'circle') mainCanvas.bind("<Motion>", getCoords) mainCanvas.pack() root.resizable(0, 0) difficulty = 1500
source share