Example #1
0
	def interpret_template_radio(self, template, widg_dex):
		try: labels = template.labels[widg_dex]
		except AttributeError: labels = ['...no labels...']
		try: title = template.box_labels[widg_dex]
		except AttributeError: title = ''
		try: initial = template.initials[widg_dex][0]
		except AttributeError: initial = None
		try: instance = template.instances[widg_dex][0]
		except AttributeError: instance = None
		try: key = template.keys[widg_dex][0]
		except AttributeError: key = None
		try: rewidget = template.rewidget[widg_dex][0]
		except AttributeError: rewidget = True
		try: refresh = template.refresh[widg_dex][0]
		except AttributeError: refresh = False
		try: window = template.window[widg_dex][0]
		except AttributeError: window = None
		return [lgb.create_radios(options = labels, title = title, 
				initial = initial, instance = instance, key = key, 
						rewidget = rewidget, refresh = refresh, 
											window = window)]
Example #2
0
	def interpret_template_radio(self, template, widg_dex):

		def generate_recast_inst_func(dex):

			def recast_inst_func():
				selected = labels[dex]
				new_class = lfu.lookup_pairwise(zip(
					[base._class for base in 
						instance.valid_base_classes], 
					[base._tag for base in 
						instance.valid_base_classes]), selected)
				instance.recast(new_class)
				instance.rewidget(True)

			return recast_inst_func

		try: labels = template.labels[widg_dex]
		except AttributeError: labels = ['...no labels...']
		try: title = template.box_labels[widg_dex]
		except AttributeError: title = ''
		try: initial = template.initials[widg_dex][0]
		except AttributeError: initial = None
		try: inst_tuple = template.instances[widg_dex][0]
		except AttributeError: inst_tuple = None
		try: key = template.keys[widg_dex][0]
		except AttributeError: key = None
		try: rewidget = template.rewidget[widg_dex][0]
		except AttributeError: rewidget = True
		if inst_tuple:
			instance = inst_tuple[1]
			base_class = inst_tuple[0]

		radios = [lgb.create_radios(options = labels, title = title, 
						initial = initial, instance = base_class, 
								key = key, rewidget = rewidget)]
		[rad.clicked.connect(lgb.create_reset_widgets_wrapper(
			self.parent, generate_recast_inst_func(dex))) for 
			dex, rad in enumerate(radios[0].children()[1:])]
		return radios