python_user 0 Light Poster

Hi all,

Could anyone please help me with this

i have a cascaded menu button and i am adding nodes in a loop like this

#Create a cascading menu button for adding attribute types
		AttTypemenuBar = Pmw.MenuBar(topF, hull_relief = 'raised',hull_borderwidth = 1)
		aname = "   Select...."
		self.createAttTypeMenu(AttTypemenuBar, topF, typeF, aname = aname,)
		AttTypemenuBar.grid(row = 3,column = 1, sticky = W)
		topF.pack(fill = 'x', expand = 1)


def createAttTypeMenu(self, AttTypemenuBar, rFrame, typeFrame, aname):
		'''Description:  adds menu nodes to a Pmw.MenuBar.
		AttTypemenuBar --> A Pmw.MenuBar to add children to
		aname --> The parent of this component we are adding
		rFrame --> root frame of this menu.
		typeFrame --> type Frame of this menu.
		return --> None
		'''
		if aname == "   Select....":
			AttTypemenuBar.addmenu(aname, 'Click to add attribute type', foreground = "#fff000fff")
			for key in MainAttributeTypes:
				if key in AttributeTypes.keys():
					AttTypemenuBar.addcascademenu(aname, key, traverseSpec = 'z', tearoff = 1)
					for skey in AttributeTypes[key]:
						if skey in SubAttributeTypes.keys():
							AttTypemenuBar.addcascademenu(key,PrettyAttTypes[skey],traverseSpec = 'z', tearoff = 1)
							for smkey in SubAttributeTypes[skey]:
								AttTypemenuBar.addmenuitem(PrettyAttTypes[skey], 'command', command = HandleTypeSelection(self, AttTypemenuBar, rFrame, typeFrame, smkey) , label = PrettyAttTypes[smkey])
						else:
							AttTypemenuBar.addmenuitem(key,'command', command = HandleTypeSelection(self, AttTypemenuBar, rFrame, typeFrame, skey), label = PrettyAttTypes[skey])
				else:
					AttTypemenuBar.addmenuitem(aname, 'command', command = HandleTypeSelection(self, AttTypemenuBar, rFrame, typeFrame, key) , label = PrettyAttTypes[key])
		else:
			print "yet to be implemented"
	#end def AttTypecreateMenu


class HandleTypeSelection:
	def __init__(self, sdf, AttTypemenuBar, refFrame, typeFrame, text):
		self.sdf = sdf
		self.AttTypemenuBar = AttTypemenuBar
		self.refFrame = refFrame
		self.typeFrame = typeFrame
		self.text = text

	def __call__(self):

the cascaded menu looks like as shown in the attachment image
some nodes have same child nodes

MainAttributeTypes = ['description', 'Biological Attributes', 'Patient Attributes', 'Reference Attributes' ]
AttributeTypes = {'Biological Attributes':['species','organ_system','organ','tissues'],
				'Patient Attributes':['characteristics','baseline_scan','baseline_dimensions','baseline_hermodynamics',
									'post_intervention_scan', 'post_intervention_dimensions', 'post_intervention_hermodynamics',
									'follow_up_scan', 'follow_up_dimensions','follow_up_hermodynamics'],
				'Reference Attributes':['citation']}
SubAttributeTypes = {'characteristics':['age','gender'],
					'baseline_scan':['date'],'post_intervention_scan':['date'],'follow_up_scan':['date'],
					'baseline_dimensions':['apex_to_base','interior_to_posterior','wall_thickness','end_diastolic_vol','end_systolic_vol','ejection_fraction','edbp','esbp'],
					'post_intervention_dimensions':['apex_to_base','interior_to_posterior','wall_thickness','end_diastolic_vol','end_systolic_vol','ejection_fraction','edbp','esbp'],
					'follow_up_dimensions':['apex_to_base','interior_to_posterior','wall_thickness','end_diastolic_vol','end_systolic_vol','ejection_fraction','edbp','esbp'],
					'baseline_hermodynamics':['apex_to_base','interior_to_posterior','wall_thickness','end_diastolic_vol','end_systolic_vol','ejection_fraction','edbp','esbp'],
					'post_intervention_hermodynamics':['apex_to_base','interior_to_posterior','wall_thickness','end_diastolic_vol','end_systolic_vol','ejection_fraction','edbp','esbp'],
					'follow_up_hermodynamics':['apex_to_base','interior_to_posterior','wall_thickness','end_diastolic_vol','end_systolic_vol','ejection_fraction','edbp','esbp']}
PrettyAttTypes = {'description':'Description','Patient Attributes':'Patient Attributes','Reference Attributes':'Reference Attributes','Biological Attributes':'Biological Attributes',
				'species':'Species', 'organ_system':'Organ System', 'organ':'Organ', 'tissues':'Tissues','characteristics':'Characteristics','baseline_scan':'Baseline Scan',
				'baseline_dimensions':'Baseline Dimensions','baseline_hermodynamics':'Baseline Hermodynamics','citation':'Citation', 'age': 'Age', 'gender': 'Gender','date':'Date',
				'apex_to_base':'Apex-to-base(mm)','interior_to_posterior':'Interior-to-Posterior(mm)','wall_thickness':'Wall Thickness(mm)','end_diastolic_vol':'End Diastolic Volume(ml)',
				'end_systolic_vol':'End Systolic Volume(ml)', 'ejection_fraction':'Ejection Fraction(%)','edbp':'EDBP(mmHg)', 'esbp':'ESBP(mmHg)','post_intervention_scan':'Post Intervention Scan',
				'post_intervention_dimensions':'Post Intervention Dimensions', 'post_intervention_hermodynamics':'Post Intervention Hermodynamics', 'follow_up_scan':'Follow Up Scan',
				'follow_up_dimensions':'Follow Up Dimensions','follow_up_hermodynamics':'Follow Up Hermodynamics'}

could anyone tell me how to identify the root node when clicked on the child node

thank you in advance

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.