示例#1
0
	def set_up_widgets(self):
		range_makers, variations = create_ranger_makers(
									self, 'variations')
		axis_widgets = lgb.central_widget_wrapper(content =\
			lgb.create_vert_box([lgb.central_widget_wrapper(content =\
				lgb.create_vert_box([lgb.create_label(
				text = axis), range_maker])) for axis, range_maker 
						in zip(self.axis_labels, range_makers)]))
		variations = lgb.central_widget_wrapper(content =\
						lgb.create_vert_box(variations))
		panel = lgb.create_scroll_area(lgb.central_widget_wrapper(
			content = lgb.create_horz_box([axis_widgets, variations])))
		layout = lgb.create_vert_box([panel])
		create_obj_dialog.set_up_widgets(self, layout)
示例#2
0
	def interpret_template_full_path_box(self, template, widg_dex):
		try: instance = template.instances[widg_dex][0]
		except AttributeError: instance = None
		try: key = template.keys[widg_dex][0]
		except AttributeError: key = None
		try: label = template.labels[widg_dex][0]
		except AttributeError: label = ''
		try: initial = template.initials[widg_dex][0]
		except AttributeError: initial = ''
		try: exts = template.initials[widg_dex][1]
		except AttributeError: exts = None
		except IndexError: exts = None
		try: init_dir = template.initials[widg_dex][2]
		except AttributeError: init_dir = None
		except IndexError: init_dir = None
		try: rewidget = template.rewidget[widg_dex][0]
		except AttributeError: rewidget = True
		try: is_dict = template.instance_is_dict[widg_dex]
		except AttributeError: is_dict = None
		paname_box = [lgb.create_file_name_box(
			instance, key, label, initial, exts, True, 
			init_dir, rewidget, None, is_dict, True)]
		try:
			title = template.box_labels[widg_dex]
			group = QtGui.QGroupBox(title = title)
			layout = lgb.create_vert_box(paname_box)
			group.setLayout(layout)
			return [group]

		except AttributeError: return paname_box
示例#3
0
	def interpret_template_panel(self, template, widg_dex):
		try: templates = template.templates[widg_dex]
		except AttributeError: templates = []
		if not templates: return [lgb.create_label()]
		try: mason = template.mason
		except AttributeError: mason = self
		try: scroll = template.scrollable[widg_dex]
		except AttributeError: scroll = False
		try: collapse = template.collapses[widg_dex]
		except AttributeError: collapse = False
		try: lay = template.layouts[widg_dex]
		except AttributeError: lay = 'grid'
		if not lay: lay = 'grid'
		if scroll:
			panel_widget = [lgb.create_scroll_area(
				lgb.create_panel(templates, mason, 
					collapses = collapse, layout = lay))]

		else:
			panel_widget = [lgb.create_panel(templates, mason, 
						collapses = collapse, layout = lay)]

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

		except AttributeError: return panel_widget
示例#4
0
	def interpret_template_slider_advanced(self, template, widg_dex):
		try: min_val = template.minimum_values[widg_dex][0]
		except AttributeError: min_val = 0
		try: max_val = template.maximum_values[widg_dex][0]
		except AttributeError: max_val = 50
		try: orientation = template.orientations[widg_dex][0]
		except AttributeError: orientation = 'horizontal'
		try: initial = template.initials[widg_dex][0]
		except AttributeError: initial = 1
		try: tick_pos = template.positions[widg_dex][0]
		except AttributeError: tick_pos = None
		try: tick_int = template.intervals[widg_dex][0]
		except AttributeError: tick_int = 1
		try: bind_events = template.bind_events[widg_dex]
		except AttributeError: bind_events = [[None], [None]]
		try: bindings = template.bindings[widg_dex]
		except AttributeError: bindings = [[None], [None]]
		slide_widget = [lgb.advanced_slider(inst =\
			template.instances[widg_dex][0], key =\
			template.keys[widg_dex][0], mason = self, 
			orientation = orientation, initial = initial, 
			minimum = min_val, maximum = max_val, 
			tick_position = tick_pos, tick_interval = tick_int, 
				bind_events = bind_events, bindings = bindings)]

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

		except AttributeError: return slide_widget
