def actionPerformed(self, event): actionCommand = event.getActionCommand() selection = self.list.getSelectedIndex() if actionCommand == COMMAND_PLAY_MOVIE: self.movie.play() elif actionCommand == COMMAND_ADD_IMG: self.listModel.addElement(media.pickAFile()) self.updateMovie() elif actionCommand == COMMAND_ADD_DIR: self.addImagesFromDirectoryIntoListModel(media.pickAFolder()) self.updateMovie() elif actionCommand == COMMAND_DELETE_IMG: if selection >= 0: self.listModel.remove(selection) self.updateMovie() elif actionCommand == COMMAND_CLEAR_IMG: self.listModel.clear() self.updateMovie() elif actionCommand == COMMAND_MOVE_UP: if selection > 0: itemAbove = self.listModel.get(selection - 1) itemBelow = self.listModel.get(selection) self.listModel.set(selection - 1, itemBelow) self.listModel.set(selection, itemAbove) self.list.setSelectedIndex(selection - 1) self.updateMovie() elif actionCommand == COMMAND_MOVE_DOWN: if selection >= 0 and selection < self.listModel.size() - 1: itemAbove = self.listModel.get(selection) itemBelow = self.listModel.get(selection + 1) self.listModel.set(selection, itemBelow) self.listModel.set(selection + 1, itemAbove) self.list.setSelectedIndex(selection + 1) self.updateMovie() elif actionCommand == COMMAND_CHANGE_FPS: self.fps = SimpleInput.getIntNumber( "Enter the number of frames per second") else: pass
def requestString(message): return SimpleInput.getString(message)
def requestIntegerInRange(message, min, max): if min >= max: print "requestIntegerInRange(message, min, max): min >= max not allowed" raise ValueError return SimpleInput.getIntNumber(message, min, max)
def requestInteger(message): return SimpleInput.getIntNumber(message)