def scenario_content_changed(self): """ Edit the content (events) of the selected scenario """ # check if there is some text if self.scenario_content.currentItem(): newline = self.scenario_content.currentItem().text() if newline != '': newline = newline.split(' ') # remove space if it is the last character while newline[-1] == "": newline = newline[:-1] # there is new text on the last line, so we create a new event if self.scenario_content.currentRow() + 1 == self.scenario_content.count(): # create a new event if newline[0] == "OSC": newline = newline[1:] print("creating event of type OSC") new_event = self.new_event('Osc', newline) elif newline[0] == "SP": newline = newline[1:] print("creating event of type ScenarioPlay") new_event = self.new_event('ScenarioPlay', newline) elif isinstance(checkType(newline[0]), float) or isinstance(checkType(newline[0]), int): print("creating event of type WAIT") new_event = self.new_event('Wait', checkType(newline[0])) elif newline[0] == "MN": newline = newline[1:] print("creating event of type MidiNote") new_event = self.new_event('MidiNote', newline) else: print("creating event of type OSC") new_event = self.new_event('Osc', newline) # add the event to the scenario self.scenario_selected.add_event(new_event) # display the current scenario (refresh) self.scenario_display(self.scenario_selected) else: # This is an edit of an existing event self.scenario_selected.events[self.scenario_content.currentRow()].command = newline # we need to refresh the duration item on the scenrio_table #don't understant why but with this line, the name is changed too… weird #item = self.scenario_list.item(self.scenario_list.currentRow(),1) row = self.scenario_list.currentRow() #duration = str(self.scenario_selected.getduration()) #item.setText(duration) self.table_list_refresh('scenario') self.scenario_list.setCurrentCell(row, 0)
def output_table_changed(self, row, col): """ An output has been edited """ if self.protocol_table.currentItem(): protocol = self.protocol.currentText() outs = self.project.outputs out = outs[row] attr = self.protocol_table.horizontalHeaderItem(col).text() value = self.protocol_table.currentItem().text() # just to be sure that an int won't be encoded as a symbol value = checkType(value) setattr(out, attr, value) if attr == 'name': self.table_list_refresh('scenario') self.table_list_refresh('event')