示例#5
0
	def interpret_template_spin(self, template, widg_dex):
		try: parent = template.parents[widg_dex][0]
		except AttributeError: parent = None
		try: double = template.doubles[widg_dex][0]
		except AttributeError: double = False
		try: min_val = template.minimum_values[widg_dex][0]
		except AttributeError: min_val = None
		try: max_val = template.maximum_values[widg_dex][0]
		except AttributeError: max_val = None
		try: sing_step = template.single_steps[widg_dex][0]
		except AttributeError: sing_step = None
		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: callback = template.callbacks[widg_dex][0]
		except AttributeError: callback = None
		spin_widget = [lgb.create_spin_box(parent = parent, 
			double = double, min_val = min_val, max_val = max_val, 
			sing_step = sing_step, initial = initial, 
					instance = instance, key = key, 
					rewidget = rewidget, callback = callback)]
		try:
			title = template.box_labels[widg_dex]
			group = QtGui.QGroupBox(title = title)
			layout = lgb.create_vert_box(spin_widget)
			group.setLayout(layout)
			return [group]

		except AttributeError: return spin_widget
示例#6
0
	def set_up_widgets(self):
		self.canvas = FigureCanvas(qp_fig)
		self.setBackgroundRole(QtGui.QPalette.Window)
		self.toolbar = plot_window_toolbar(self.canvas, self)
		#layout = lgb.create_vert_box([self.canvas, self.toolbar])
		layout = lgb.create_vert_box([self.canvas])
		self.setLayout(layout)
示例#7
0
	def interpret_template_check_set(self, template, widg_dex):
		try: append_instead = template.append_instead[widg_dex]
		except AttributeError: append_instead = True
		try: keys = template.keys[widg_dex]
		except AttributeError: keys = []
		try: instances = template.instances[widg_dex]
		except AttributeError: instances = []
		try: labels = template.labels[widg_dex]
		except AttributeError: labels = []
		try: is_list = template.instance_is_list[widg_dex]
		except AttributeError: is_list = None
		try: rewidget = template.rewidget[widg_dex][0]
		except AttributeError: rewidget = True
		try: provide_master = template.provide_master[widg_dex]
		except AttributeError: provide_master = False
		try: callbacks = template.callbacks[widg_dex]
		except AttributeError: callbacks = []
		check_widget = lgb.create_check_boxes(append_instead, 
							keys, instances, labels, is_list, 
					None, rewidget, provide_master, callbacks)
		try:
			title = template.box_labels[widg_dex]
			group = QtGui.QGroupBox(title = title)
			layout = lgb.create_vert_box(check_widget)
			group.setLayout(layout)
			return [group]

		except AttributeError: return check_widget
示例#8
0
	def interpret_template_spin(self, template, widg_dex):
		try: double = template.doubles[widg_dex][0]
		except AttributeError: double = False
		try: min_val = template.minimum_values[widg_dex][0]
		except AttributeError: min_val = 0
		try: max_val = template.maximum_values[widg_dex][0]
		except AttributeError: max_val = 50
		try: sing_step = template.single_steps[widg_dex][0]
		except AttributeError: sing_step = 1
		try: initial = template.initials[widg_dex][0]
		except AttributeError: initial = 1
		try: instance = template.instances[widg_dex][0]
		except AttributeError: instance = None
		try: key = template.keys[widg_dex][0]
		except AttributeError: key = None
		widgs = [lgb.create_spin_box(double = double, 
					min_val = min_val, max_val = max_val, 
				sing_step = sing_step, initial = initial, 
						instance = instance, key = key)]
		p_sp_template = template.parameter_space_templates[widg_dex]
		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
示例#9
0
	def interpret_template_tree_book(self, template, widg_dex):
		try: pages = template.pages[widg_dex]
		except AttributeError: pages = []
		try: mason = template.mason
		except AttributeError: mason = self
		try: initial = template.initials[widg_dex][0]
		except AttributeError: initial = [0, []]
		try: instance = template.instances[widg_dex][0]
		except AttributeError: instance = None
		try: key = template.keys[widg_dex][0]
		except AttributeError: key = None
		try: header = template.headers[widg_dex][0]
		except AttributeError: header = None
		tree_widget = [lgb.central_widget_wrapper(content =\
						lgb.create_treebook(pages = pages, 
						mason = mason, initial = initial, 
							inst = instance, key = key, 
									header = header))]
		try:
			title = template.box_labels[widg_dex]
			group = QtGui.QGroupBox(title = title)
			layout = lgb.create_vert_box(tree_widget)
			group.setLayout(layout)
			return [group]

		except AttributeError: return tree_widget
