Package teamwork :: Package widgets :: Module attribute
[hide private]
[frames] | no frames]

Source Code for Module teamwork.widgets.attribute

 1  from Tkinter import * 
 2  import Pmw 
 3  from teamwork.math.KeyedVector import TrueRow 
 4  from teamwork.math.KeyedTree import KeyedPlane 
 5  from MatrixEditor import MatrixEditor 
 6   
7 -class AttributeDialog(Pmw.Dialog):
8 - def __init__(self,parent,entity,**kw):
9 self.entity = entity 10 optiondefs = ( 11 ('plane', KeyedPlane(TrueRow(),-.1), self.setPlane), 12 ) 13 self.defineoptions(kw, optiondefs) 14 Pmw.Dialog.__init__(self,parent) 15 self.createcomponent('attribute',(),None,Label, 16 (self.component('dialogchildsite'),), 17 height=3,wraplength=300, 18 ).pack(side='top',expand='yes') 19 # Find all possible state features 20 states = {} 21 for key in self.entity.getBeliefKeys(): 22 states[str(key)] = key 23 self.createcomponent('selector',(),None,MatrixEditor, 24 (self.component('dialogchildsite'),), 25 states=states, 26 ).pack(side='top',fill='both',expand='yes') 27 self.component('selector_type').configure(entry_width=32, 28 selectioncommand=self.setBranch) 29 self.component('selector').displayBranch(self['plane']) 30 for name in self.component('selector').components(): 31 if self.component('selector').componentgroup(name) == 'feature': 32 self.component('selector_%s' % (name)).configure(selectioncommand=self.updatePlane) 33 self.initialiseoptions()
34
35 - def setPlane(self):
36 self.component('attribute').configure(text=self['plane'].simpleText())
37
38 - def setBranch(self,rowType):
39 self.component('selector').setBranch(rowType) 40 self.updatePlane()
41
42 - def updatePlane(self,button=None):
43 self['plane'] = self.component('selector').getBranch()
44