I apologize if the answer is already on here but I did a pretty good search.
if I change the number and then hit enter I want to popup and ask Yes, No then proceed or exit.
def runAction(self, event):
system.perspective.print(message='Key ' + event.keyCode + event.key, destination="all")
self.session.custom.newSequenceNumber = event.keyCode
if event.key == '\n':
system.perspective.openPopup("messageBox",'ChangeSequence', title='Key ' + event.keyCode + event.key, showCloseIcon = True)
else:
system.perspective.openPopup("messageBox",'ChangeSequence', title='Key ' + event.keyCode + event.key, showCloseIcon = True)
#system.perspective.openPopup("messageBox",'Popups/MessageBox', params = {'message':self.getSibling("TextField").props.text})
So I have this Table that I want to run this script on but want to ask yes or no to first.
I am have problems opening popup or even printing to console's
|||
|---|---|
||def get_sequence_values(data):|
|| return [data.getValueAt(row, 'Sequence') for row in range(data.getRowCount())]|
|| |
||def get_sorted_indices(sequence_values):|
|| return sorted(range(len(sequence_values)), key=lambda k: sequence_values[k])|
|| |
||def get_row_values(data, row_index):|
|| return [data.getValueAt(row_index, col) for col in range(data.getColumnCount())]|
|||
||def swap_rows(data, row_index1, row_index2):|
|| if 0 <= row_index1 < data.getRowCount() and 0 <= row_index2 < data.getRowCount():|
|| if row_index1 != row_index2:|
|| row1_values = get_row_values(data, row_index1)|
|| row2_values = get_row_values(data, row_index2)|
|| # Delete the row with the higher index first|
|| if row_index1 < row_index2:|
|| data = system.dataset.deleteRow(data, row_index2)|
|| data = system.dataset.deleteRow(data, row_index1)|
|| data = system.dataset.insertRow(data, row_index1, row2_values)|
|| data = system.dataset.insertRow(data, row_index2, row1_values)|
|| else:|
|| data = system.dataset.deleteRow(data, row_index1)|
|| data = system.dataset.deleteRow(data, row_index2)|
|| data = system.dataset.insertRow(data, row_index2, row1_values)|
|| data = system.dataset.insertRow(data, row_index1, row2_values)|
|| return data|
||def adjust_sequence_values(data):|
|| for row in range(data.getRowCount()):|
|| data = system.dataset.setValue(data, row, 'Sequence', row + 1)|
|| return data|
||newValue = event.value|
|||
||columnName = event.column|
||data = self.props.data|
||maxSequence = max(get_sequence_values(data))|
||if columnName == 'Sequence' and newValue is not None:|
|||
|| if newValue <= maxSequence:|
|| originalSequenceValues = get_sequence_values(data)|
|| newData = system.dataset.setValue(data, event.row, columnName, newValue)|
|| newRowIndex = originalSequenceValues.index(newValue)|
|| if newRowIndex != event.row:|
|| newData = swap_rows(newData, event.row, newRowIndex)|
|| newData = adjust_sequence_values(newData)|
|| self.props.data = newData|