示例#10
0
	def update_axes_slicing(self, page_dex):
		self.slice_layout.removeWidget(self.slice_group)
		if self.slice_group: self.slice_group.deleteLater()
		labels = copy(self._all_plot_axes_[page_dex])
		daters = self.pages[page_dex]._data_.data
		try:
			surf_vector_dex = [hasattr(dater, 'reduced') 
						for dater in daters].index(True)

		except ValueError:
			print 'no surface_vector found!'; return

		surf_vect = daters[surf_vector_dex]
		ax_labs, ax_vals = surf_vect.axis_labels, surf_vect.axis_values
		slice_widgets = []
		self.slice_widgets = slice_widgets
		self.slice_selectors = []
		for lab, sca, def_ in zip(ax_labs, ax_vals, 
							surf_vect.axis_defaults):
			dummy = [None]*len(sca.scalars)
			selector = lgb.create_combo_box(
				sca.as_string_list(), dummy, dummy)
			if hasattr(sca.scalars, 'index'):
				initial = sca.scalars.index(def_)

			else: initial = np.nonzero(sca.scalars == def_)[0][0]
			selector.setCurrentIndex(initial)
			self.slice_selectors.append(selector)
			selector.currentIndexChanged.connect(
				lgb.create_function_with_args(
				self.change_axis_slice, (page_dex, )))
			ax_box = QtGui.QGroupBox(title = lab)
			ax_box.setLayout(lgb.create_vert_box([selector]))
			slice_widgets.append(ax_box)
			#determine if ax_box corresponds to a domain axis
			# hide it if so

		title = 'P-Space Axis Handling'
		self.slice_group = QtGui.QGroupBox(title = title)
		layout = lgb.create_vert_box(slice_widgets)
		self.slice_group.setLayout(lgb.create_vert_box([
			lgb.create_scroll_area(lgb.central_widget_wrapper(
								content = layout))]))
		self.slice_layout.addWidget(self.slice_group)
示例#11
0
	def update_check_boxes(self, page_dex):
		self.targets_layout.removeWidget(self.check_group)
		if self.check_group: self.check_group.deleteLater()
		append_instead = True
		keys = ['current_targets']
		instances = [self]
		labels = copy(self._all_plot_targets_[page_dex])
		provide_master = False
		check_widget = lgb.create_check_boxes(append_instead, keys, 
			instances, labels, None, None, False, provide_master)

		for check in check_widget:
			dex = self.page_labels.index(self.selected_page_label)
			check.stateChanged.connect(self.pages[dex].show_plot)

		title = 'Curves Shown'
		self.check_group = QtGui.QGroupBox(title = title)
		layout = lgb.create_vert_box(check_widget)
		self.check_group.setLayout(lgb.create_vert_box([
			lgb.create_scroll_area(lgb.central_widget_wrapper(
								content = layout))]))
		self.targets_layout.addWidget(self.check_group)
示例#12
0
	def __init__(self, *args, **kwargs):
		self.codes = range(10000000)
		self.selected_page_label = None
		self.page_labels = []
		self.pages = []

		self._all_plot_targets_ = []
		self.current_targets = []
		self.targets_layout = lgb.create_vert_box([])
		self.check_group = None

		self.surface_vector_flag = False
		self._all_plot_axes_ = []
		self._current_axes_ = []
		self.slice_layout = lgb.create_vert_box([])
		self.slice_group = None
		self.slice_selectors = []

		self.plot_type = 'lines'
		self.plot_types = kwargs['plot_types']
		mason = lgm.standard_mason(parent = self)
		if 'title' in kwargs.keys(): title = kwargs['title']
		else: title = 'Plot Window'
		create_obj_dialog.__init__(self, None, mason = mason, 
							title = title, from_sub = True)

		x, y = lfu.convert_pixel_space(256, 256)
		x_size, y_size = lfu.convert_pixel_space(1024, 768)
		geometry = (x, y, x_size, y_size)
		self.setGeometry(*geometry)
		self.figure = plt.figure()
		self.canvas = FigureCanvas(self.figure)
		self.setBackgroundRole(QtGui.QPalette.Window)
		#self.canvas.setSizePolicy(
		#	QtGui.QSizePolicy.Expanding,
		#	QtGui.QSizePolicy.Expanding)
		#self.canvas.updateGeometry()
		self.toolbar = plot_window_toolbar(self.canvas, self)
		self.set_settables()
