def add_debug(self): entity = self.context['selected_entity'] name = self.debug_name_field.text() component_item = self.component_tree_view.currentItem() lambda_component = component_item.component color = self.color_list_view.currentItem().component location_vec = self.vector_list_view.currentItem().component inner_component = lambda_component.component.component #component_type = component_wrapper.__class__.__name__ attr = getattr(inner_component, lambda_component.attr).component component_type = attr.__class__.__name__ # create the debug component # extract the real component from a LambdaDef if component_type == 'BoxComponent': rect = getattr(inner_component, lambda_component.attr) debug_component = DebugComponent(entity_id=entity, rect=rect, style={'color': color}) else: lambda_name = lambda_component.attr text_lambda = TextLambdaDef(lambda_component, lambda_name, '{a}') text = str(getattr(lambda_component.component.component, lambda_name).component) text_comp = TextComponent(entity_id=entity, text=text, loc=location_vec, style={'color':color}) text_wrapper = Component(text_comp, text) # add this text component to the context self.context['entities'][entity]['components']['text'].append(text_wrapper) new_event = Event('added_component', entity=entity, component_type='text', component=text_wrapper) EVENT_MANAGER.fire_event(new_event) # finally create debug component debug_component = DebugComponent(entity_id=entity, text=text_wrapper, get_value=text_lambda, style={'color': color}) debug_wrapper = Component(debug_component, name) widget_item = WidgetItemComponent(name, debug_wrapper) self.debug_list_view.addItem(widget_item) # add to context self.context['entities'][entity]['components']['debug'].append(debug_wrapper) # fire event new_event = Event('added_component', entity=entity, component_type='debug', component=debug_wrapper) EVENT_MANAGER.fire_event(new_event)
def add_frame(self): frame_name = str(self.frame_name_field.text()) entity = self.context['selected_entity'] ani = self.selected_animation crop = Rect(int(self.frame_x_field.text()), int(self.frame_y_field.text()), int(self.frame_width_field.text()), int(self.frame_height_field.text())) repeat = int(self.frame_repeat_field.text()) frame_component = FrameComponent(entity_id=entity, crop=crop, repeat=repeat) frame_component_wrapper = Component(frame_component, frame_name) widget_component = WidgetItemComponent(frame_name, frame_component_wrapper) self.frame_list_view.addItem(widget_component) # add new frame component to the selected animation's frame list ani.component.frames.append(frame_component_wrapper) # fire event new_event = Event('added_component', entity=entity, component_type='frame', component=frame_component_wrapper) EVENT_MANAGER.fire_event(new_event)
def add_state(self): entity = self.context['selected_entity'] state_name = str(self.state_name_field.text()) # get activation event act_event_name = str(self.activation_list_view.currentItem().text()) # get deactivation event deact_event_name = str(self.deactivation_list_view.currentItem().text()) # get activation component act_component = self.activation_component_tree_view.currentItem().component # build list of rules added to this state rules = list() rule_values = dict() for i in range(self.selected_rule_list_view.count()): item = self.selected_rule_list_view.item(i) rule_component = item.component rules.append(rule_component.rule) rule_values[str(rule_component.rule.text)] = rule_component.rule_value # create state component state_component = StateComponent(entity_id=entity, rules=rules, activation_event_type=act_event_name, deactivation_event_type=deact_event_name, activation_component=act_component, rule_values=rule_values) state_component_wrapper = Component(state_component, state_name) widget_component = WidgetItemComponent(state_name, state_component_wrapper) self.state_list_view.addItem(widget_component) # add state component to application context self.context['entities'][entity]['components']['state'].append(state_component_wrapper) # fire event for adding component new_event = Event('added_component', entity=entity, component_type='state', component=state_component_wrapper) EVENT_MANAGER.fire_event(new_event)
def add_binding(self): entity = self.context['selected_entity'] binding_name = str(self.binding_name_field.text()) # begin by building the bindings dictionary bindings = dict() mirrors = dict() for i in range(self.selected_inp_list_view.count()): input_comp = self.selected_inp_list_view.item(i).component key = input_comp.component.name.text bindings[key] = input_comp mirrors[key] = input_comp.component.mirror binding_comp = InputComponent(entity_id=entity, bindings=bindings, mirror_bindings=mirrors) binding_comp_wrapper = Component(binding_comp, binding_name) widget_component = WidgetItemComponent(binding_name, binding_comp_wrapper) self.binding_list_view.addItem(widget_component) # add the component to the application context self.context['entities'][entity]['components']['binding'].append( binding_comp_wrapper) # fire event for adding new binding new_event = Event('added_binding', binding_component=binding_comp_wrapper) EVENT_MANAGER.fire_event(new_event) new_event = Event('added_component', entity=entity, component_type='binding', component=binding_comp_wrapper) EVENT_MANAGER.fire_event(new_event)
def add_animation(self): animation_name = str(self.animation_name_field.text()) entity = self.context['selected_entity'] animation_component = AnimationComponent(entity_id=entity, graphic=self.selected_graphic) animation_component_wrapper = Component(animation_component, animation_name) widget_component = WidgetItemComponent(animation_name, animation_component_wrapper) self.animation_list_view.addItem(widget_component) # add new component to the application context context_animations = self.context['entities'][entity]['components'][ 'animation'] context_animations.append(animation_component_wrapper) # fire event for adding an animation new_event = Event( 'added_animation', animation_component=animation_component_wrapper, entity=animation_component_wrapper.component.entity_id) EVENT_MANAGER.fire_event(new_event) new_event = Event('added_component', entity=entity, component_type='animation', component=animation_component_wrapper) EVENT_MANAGER.fire_event(new_event)
def add_exec(self): entity = self.context['selected_entity'] exec_name = str(self.exec_name_field.text()) binding = self.binding_list_view.currentItem().component # build list of selected moves moves = list() for i in range(self.selected_move_list_view.count()): item = self.selected_move_list_view.item(i) move = item.component moves.append(move) exec_component = ExecutionComponent(entity_id=entity, executables=moves, inputs=binding) exec_component_wrapper = Component(exec_component, exec_name) widget_component = WidgetItemComponent(exec_name, exec_component_wrapper) self.exec_list_view.addItem(widget_component) # add execution component to the application context self.context['entities'][entity]['components']['execution'].append( exec_component_wrapper) # fire event for adding new execution new_event = Event('added_execution', execution_component=exec_component_wrapper) EVENT_MANAGER.fire_event(new_event) new_event = Event('added_component', entity=entity, component_type='execution', component=exec_component_wrapper) EVENT_MANAGER.fire_event(new_event)
def add_box(self): box_name = str(self.box_name_field.text()) entity = self.context['selected_entity'] frame = self.selected_frame.component rect = Rect(int(self.box_x_field.text()), int(self.box_y_field.text()), int(self.box_width_field.text()), int(self.box_height_field.text())) hitactive = self.check_context['hitactive'] > 0 hurtactive = self.check_context['hurtactive'] > 0 blockactive = self.check_context['blockactive'] > 0 solid = self.check_context['solid'] > 0 box_component = BoxComponent(entity_id=entity, rect=rect, anchor=self.anchor, hitactive=hitactive, hurtactive=hurtactive, blockactive=blockactive, solid=solid) box_component_wrapper = Component(box_component, box_name) widget_component = WidgetItemComponent(box_name, box_component_wrapper) self.box_list_view.addItem(widget_component) # add box to the selected frame's box list frame.hitboxes.append(box_component_wrapper) # add the box component to the application context self.context['entities'][entity]['components']['hitbox'].append( box_component_wrapper) # fire event new_event = Event('added_component', entity=entity, component_type='hitbox', component=box_component_wrapper) EVENT_MANAGER.fire_event(new_event)
def add_move(self): move_name = str(self.move_name_field.text()) entity = self.context['selected_entity'] selected_animation = self.ani_list_view.currentItem().component # build a list of the chosen inputs inputs = list() for i in range(self.selected_inp_list_view.count()): item = self.selected_inp_list_view.item(i) inp_component = item.component inputs.append(inp_component) # construct the move component move = MoveComponent(entity_id=entity, name=move_name, animation=selected_animation, inputs=inputs) move_component_wrapper = Component(move, move_name) widget_component = WidgetItemComponent(move_name, move_component_wrapper) self.move_list_view.addItem(widget_component) # add the move component to the application context self.context['entities'][entity]['components']['move'].append(move_component_wrapper) # fire event for adding new move new_event = Event('added_move', move_component=move_component_wrapper) EVENT_MANAGER.fire_event(new_event) new_event = Event('added_component', entity=entity, component_type='move', component=move_component_wrapper) EVENT_MANAGER.fire_event(new_event)
def add_graphic(self): # add the new graphic to the UI selected_asset = self.asset_list_view.currentItem() selected_component = selected_asset.component file_name = selected_component.component.file_name graphic_name = str(self.graphic_name_field.text()) selected_anchor = self.anchor_list_view.currentItem().component graphic_component = GraphicsComponent(entity_id=self.context.get('selected_entity'), surface=selected_component.component.surface, file_name=file_name, dest=selected_anchor) graphic_component_wrapper = Component(graphic_component, graphic_name) widget_component = WidgetItemComponent(graphic_name, graphic_component_wrapper) self.graphic_list_view.addItem(widget_component) # render it to the label image holder self.show_graphic(file_name) # then add it to the application context entity_name = self.context.get('selected_entity') if entity_name: self.context['entities'][entity_name]['components']['graphic'].append(graphic_component_wrapper) # fire off an event new_event = Event('graphic_added', graphic_component=graphic_component_wrapper) EVENT_MANAGER.fire_event(new_event) new_event = Event('added_component', entity=entity_name, component_type='graphic', component=graphic_component_wrapper) EVENT_MANAGER.fire_event(new_event)
def add_entity(self): entity_name = str(self.entity_name_field.text()) new_entity = Entity(entity_name) new_entity_wrapper = Component(new_entity, entity_name) widget_component = WidgetItemComponent(entity_name, new_entity_wrapper) self.entity_list_view.addItem(widget_component) self.context['entities'][entity_name] = dict() self.context['entities'][entity_name]['entity'] = new_entity self.context['entities'][entity_name]['components'] = defaultdict(list)
def select_state(self): ''' update the state editor GUI to show all properties of the selected state ''' entity = self.context['selected_entity'] selected_item = self.state_list_view.currentItem() selected_component = selected_item.component # start by setting the state name self.state_name_field.setText(selected_component.text) # then set the selected activation event for i in range(self.activation_list_view.count()): item = self.activation_list_view.item(i) if item.text() == selected_component.component.activation_event_type: self.activation_list_view.setCurrentRow(i) break # then set the selected deactivation event for i in range(self.deactivation_list_view.count()): item = self.deactivation_list_view.item(i) if item.text() == selected_component.component.deactivation_event_type: self.deactivation_list_view.setCurrentRow(i) break # then select activation component # begin by deselecting any selected node and collapsing all branches activation_component = selected_component.component.activation_component for i in range(self.activation_component_tree_view.topLevelItemCount()): tl_item = self.activation_component_tree_view.topLevelItem(i) for j in range(tl_item.childCount()): child_item = tl_item.child(j) child_item.setSelected(False) tl_item.setExpanded(False) # then find and select the proper node for i in range(self.activation_component_tree_view.topLevelItemCount()): tl_item = self.activation_component_tree_view.topLevelItem(i) for j in range(tl_item.childCount()): child_item = tl_item.child(j) if child_item.component == activation_component: tl_item.setExpanded(True) child_item.setSelected(True) break # then show the proper rules in the selected rule box # also, deselect any selected rule or rule component values for i in range(self.selected_rule_list_view.count()-1,-1,-1): item = self.selected_rule_list_view.takeItem(i) context_rules = self.context['entities'][entity]['components']['rules'] rules = [RuleRuleValueWrapper(x, y) for x in selected_component.component.rules for k,y in selected_component.component.rule_values.iteritems() if k == x.component.name] for rule in rules: comp = Component(rule, rule.rule.text) widget_item = WidgetItemComponent(comp.text, comp) self.selected_rule_list_view.addItem(widget_item) self.rule_list_view.setCurrentRow(-1)
def add_physics(self): name = str(self.name_field.text()) w = int(self.w_field.text()) h = int(self.h_field.text()) rect = Rect(0, 0, w, h) rect_wrapper = Component(rect, str(rect)) anchor = self.anchor_list_view.currentItem().component self.context['entities'][self.entity]['components']['vector'].append( anchor) box_component = BoxComponent(entity_id=self.entity, rect=rect, anchor=anchor, hitactive=False, hurtactive=False, blockactive=False, solid=True) box_wrapper = Component(box_component, str(rect)) # add this box to the application context and fire respective events self.context['entities'][self.entity]['components']['hitbox'].append( box_wrapper) new_event = Event('added_component', entity=self.entity, component_type='hitbox', component=box_wrapper) EVENT_MANAGER.fire_event(new_event) physics_component = PhysicsComponent(entity_id=self.entity, box=box_wrapper, body=rect_wrapper) physics_wrapper = Component(physics_component, name) widget_component = WidgetItemComponent(physics_wrapper.text, physics_wrapper) self.physics_list_view.addItem(widget_component) self.context['entities'][self.entity]['components']['physics'].append( physics_wrapper) new_event = Event('added_component', entity=self.entity, component_type='physics', component=physics_wrapper) EVENT_MANAGER.fire_event(new_event) new_event = Event('physics_added', physics_component=physics_wrapper) EVENT_MANAGER.fire_event(new_event)
def add_input(self): inp_name = str(self.input_name_field.text()) inp = Input(name=inp_name) inp_wrapper = Component(inp, inp_name) widget_component = WidgetItemComponent(inp_name, inp_wrapper) self.input_list_view.addItem(widget_component) # add input to the application context self.context['inputs'].append(inp_wrapper) # fire event for adding new input new_event = Event('added_input', input_component=inp_wrapper) EVENT_MANAGER.fire_event(new_event)
def add_inputs(self): # possible multiple selection selected_items = self.inp_list_view.selectedItems() widget_component = None if len(selected_items) > 0: # if multiple items selected, join each component's # text together, and use the list of components as the # component text = ' + '.join([str(x.text()) for x in selected_items]) agg_comp = Component([x.component for x in selected_items], text) widget_component = WidgetItemComponent(text, agg_comp) elif len(selected_items) == 1: # if just one item selected, follow the normal process comp = Component(selected_items[0].component, selected_items[0].text) widget_component = WidgetItemComponent(comp.text, comp) else: return # then add the widget item to the selected inputs list self.selected_inp_list_view.addItem(widget_component)
def add_input(self): selected_item = self.inp_list_view.currentItem() selected_component = selected_item.component selected_key = self.key_list_view.currentItem().component selected_mirror = self.mirror_list_view.currentItem() selected_mirror = None if selected_mirror is None else selected_mirror.component bound_input = InputToKeyBinding(selected_component, selected_key, selected_mirror) bound_input_wrapper = Component( bound_input, '{a} - {b}'.format(a=selected_component.text, b=selected_key.text)) widget_component = WidgetItemComponent(bound_input_wrapper.text, bound_input_wrapper) self.selected_inp_list_view.addItem(widget_component)
def find_components(genes): print("Finding components...") guide_to_genes = defaultdict(set) for g in genes: for target in g.targets: guide_to_genes[target.guide].add(g.name) graph = networkx.Graph() for g in genes: graph.add_node(g.name) def guide_to_node(guide): return 'guide: ' + guide def is_guide(node): if node[:6] == 'guide:': return True else: return False for guide in guide_to_genes: graph.add_node(guide_to_node(guide)) for gene in guide_to_genes[guide]: graph.add_edge(guide_to_node(guide), gene) connected_components = networkx.connected_components(graph) connected_genes = [[node for node in c if not is_guide(node)] for c in connected_components] gene_dict = {g.name: g for g in genes} components = [ Component([gene_dict[name] for name in sorted(c)]) for c in connected_genes ] print("There are ", len(components), " components.") return components
def add_rule(self): rule_name = str(self.rule_name_field.text()) operator = str(self.operator_list_view.itemText(self.operator_list_view.currentIndex())) value = str(self.value_field.text()) try: value = float(value) except ValueError: pass # create rule component rule_component = RuleComponent(rule_name, operator, value) rule_component_wrapper = Component(rule_component, rule_name) widget_component = WidgetItemComponent(rule_name, rule_component_wrapper) self.rule_list_view.addItem(widget_component) # add the rule component to the application context self.context['rules'].append(rule_component_wrapper) # fire event for adding rule new_event = Event('added_rule', rule_component=rule_component_wrapper) EVENT_MANAGER.fire_event(new_event)
def add_asset(self): # add the new graphic to the UI file_name = str(self.asset_file_name_field.text()) asset_name = str(self.asset_name_field.text()) asset_name = asset_name if asset_name else file_name asset_component = AssetComponent(file_name, None) asset_component_wrapper = Component(asset_component, asset_name) widget_component = WidgetItemComponent(asset_name, asset_component_wrapper) self.asset_list_view.addItem(widget_component) # render it to the label image holder self.show_asset(file_name) # then add it to the application context if 'assets' not in self.context: self.context['assets'] = list() self.context['assets'].append(asset_component_wrapper) # fire off an event new_event = Event('asset_added', asset_component=asset_component_wrapper) EVENT_MANAGER.fire_event(new_event)
def __init__(self, context): super(StateDefinitionEditor, self).__init__(context, QtGui.QGroupBox('State')) # gui elements self.layout = QtGui.QGridLayout() self.state_name_label = QtGui.QLabel('State Name') self.state_name_field = QtGui.QLineEdit() self.activation_label = QtGui.QLabel('Activation Events') self.activation_list_view = QtGui.QListWidget() self.activation_layout = QtGui.QVBoxLayout() self.deactivation_label = QtGui.QLabel('Deactivation Events') self.deactivation_list_view = QtGui.QListWidget() self.deactivation_layout = QtGui.QVBoxLayout() self.activation_component_label = QtGui.QLabel('Activation Component') self.activation_component_tree_view = QtGui.QTreeWidget() self.activation_component_layout = QtGui.QVBoxLayout() self.rule_list_label = QtGui.QLabel('Rules') self.rule_list_view = QtGui.QListWidget() self.rule_list_layout = QtGui.QVBoxLayout() self.rule_value_label = QtGui.QLabel('Rule Value') self.rule_value_field = QtGui.QLineEdit() self.rule_value_component_label = QtGui.QLabel('Or Pick a Component Value') self.rule_value_component_tree_view = QtGui.QTreeWidget() self.rule_value_layout = QtGui.QVBoxLayout() self.selected_rule_list_view = QtGui.QListWidget() self.add_rule_button = QtGui.QPushButton('Add Rule and Value') self.remove_rule_button = QtGui.QPushButton('Remove Rule and Value') self.rule_button_layout = QtGui.QVBoxLayout() self.state_list_view = QtGui.QListWidget() self.add_state_button = QtGui.QPushButton('Add State') self.remove_state_button = QtGui.QPushButton('Remove State') self.state_button_layout = QtGui.QVBoxLayout() # set up layout self.layout.addWidget(self.state_name_label,0,0) self.layout.addWidget(self.state_name_field,0,1) self.activation_layout.addWidget(self.activation_label) self.activation_layout.addWidget(self.activation_list_view) self.layout.addLayout(self.activation_layout,1,0) self.deactivation_layout.addWidget(self.deactivation_label) self.deactivation_layout.addWidget(self.deactivation_list_view) self.layout.addLayout(self.deactivation_layout,1,1) self.activation_component_layout.addWidget(self.activation_component_label) self.activation_component_layout.addWidget(self.activation_component_tree_view) self.layout.addLayout(self.activation_component_layout,1,2,1,2) self.rule_list_layout.addWidget(self.rule_list_label) self.rule_list_layout.addWidget(self.rule_list_view) self.layout.addLayout(self.rule_list_layout,2,0) self.rule_value_layout.addWidget(self.rule_value_label) self.rule_value_layout.addWidget(self.rule_value_field) self.rule_value_layout.addWidget(self.rule_value_component_label) self.rule_value_layout.addWidget(self.rule_value_component_tree_view) self.layout.addLayout(self.rule_value_layout,2,1) self.rule_button_layout.addWidget(self.add_rule_button) self.rule_button_layout.addWidget(self.remove_rule_button) self.layout.addLayout(self.rule_button_layout,2,2) self.layout.addWidget(self.selected_rule_list_view,2,3) self.layout.addWidget(self.state_list_view,3,0) self.state_button_layout.addWidget(self.add_state_button) self.state_button_layout.addWidget(self.remove_state_button) self.layout.addLayout(self.state_button_layout,3,1,1,1) self.group.setLayout(self.layout) # populate event lists for name in (x for x in dir(events) if not x.startswith('_')): value = events.__dict__[name] activation_component = Component(value, name) deactivation_component = Component(value, name) a_widget_component = WidgetItemComponent(name, activation_component) d_widget_component = WidgetItemComponent(name, deactivation_component) self.activation_list_view.addItem(a_widget_component) self.deactivation_list_view.addItem(d_widget_component) # internal events EVENT_MAPPING.register_handler('selected_entity', self.set_entity) EVENT_MAPPING.register_handler('added_component', self.add_component) EVENT_MAPPING.register_handler('removed_component', self.remove_component) EVENT_MAPPING.register_handler('added_rule', self.rule_added) EVENT_MAPPING.register_handler('removed_rule', self.rule_removed) # wire up events self.add_rule_button.clicked.connect(self.add_rule) self.remove_rule_button.clicked.connect(self.remove_rule) self.add_state_button.clicked.connect(self.add_state) self.remove_state_button.clicked.connect(self.remove_state) self.state_list_view.currentItemChanged.connect(self.select_state) self.selected_rule_list_view.currentItemChanged.connect(self.select_rule)
def __init__(self, context): super(BindingDefinitionEditor, self).__init__(context, QtGui.QGroupBox('Binding')) self.current_binding = None self.layout = QtGui.QGridLayout() self.binding_name_label = QtGui.QLabel('Binding Name') self.binding_name_field = QtGui.QLineEdit() self.inp_list_view = QtGui.QListWidget() self.selected_inp_list_view = QtGui.QListWidget() self.inp_layout = QtGui.QHBoxLayout() self.inp_button_layout = QtGui.QVBoxLayout() self.key_label = QtGui.QLabel('Choose Default Key') self.key_list_view = QtGui.QListWidget() self.key_layout = QtGui.QVBoxLayout() self.mirror_label = QtGui.QLabel('Choose Mirror Input') self.mirror_list_view = QtGui.QListWidget() self.mirror_layout = QtGui.QVBoxLayout() self.binding_list_view = QtGui.QListWidget() self.add_inp_button = QtGui.QPushButton('Add Input') self.remove_inp_button = QtGui.QPushButton('Remove Input') self.add_binding_button = QtGui.QPushButton('Add Binding') self.remove_binding_button = QtGui.QPushButton('Remove Binding') self.edit_binding_button = QtGui.QPushButton('Edit Binding') self.button_layout = QtGui.QVBoxLayout() # set up layout self.layout.addWidget(self.binding_name_label, 0, 0) self.layout.addWidget(self.binding_name_field, 0, 1) self.inp_layout.addWidget(self.inp_list_view) self.key_layout.addWidget(self.key_label) self.key_layout.addWidget(self.key_list_view) self.inp_layout.addLayout(self.key_layout) self.mirror_layout.addWidget(self.mirror_label) self.mirror_layout.addWidget(self.mirror_list_view) self.inp_layout.addLayout(self.mirror_layout) self.inp_button_layout.addWidget(self.add_inp_button) self.inp_button_layout.addWidget(self.remove_inp_button) self.inp_layout.addLayout(self.inp_button_layout) self.inp_layout.addWidget(self.selected_inp_list_view) self.layout.addLayout(self.inp_layout, 1, 0, 1, 2) self.layout.addWidget(self.binding_list_view, 2, 0) self.button_layout.addWidget(self.add_binding_button) self.button_layout.addWidget(self.remove_binding_button) self.button_layout.addWidget(self.edit_binding_button) self.layout.addLayout(self.button_layout, 2, 1) self.group.setLayout(self.layout) # miscellaneous for key in KEYS: key_comp = KeyComponent(pygame.__dict__[key]) key_wrapper = Component(key_comp, key) widget_item = WidgetItemComponent(key, key_wrapper) self.key_list_view.addItem(widget_item) # internal events EVENT_MAPPING.register_handler('selected_entity', self.set_bindings) EVENT_MAPPING.register_handler('added_input', self.new_input) EVENT_MAPPING.register_handler('removed_input', self.removed_input) # wire up events self.add_inp_button.clicked.connect(self.add_input) self.remove_inp_button.clicked.connect(self.remove_input) self.add_binding_button.clicked.connect(self.add_binding) self.remove_binding_button.clicked.connect(self.remove_binding) self.edit_binding_button.clicked.connect(self.edit_binding) self.binding_list_view.currentItemChanged.connect(self.select_binding)
def __init__(self, context): super(DebugDefinitionEditor, self).__init__(context, QtGui.QGroupBox('Debug')) # setup gui stuff self.layout = QtGui.QGridLayout() self.debug_name_label = QtGui.QLabel('Debug Name') self.debug_name_field = QtGui.QLineEdit() self.name_layout = QtGui.QVBoxLayout() self.component_tree_view = QtGui.QTreeWidget() self.component_tree_label = QtGui.QLabel('Choose Component or Property') self.component_layout = QtGui.QVBoxLayout() self.vector_list_view = QtGui.QListWidget() self.vector_list_label = QtGui.QLabel('Choose Position') self.vector_layout = QtGui.QVBoxLayout() self.color_list_view = QtGui.QListWidget() self.color_list_label = QtGui.QLabel('Choose Color') self.color_layout = QtGui.QVBoxLayout() self.debug_list_view = QtGui.QListWidget() self.add_debug_button = QtGui.QPushButton('Add Debug') self.edit_debug_button = QtGui.QPushButton('Edit Debug') self.remove_debug_button = QtGui.QPushButton('Remove Debug') self.button_layout = QtGui.QVBoxLayout() # setup layout self.name_layout.addWidget(self.debug_name_label) self.name_layout.addWidget(self.debug_name_field) self.layout.addLayout(self.name_layout,0,0) self.component_layout.addWidget(self.component_tree_label) self.component_layout.addWidget(self.component_tree_view) self.layout.addLayout(self.component_layout,1,0) self.vector_layout.addWidget(self.vector_list_label) self.vector_layout.addWidget(self.vector_list_view) self.layout.addLayout(self.vector_layout,1,1) self.color_layout.addWidget(self.color_list_label) self.color_layout.addWidget(self.color_list_view) self.layout.addLayout(self.color_layout,1,2) self.layout.addWidget(self.debug_list_view,2,0) self.button_layout.addWidget(self.add_debug_button) self.button_layout.addWidget(self.edit_debug_button) self.button_layout.addWidget(self.remove_debug_button) self.layout.addLayout(self.button_layout,2,1) self.group.setLayout(self.layout) # internal events EVENT_MAPPING.register_handler('selected_entity', self.set_entity) EVENT_MAPPING.register_handler('added_component', self.add_component) EVENT_MAPPING.register_handler('removed_component', self.remove_component) # wire up events self.add_debug_button.clicked.connect(self.add_debug) self.edit_debug_button.clicked.connect(self.edit_debug) self.remove_debug_button.clicked.connect(self.remove_debug) self.debug_list_view.currentItemChanged.connect(self.select_debug) # populate color list white = WidgetItemComponent('White', Component(common.WHITE, 'White')) red = WidgetItemComponent('Red', Component(common.RED, 'Red')) green = WidgetItemComponent('Green', Component(common.GREEN, 'Green')) blue = WidgetItemComponent('Blue', Component(common.BLUE, 'Blue')) yellow = WidgetItemComponent('Yellow', Component(common.YELLOW, 'Yellow')) black = WidgetItemComponent('Black', Component(common.BLACK, 'Black')) purple = WidgetItemComponent('Purple', Component(common.PURPLE, 'Purple')) self.color_list_view.addItem(white) self.color_list_view.addItem(red) self.color_list_view.addItem(green) self.color_list_view.addItem(blue) self.color_list_view.addItem(yellow) self.color_list_view.addItem(black) self.color_list_view.addItem(purple)