示例#1
0
	def __init__(self, display, parent = None):
		super(range_maker, self).__init__(parent)
		self.display = display
		self._range_ = ''
		self.box = lgb.create_text_box(parent = self, 
			instance = self, key = '_range_', alignment = 'center', 
			initial = self._range_, multiline = False, rewidget = False)
		self.box.returnPressed.connect(self.update_display)
		self.setLayout(lgb.create_horz_box([self.box]))
		lgb.set_sizes_limits([[self]], [[(max([25*10, 100]), 40)]])
示例#2
0
	def __init__(self, inst, key, dex, parent = None):
		super(range_maker_display, self).__init__(parent)
		self.inst = inst
		self.key = key
		self.dex = dex
		self._range_ = ''
		self.box = lgb.create_text_box(parent = self, 
			instance = self, key = '_range_', alignment = 'center', 
			initial = self._range_, multiline = True, rewidget = False)
		self.box.textChanged.connect(self.update_variation)
		self.setLayout(lgb.create_horz_box([self.box]))
		lgb.set_sizes_limits([[self]], [[(100, 80)]])
示例#3
0
	def interpret_template_text_box(self, template, widg_dex):
		#do text boxes get icons?
		try: icons = template.icons[widg_dex]
		except AttributeError: icons = None
		try: bind_events = template.bind_events[widg_dex]
		except AttributeError: bind_events = None
		try: bindings = template.bindings[widg_dex]
		except AttributeError: bindings = None
		try: placeholder = template.placeholders[widg_dex]
		except AttributeError: placeholder = None
		try: max_leng = template.max_lengths[widg_dex][0]
		except AttributeError: max_leng = None
		try: read_only = template.read_only[widg_dex]
		except AttributeError: read_only = False
		try: multi = template.multiline[widg_dex]
		except AttributeError: multi = False
		try: keep_frame = template.keep_frame[widg_dex]
		except AttributeError: keep_frame = True
		try: alignment = template.alignments[widg_dex][0]
		except AttributeError: alignment = 'left'
		try: instance = template.instances[widg_dex][0]
		except AttributeError: instance = None
		try: key = template.keys[widg_dex][0]
		except AttributeError: key = None
		try: initial = template.initials[widg_dex][0]
		except AttributeError:
			if not (instance is None or key is None):
				initial = instance.__dict__[key]

			else: initial = ''

		widgs = [lgb.create_text_box(instance = instance, key = key, 
				placeholder = placeholder, max_length = max_leng, 
				multiline = multi, read_only = read_only, 
				alignment = alignment, initial = initial, 
				keep_frame = keep_frame, bind_events = bind_events, 
											bindings = bindings)]
		try: p_sp_template = template.parameter_space_templates[widg_dex]
		except AttributeError: p_sp_template = None
		if not p_sp_template is None:
			widgs.append(self.interpret_template_p_sp(p_sp_template))

		try:
			title = template.box_labels[widg_dex]
			group = QtGui.QGroupBox(title = title)
			layout = lgb.create_vert_box(widgs)
			group.setLayout(layout)
			return [group]

		except AttributeError: return widgs
