Changeset - 224505b0c21e
[Not reviewed]
default
0 2 0
drewp - 21 years ago 2003-07-07 06:56:50

smaller text
smaller text
better bounds updating (now only on mouse-up)

cooler demo
2 files changed with 16 insertions and 7 deletions:
0 comments (0 inline, 0 general)
flax/fieldsets/demo
Show inline comments
 
<?xml version='1.0' encoding='UTF-8'?>
 
<fieldset version='1'>
 
  <field y='40' x='30' name='light1' falloff='10'/>
 
  <field y='70.9854106065' x='89.7809651165' name='light2' falloff='9.44161122397'/>
 
  <field y='56.5504587159' x='39.8543897217' name='light3' falloff='9.02748404992'/>
 
  <field y='64.518605176' x='64.4226431666' name='light1' falloff='10'/>
 
  <field y='71.6297059084' x='64.1501958858' name='light2' falloff='9.44161122397'/>
 
  <field y='62.2614165793' x='49.4797562176' name='light3' falloff='9.02748404992'/>
 
  <field y='64.7105473806' x='39.4725745351' name='1ight3' falloff='9.02748404992'/>
 
  <field y='70.0008620159' x='45.644638445' name='2ight3' falloff='9.02748404992'/>
 
  <field y='70.7801243766' x='53.963092297' name='3ight3' falloff='9.02748404992'/>
 
  <field y='68.1676620898' x='74.8416350959' name='4ight3' falloff='10.5270359255'/>
 
  <field y='62.0408841822' x='79.8677043872' name='5ight3' falloff='9.02748404992'/>
 
</fieldset>
flax/tracker
Show inline comments
 
@@ -12,6 +12,8 @@ import dispatcher
 

	
 
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 @@ class FieldDisplay:
 
                                          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 @@ class FieldDisplay:
 
            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):
 
            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 @@ class FieldDisplay:
 
            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 @@ class Tracker(tk.Frame):
 
########################################################################
 
                
 
root=tk.Tk()
 

	
 
root.wm_geometry('700x350')
 
tra=Tracker(root)
 
tra.pack(fill='both',exp=1)
 

	
0 comments (0 inline, 0 general)