示例#13
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
示例#14
0
	def set_up_widgets(self):
		panel = lgb.create_panel(self.widg_templates, self.mason)
		split = QtGui.QSplitter(QtCore.Qt.Horizontal)
		split.addWidget(panel)
		split.addWidget(lgb.central_widget_wrapper(
					content = self.targets_layout))
		split.addWidget(lgb.central_widget_wrapper(
					content = self.slice_layout))
		split.addWidget(lgb.central_widget_wrapper(
					content = lgb.create_vert_box(
					[self.canvas, self.toolbar])))

		layout = lgb.create_horz_box([split])
		self.setLayout(layout)
示例#15
0
	def interpret_template_check_spin_list(self, template, widg_dex):
		try: instance = template.instances[widg_dex][0]
		except AttributeError: instance = None
		try: key = template.keys[widg_dex][0]
		except AttributeError: key = None
		try: labels = template.labels[widg_dex]
		except AttributeError: labels = []
		check_spin = lgb.create_check_spin_list(instance, key, labels)
		try:
			title = template.box_labels[widg_dex]
			group = QtGui.QGroupBox(title = title)
			layout = lgb.create_vert_box(check_spin)
			group.setLayout(layout)
			return [group]

		except AttributeError: return check_spin
示例#16
0
	def set_up_widgets(self, layout = None):
		panel = lgb.create_panel(self.widg_templates, self.mason)
		button_template = lgm.interface_template_gui(
				widgets = ['button_set'], 
				verbosities = [0], 
				layout = 'horizontal', 
				bindings = [[self.on_make, self.reject]], 
				#labels = [['make', 'cancel']], 
				icons = [self.button_icons], 
				minimum_sizes = [[(100, 50), (100, 50)]])
		buttons = self.mason.interpret_template(button_template)
		buttons.itemAt(0).widget().setFocus()
		if layout: layout.addWidget(panel)
		else: layout = lgb.create_vert_box([panel])
		layout.addLayout(buttons)
		self.delete_layout()
		self.setLayout(layout)
示例#17
0
	def interpret_template_combo_box(self, template, widg_dex):
		try: labels = template.labels[widg_dex]
		except AttributeError: labels = []
		try: icons = template.icons[widg_dex]
		except AttributeError: icons = []
		try: datas = template.datas[widg_dex]
		except AttributeError: datas = []
		try: initial = template.initials[widg_dex][0]
		except AttributeError: initial = None
		except TypeError: initial = None
		try: bindings = template.bindings[widg_dex]
		except AttributeError: bindings = None
		try: bind_event = template.bind_events[widg_dex]
		except AttributeError: bind_event = None
		try: instance = template.instances[widg_dex][0]
		except AttributeError: instance = None
		except TypeError: instance = None
		try: key = template.keys[widg_dex][0]
		except AttributeError: key = None
		except TypeError: key = None
		try: rewidget = template.rewidget[widg_dex][0]
		except AttributeError: rewidget = True
		try: refresh = template.refresh[widg_dex][0]
		except AttributeError: refresh = False
		except TypeError: refresh = False
		try: window = template.window[widg_dex][0]
		except AttributeError: window = None
		except TypeError: window = None
		if bind_event: bind_event = bind_event[0]
		if labels: lfu.fill_lists([labels, icons, datas], fill = None)
		combo_widget = [lgb.create_combo_box(labels, icons, datas, 
			initial = initial, bindings = bindings, bind_event =\
			bind_event, inst = instance, key = key, rewidget = rewidget, 
							refresh_widgets = refresh, window = window)]
		try:
			title = template.box_labels[widg_dex]
			group = QtGui.QGroupBox(title = title)
			layout = lgb.create_vert_box(combo_widget)
			group.setLayout(layout)
			return [group]

		except AttributeError: return combo_widget
