diff flax/tracker @ 156:224505b0c21e

smaller text smaller text better bounds updating (now only on mouse-up) cooler demo
author drewp
date Mon, 07 Jul 2003 06:56:50 +0000
parents e3a92ccea4be
children 5aa7cffe68d0
line wrap: on
line diff
--- a/flax/tracker	Mon Jul 07 06:56:15 2003 +0000
+++ b/flax/tracker	Mon Jul 07 06:56:50 2003 +0000
@@ -12,6 +12,8 @@
 
 import Tkinter as tk
 
+defaultfont="arial 8"
+
 def pairdist(pair1,pair2):
     return sqrt((pair1[0]-pair2[0])**2+(pair1[1]-pair2[1])**2)
 
@@ -136,7 +138,7 @@
                                           outlinestipple='gray50')
 
         # make text
-        self.txt=c.create_text(0,0,text=f.name(),font="arial 10 bold",
+        self.txt=c.create_text(0,0,text=f.name(),font=defaultfont+" bold",
                                fill='white',anchor='c',
                                tags=self.tags)
 
@@ -151,10 +153,12 @@
             dworld=c.canvas2world_vector(*dcan)
             self.field.center(*(self.field.center()+dworld))
             self._lastmouse=ev.x,ev.y
-            dispatcher.send("field coord changed")
             self.setcoords() # redraw
         def release(ev):
-            del self._lastmouse
+            if hasattr(self,'_lastmouse'):
+                del self._lastmouse
+            dispatcher.send("field coord changed") # updates bounds
+            
         c.tag_bind(self.txt,"<ButtonPress-1>",press)
         c.tag_bind(self.txt,"<B1-Motion>",motion)
         c.tag_bind(self.txt,"<B1-ButtonRelease>",release)
@@ -167,9 +171,9 @@
             worldmouse=self.canvas.canvas2world(ev.x,ev.y)
             currentdist=pairdist(worldmouse,self.field.center())
             self.field.falloff(currentdist)
-            dispatcher.send("field coord changed")
             self.setcoords()
         c.tag_bind(outerring,"<B1-Motion>",motion)
+        c.tag_bind(outerring,"<B1-ButtonRelease>",release) # from above
 
         self.setcoords()
     
@@ -248,7 +252,7 @@
 ########################################################################
                 
 root=tk.Tk()
-
+root.wm_geometry('700x350')
 tra=Tracker(root)
 tra.pack(fill='both',exp=1)