示例#4
0
	def interpret_template_text_box(self, template, widg_dex):

		def generate_update_wheres_func(widg, inst, 
						wheres, template, widg_dex):

			def update_where():
				new_label = widg.text()
				initial = template.initials[widg_dex][0]
				if new_label == initial: return
				template.initials[widg_dex][0] = new_label
				for whar in wheres:
					if type(whar) is types.ListType:
						print 'why update a list?'

					elif type(whar) is types.DictionaryType:
						whar[new_label] = whar[initial]
						#if issubclass(whar[initial].__class__, 
						#				lfu.modular_object_qt):
						#	whar[initial]._destroy_()
						del whar[initial]
						whar[new_label]._set_label_(new_label)

					else: print 'could not update where:', whar

				inst.rewidget(True)

			return update_where

		try: icons = template.icons[widg_dex]
		except AttributeError: icons = None
		try: bind_events = template.bind_events[widg_dex]
		except AttributeError: bind_events = None
		try: bindings = template.bindings[widg_dex]
		except AttributeError: bindings = None
		try: placeholder = template.placeholders[widg_dex]
		except AttributeError: placeholder = None
		try: max_leng = template.max_lengths[widg_dex][0]
		except AttributeError: max_leng = None
		try: read_only = template.read_only[widg_dex]
		except AttributeError: read_only = False
		try: multi = template.multiline[widg_dex]
		except AttributeError: multi = False
		try: keep_frame = template.keep_frame[widg_dex]
		except AttributeError: keep_frame = True
		try: alignment = template.alignments[widg_dex][0]
		except AttributeError: alignment = 'left'
		try: instance = template.instances[widg_dex][0]
		except AttributeError: instance = None
		try: key = template.keys[widg_dex][0]
		except AttributeError: key = None
		try: initial = template.initials[widg_dex][0]
		except AttributeError:
			if not (instance is None or key is None):
				initial = instance.__dict__[key]

			else: initial = ''

		text_widget = [lgb.create_text_box(instance = instance, 
							key = key, placeholder = placeholder, 
						max_length = max_leng, multiline = multi, 
					read_only = read_only, alignment = alignment, 
					initial = initial, keep_frame = keep_frame, 
				bind_events = bind_events, bindings = bindings)]

		if not template.data_links is None:
			if template.data_links[widg_dex]:
				'''
				if widget_type == 'add_rem_drop_list':
					[last_widgs_reference[0].Bind(widg_specific_event, 
						function) for function in 
						lgb.generate_linkage_assertion_funcs(
							template.data_links[widg_dex])]
					[last_widgs_reference[1].Bind(widg_specific_event, 
						function) for function in 
						lgb.generate_linkage_assertion_funcs(
							template.data_links[widg_dex])]
				'''
				#else:
				[text_widget[0].textChanged.connect(function) for 
					function in lgb.generate_linkage_assertion_funcs(
									template.data_links[widg_dex])]

		if not template.wheres[widg_dex] is None:
			text_widget[0].textChanged.connect(
				generate_update_wheres_func(text_widget[0], 
					instance, template.wheres[widg_dex], 
									template, widg_dex))

		try:
			title = template.box_labels[widg_dex]
			group = QtGui.QGroupBox(title = title)
			layout = lgb.create_vert_box(text_widget)
			group.setLayout(layout)
			return [group]

		except AttributeError: return text_widget
示例#5
0
	def interpret_template_text_box(self, template, widg_dex):
		#do text boxes get icons?
		try: icons = template.icons[widg_dex]
		except AttributeError: icons = None
		try: bind_events = template.bind_events[widg_dex]
		except AttributeError: bind_events = None
		try: bindings = template.bindings[widg_dex]
		except AttributeError: bindings = None
		try: placeholder = template.placeholders[widg_dex]
		except AttributeError: placeholder = None
		try: max_leng = template.max_lengths[widg_dex][0]
		except AttributeError: max_leng = None
		try: read_only = template.read_only[widg_dex]
		except AttributeError: read_only = False
		try: multi = template.multiline[widg_dex]
		except AttributeError: multi = False
		try: keep_frame = template.keep_frame[widg_dex]
		except AttributeError: keep_frame = True
		try: for_code = template.for_code[widg_dex]
		except AttributeError: for_code = False
		try: alignment = template.alignments[widg_dex][0]
		except AttributeError: alignment = 'left'
		try: inst_is_dict = template.inst_is_dict[widg_dex]
		except AttributeError: inst_is_dict = None
		try: instance = template.instances[widg_dex][0]
		except AttributeError: instance = None
		try: key = template.keys[widg_dex][0]
		except AttributeError: key = None
		try: initial = template.initials[widg_dex][0]
		except AttributeError:
			if not (instance is None or key is None):
				if key is 'label':
					try: initial = instance._get_label_()
					except: pdb.set_trace()

				else:
					try: initial = instance.__dict__[key]
					except AttributeError:
						try: initial = instance[key]
						except: pdb.set_trace()

			else: initial = ''

		try: rewidget = template.rewidget[widg_dex][0]
		except AttributeError: rewidget = True
		except IndexError: rewidget = True
		text_widget = [lgb.create_text_box(instance = instance, 
			key = key, placeholder = placeholder, max_length = max_leng, 
							multiline = multi, read_only = read_only, 
							alignment = alignment, initial = initial, 
				keep_frame = keep_frame, bind_events = bind_events, 
						bindings = bindings, rewidget = rewidget, 
				inst_is_dict = inst_is_dict, for_code = for_code)]
		try:
			title = template.box_labels[widg_dex]
			group = QtGui.QGroupBox(title = title)
			layout = lgb.create_vert_box(text_widget)
			group.setLayout(layout)
			return [group]

		except AttributeError: return text_widget