示例#18
0
	def interpret_template(self, template):
		widgs = []
		if not hasattr(template, 'widgets'): pdb.set_trace()
		for widg_dex, widget_type in enumerate(template.widgets):
			if widget_type == 'button_set':
				widg_list = self.interpret_template_button_set(
											template, widg_dex)

			elif widget_type == 'check_set':
				widg_list = self.interpret_template_check_set(
											template, widg_dex)

			elif widget_type == 'text':
				widg_list = self.interpret_template_text_box(
										template, widg_dex)

			elif widget_type == 'selector':
				widg_list = self.interpret_template_combo_box(
											template, widg_dex)

			elif widget_type == 'image':
				widg_list = self.interpret_template_image(
										template, widg_dex)

			elif widget_type == 'spin':
				widg_list = self.interpret_template_spin(
									template, widg_dex)

			elif widget_type == 'slider':
				widg_list = self.interpret_template_slider(
										template, widg_dex)

			elif widget_type == 'slider_advanced':
				widg_list = self.interpret_template_slider_advanced(
												template, widg_dex)

			elif widget_type == 'radio':
				widg_list = self.interpret_template_radio(
										template, widg_dex)

			elif widget_type == 'splitter':
				widg_list = self.interpret_template_splitter(
										template, widg_dex)

			elif widget_type == 'panel':
				widg_list = self.interpret_template_panel(
										template, widg_dex)

			elif widget_type == 'file_name_box':
				widg_list = self.interpret_template_file_name_box(
											template, widg_dex)

			elif widget_type == 'directory_name_box':
				widg_list = self.interpret_template_directory_name_box(
													template, widg_dex)

			elif widget_type == 'full_path_box':
				widg_list = self.interpret_template_full_path_box(
											template, widg_dex)

			elif widget_type == 'check_spin_list':
				widg_list = self.interpret_template_check_spin_list(
												template, widg_dex)

			elif widget_type == 'mobj_inspector':
				widg_list = self.interpret_template_inspector(
										template, widg_dex)

			elif widget_type == 'mobj_catalog':
				widg_list = self.interpret_template_catalog(
										template, widg_dex)

			elif widget_type == 'tab_book':
				widg_list = self.interpret_template_tab_book(
										template, widg_dex)

			elif widget_type == 'tree_book':
				widg_list = self.interpret_template_tree_book(
										template, widg_dex)

			elif widget_type == 'list_controller':
				widg_list = self.interpret_template_list_controller(
												template, widg_dex)

			elif widget_type == 'console_listener':
				widg_list = self.interpret_template_console_listener(
												template, widg_dex)

			elif widget_type == 'opengl_view':
				widg_list = self.interpret_template_opengl_view(
											template, widg_dex)

			elif widget_type == 'plot':
				widg_list = self.interpret_template_plot(
									template, widg_dex)

			else:
				print 'no interpretation of widget type: ' + widget_type
				return None

			try:
				if template.handles[widg_dex]:
					handle = template.handles[widg_dex]
					inst = handle[0]
					key = handle[1]
					inst.__dict__[key] = widg_list
					if not handle in inst._handles_:
						inst._handles_.append(handle)

			except AttributeError: pass
			widgs.append(widg_list)

		self.hide_quiet_widgets(widgs, template)
		try: lgb.set_tooltips(widgs, template.tooltips)
		except AttributeError: pass
		try: lgb.set_sizes_limits(widgs, template.minimum_sizes)
		except AttributeError: pass
		try: lgb.set_sizes_limits(widgs, template.maximum_sizes, 'max')
		except AttributeError: pass
		try: layout = template.layout
		except AttributeError: layout = 'vertical'
		try: subspacers = template.subspacers[widg_dex]
		except AttributeError: subspacers = None
		if layout == 'vertical': box = lgb.create_vert_box
		elif layout == 'horizontal': box = lgb.create_horz_box
		elif layout == 'grid':
			box = lgb.create_grid_box
			try: positions = template.widg_positions
			except AttributeError: positions = []
			try: spans = template.widg_spans
			except AttributeError: spans = []
			try: g_spacing = template.grid_spacing
			except AttributeError: g_spacing = 5
			try: widg_layout = box(widgs, positions, spans, 
								g_spacing, template.layouts)

			except AttributeError:
				widg_layout = box(lfu.flatten(widgs), 
						positions, spans, g_spacing)

			return widg_layout

		else:
			print 'widget layout "', layout,\
				'" unrecognized; returning empty'
			return lgb.create_vert_box([])

		try: widg_layout = box(widgs, template.layouts, subspacers)
		except AttributeError: widg_layout = box(lfu.flatten(widgs))
		return widg_layout
示例#19
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
示例#20
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