def add_combo(): while True: #se pide la información del combo try: name = input('Combo que desea agregar: ') number_of_products = int(input('¿Cuántos productos tiene el combo?: ')) #si el combo no tiene 2 o más productos no se puede agregar if number_of_products >= 2: products = products_list(number_of_products) else: print('El combo debe de tener más de 2 productos') raise Exception #raw_price es el precio sin iva raw_price = float(input('Precio: ')) #aqui se le agrega el IVA al precio price = Combo.combo_price(raw_price) break except: print('Ingrese datos válidos') #guardo el combo en una variable combo = Combo(name, products, price) m = ComboMenu(combo) #función de la clase para agregar el combo al menú m.add_combo('combo_menu.txt') print(f'Combo {combo.name} agregado exitosamente') return m.show_combo_menu()
def fill_combos(file_name): combos = [] with open(file_name) as f: for line in f: combo = line[:-1].split(',') new_combo = Combo(combo[0],float(combo[1]),combo[2]) combos.append(new_combo) return combos
def agregar_combo(self): # Método para agregar combo nombre = input("Indique el nombre del combo: ") productos = [] continuar = '' while len(productos) < 2 or continuar == 'S': producto = self.buscar_producto_nombre() productos.append(producto) if len(productos) >= 2: continuar = input("Desea agregar otro producto (S/N): ") while continuar!= 'S' and continuar!= 'N': continuar = input("Opcion incorrecta. Desea agregar otro producto (S/N): ") costo = float(input("Indique el costo del combo: ")) self.combos.append(Combo(nombre,productos,costo))
def playCards(self, player, currentTrick): cardsPlayed = SortedCardCollection() valid = False combo = None while not valid: self.inputCardsPlayed(cardsPlayed, player) combo = Combo(player, cardsPlayed) valid = self.validateCardsPlayed(combo, currentTrick, player) if not valid: print("Invalid!") cardsPlayed.removeAll() else: print("VALID!") currentTrick.add(combo) player.removeCards(cardsPlayed)
def droneAssigner(droneList, parcelList): """ Decides which drone is best for which parcel based on drone attributes. When picking a drone for a parcel, the following criteria is applied: The drone must be operating in the same area as the parcel request, must have enough weight capacity to carry the parcel, have enough autonomy to go and return to base. If multiple drones satisfy the criteria, one will be picked based on the following attributes (by this order): drone available the earliest, if tied, drone with the most autonomy, if tied, drone with least distance travelled, if tied, first drone when sorted by ascending lexicographical order of their name. Requires: droneList is a list containing objects of Drone class. parcelList is a list containing objects of Parcel class. Ensures: delivery of ComboList, which contains Combo objets, associated drones and parcels. """ ComboList = [] for parcel in parcelList: droneList.sort(key=lambda drone: (drone.getArea() != parcel.getArea(), dt.datetime.strptime(drone.getDMYDate(), '%d-%M-%Y'), dt.datetime.strptime(drone.getAvailabilityHour( ), '%H:%M'), -float(drone.getAutonomy()), float(drone.getDistanceTraveled()), drone.getName())) # 3 possible drones are picked, which will be compared possibleDrone1 = droneList[0] possibleDrone2 = droneList[1] possibleDrone3 = droneList[2] if (possibleDrone1.getArea() != parcel.getArea()) or float( possibleDrone1.getRange()) < int( parcel.getBaseDistance() or float(possibleDrone1.getAutonomy()) < (float(parcel.getBaseDistance()) * 2 / 1000)) or float( possibleDrone1.getWeightLimit()) < float( parcel.getWeight()): if (possibleDrone2.getArea() != parcel.getArea()) or float( possibleDrone2.getRange()) < int( parcel.getBaseDistance() or float(possibleDrone2.getAutonomy()) < (float(parcel.getBaseDistance()) * 2 / 1000)) or float( possibleDrone2.getWeightLimit()) < float( parcel.getWeight()): if (possibleDrone3.getArea() != parcel.getArea() ) or float(possibleDrone3.getRange()) < int( parcel.getBaseDistance()) or float( possibleDrone3.getAutonomy()) < (float( parcel.getBaseDistance()) * 2 / 1000) or float( possibleDrone3.getWeightLimit()) < float( parcel.getWeight()): ComboObject = Combo("", parcel, "cancelled") ComboList.append(ComboObject) continue else: rightDrone = possibleDrone3 else: rightDrone = possibleDrone2 else: rightDrone = possibleDrone1 # a drone has been selected and it's statistics/attributes are going to be updated based on the parcel's statistics/attributes rightDrone.setAutonomy( round((float(rightDrone.getAutonomy()) - (float(parcel.getBaseDistance()) * 2 / 1000)), 1)) rightDrone.setDistanceTraveled( round((float(rightDrone.getDistanceTraveled()) + float(parcel.getBaseDistance()) * 2 / 1000), 1)) parcel.setTimeParcelLeft( t.timeMax(rightDrone.getAvailabilityHour(), parcel.getOrderHour())) parcel.setDateParcelLeft( t.dateMax(rightDrone.getAvailabilityDate(), parcel.getOrderDate())) rightDrone.setAvailabilityHour( t.updateTime( t.timeMax(rightDrone.getAvailabilityHour(), parcel.getOrderHour()), parcel.getDuration())) # future proofing in the eventuality that a parcel can only be delivered past 8pm, said parcel will be delivered the day after if t.hourToDatetime( rightDrone.getAvailabilityHour()) > t.hourToDatetime("20:00"): parcel.setTimeParcelLeft("08:00") parcel.setDateParcelLeft( t.updateDate(parcel.getDateParcelLeft(), 1)) rightDrone.setAvailabilityHour( t.updateTime("08:00", parcel.getDuration())) rightDrone.setAvailabilityDate( t.updateDate(parcel.getOrderDate(), 1)) rightDrone.setStatus("used") ComboObject = Combo(rightDrone, parcel) ComboList.append(ComboObject) return ComboList
def __init__(self): fileLocs = FileLocations() prefix = fileLocs.comboSounds zero = GoodStep(0) one = GoodStep(1) two = GoodStep(2) three = GoodStep(3) five = GoodStep(5) six = GoodStep(6) seven = GoodStep(7) eight = GoodStep(8) comboA = Combo((six, seven, six), "Warm_Er_Up") comboB = Combo((six, three, zero), "Jackhammer") comboC = Combo((seven, six, three), "Sidewinder") comboD = Combo((seven, five, eight), "Off_The_Rocker") comboE = Combo((one, six, eight), "Chromosomal") comboF = Combo((one, eight, six), "Corkscrew") comboG = Combo((three, five, seven), "Whirlwind") comboH = Combo((three, zero, three), "Left_Waggle") comboI = Combo((five, eight, five), "Right_Waggle") comboJ = Combo((five, zero, three), "Sicktackular") comboK = Combo((two, seven, six), "Thunderstorm") comboL = Combo((two, five, eight), "Triple_Jump") comboM = Combo((zero, one, two), "Super_Slide") comboN = Combo((zero, two, five), "ZigZag") comboO = Combo((eight, seven, six), "Exit_Hatch") comboP = Combo((eight, three, one), "Blast_Off") comboQ = Combo((six, three, seven, seven), "Power_Surge") comboR = Combo((seven, one, three, five), "Inferno") comboS = Combo((eight, five, five, eight), "Carolina_Two_Step") comboT = Combo((three, six, seven, two), "Torpedo") comboU = Combo((five, two, one, five), "Fusion") comboV = Combo((zero, zero, three, one), "Somersault") comboW = Combo((one, six, seven, eight), "Psycho_T") comboX = Combo((two, eight, two, zero), "Ricochet") comboY = Combo((six, eight, two, zero, six), "Atomic_Accelerator") comboZ = Combo((seven, five, one, three, seven), "Flipside_360") comboAA = Combo((eight, five, seven, three, six), "Berserker") comboBB = Combo((three, zero, three, one, three), "Canonball") comboCC = Combo((five, eight, six, three, two), "Schism_Leap") comboDD = Combo((zero, one, zero, one, zero), "Running_Man") comboEE = Combo((one, two, zero, one, one), "Suspended_In_Time") comboFF = Combo((two, eight, five, three, seven), "Annihilator") self.comboDictionary= [comboA,comboB,comboC,comboD,comboE,comboF,comboG,comboH,\ comboI, comboJ, comboK, comboL, comboM, comboN, comboO, comboP,\ comboQ,comboR,comboS,comboT,comboU,comboV,comboW,comboX,comboY, \ comboZ,comboAA,comboBB,comboCC,comboDD,comboEE,comboFF] self.MINCOMBO = 3 self.MAXCOMBO = 5 self.combosSize3 = self.createCombosOfSize(3) self.combosSize4 = self.createCombosOfSize(4) self.combosSize5 = self.createCombosOfSize(5)
def startGame(screen): gameInfo = GameInfo() screenInf = ScreenInfo() player = gameInfo.getPlayer(0) gameStats = player.getGameStats() gameStats.newRound() difficulty = player.getProfile().getDifficulty() if (difficulty == 0): FAIR_DIFF = .3 if (difficulty == 1): FAIR_DIFF = .25 if (difficulty == 2): FAIR_DIFF = .2 HIT_TOL = FAIR_DIFF BEAT_TOL = 0.033 print HIT_TOL comboDictionary = ComboDictionary() fileLocs = FileLocations() scorer = Score() screenBorder = ScreenBorder(screen) #find one simple song for this songfile = fileLocs.songs + "\TeQuieroMas.mp3" timefile = fileLocs.beats + "\TeQuieroMas.times" #initialize pygame pygame.mixer.pre_init(44100, -16, 2, 1024 * 2) pygame.init() music = pygame.mixer.music music.load(songfile) #initialize sound controller soundController = SoundEffectController() clock = pygame.time.Clock() #get the times from the times file times = [float(t.strip()) for t in file(timefile, 'rt')] #FUNCTIONS FOR SINGLEPLAYER #get the change in time between the beat times and the current time def GetDelta(t): n = bisect(times, t) d1 = t - times[n - 1] try: d2 = times[n] - t except IndexError: return None if d1 < d2: return -d1 else: return d2 #figure out if the change in time / tolerance is < .5, it if is, it's a hit def HitOnBeat(changeInTime, hitTolerance): dt = changeInTime ht = hitTolerance f = max(-1, min(1, (dt / ht))) hit = abs(f) < 0.5 errors.append(f) return hit #compare containers of goodsteps and see if they are equal def CompareGoodStepContainers(container1, container2): isTrue = True if len(container1) != len(container2): return False for i in range(0, len(container1)): if container1[i].getLocation() != container2[i].getLocation(): return False return isTrue #combo Detection will return combo if yes, none if not def CheckForCombo(): currentStepLength = len(gameStats.getComboSteps()) comboStepList = gameStats.getComboSteps() for item in comboDictionary.getCombosOfSize(3): if CompareGoodStepContainers( comboStepList[currentStepLength - 3:currentStepLength], item.getSteps()): return item for item in comboDictionary.getCombosOfSize(4): if CompareGoodStepContainers( comboStepList[currentStepLength - 4:currentStepLength], item.getSteps()): return item for item in comboDictionary.getCombosOfSize(5): if CompareGoodStepContainers( comboStepList[currentStepLength - 5:currentStepLength], item.getSteps()): return item return None #prepare screen flash def FlashOrUpdateScreen(gameStats): if abs(dt) < BEAT_TOL: #screen.fill((0, 0, 0)) screenBorder.IncrementDanceFloorCounter() #pygame.display.flip() screenBorder.drawScreen(gameStats.getGoodSteps(), screenInf, gameStats.getPointsPerHit(), gameStats.getCurrentScore(), gameInfo.getGameMode()) #update score def UpdateScore(gameinfo, dt): #set points per hit gameStats.setPointsPerHit( int( scorer.scoreHit(gameStats.getGoodSteps(), difficulty, dt, gameStats.getCurrentCombo()))) currentScore = gameStats.getCurrentScore() pointsForCurrentHit = gameStats.getPointsPerHit() currentScore += pointsForCurrentHit gameStats.setCurrentScore(currentScore) def checkPositiveSounds(gameInfo): playPointsSound(gameInfo) #plays number of points based on how many points there are, every 100,000 def playPointsSound(gameInfo): pass """ totalScore = gameInfo.getCurrentScore() pointGoal = gameInfo.getPointGoal() if totalScore >= pointGoal: soundController.playNumberSound(totalScore) print "you've reached " + str(pointGoal) + " points!" gameInfo.setPointGoal(pointGoal + 100000) """ #depending on the level, create a list of combos to ask for # def createAskComboList(gameInfo): # #easy # comboListtoAsk = [] # # unlockLevel = gameInfo.getCurrentLevel() # #unlockLevel = 9 # print "highest level is " + str(unlockLevel) # # if unlockLevel ==0 or unlockLevel ==1: # combos= comboDictionary.getCombosOfSizeAndDifficulty(3, "easy") # combos1 = comboDictionary.getCombosOfSizeAndDifficulty(3, "medium") # comboListtoAsk = combos + combos1 # # elif unlockLevel ==2 or unlockLevel ==3: # combos = comboDictionary.getCombosOfSizeAndDifficulty(3, "easy") # combos1 = comboDictionary.getCombosOfSizeAndDifficulty(3, "medium") # combos2 = comboDictionary.getCombosOfSizeAndDifficulty(3, "hard") # comboListtoAsk = combos + combos1 + combos2 # # elif unlockLevel ==4 or unlockLevel ==5: # combos = comboDictionary.getCombosOfSizeAndDifficulty(3, "easy") # combos1 = comboDictionary.getCombosOfSizeAndDifficulty(3, "medium") # combos2 = comboDictionary.getCombosOfSizeAndDifficulty(3, "hard") # combos3 = comboDictionary.getCombosOfSizeAndDifficulty(4, "easy") # comboListtoAsk = combos + combos1 + combos2 + combos3 # # # elif unlockLevel ==6 or unlockLevel ==7: # combos = comboDictionary.getCombosOfSizeAndDifficulty(3, "easy") # combos1 = comboDictionary.getCombosOfSizeAndDifficulty(3, "medium") # combos2 = comboDictionary.getCombosOfSizeAndDifficulty(3, "hard") # combos3 = comboDictionary.getCombosOfSizeAndDifficulty(4, "easy") # combos4 = comboDictionary.getCombosOfSizeAndDifficulty(4, "medium") # combos5 = comboDictionary.getCombosOfSizeAndDifficulty(4, "hard") # combos6 = comboDictionary.getCombosOfSizeAndDifficulty(5, "easy") # comboListtoAsk = combos + combos1 + combos2 + combos3 + combos4 + combos5 + combos6 # # elif unlockLevel ==8 or unlockLevel ==9: # combos = comboDictionary.getCombosOfSizeAndDifficulty(3, "easy") # combos1 = comboDictionary.getCombosOfSizeAndDifficulty(3, "medium") # combos2 = comboDictionary.getCombosOfSizeAndDifficulty(3, "hard") # combos3 = comboDictionary.getCombosOfSizeAndDifficulty(4, "easy") # combos4 = comboDictionary.getCombosOfSizeAndDifficulty(4, "medium") # combos5 = comboDictionary.getCombosOfSizeAndDifficulty(4, "hard") # combos6 = comboDictionary.getCombosOfSizeAndDifficulty(5, "easy") # combos7 = comboDictionary.getCombosOfSizeAndDifficulty(5, "medium") # combos8 = comboDictionary.getCombosOfSizeAndDifficulty(5, "hard") # comboListtoAsk = combos + combos1 + combos2 + combos3 + combos4 + combos5 + combos6 + combos7 + combos8 # # # # gameInfo.setAskedComboList(comboListtoAsk) # def askForCombo(gameInfo): #get a combo to be played, randomly from askedComboList comboList = gameInfo.getAskedComboList() gameInfo.setAskedCombo(comboList[random.randrange(0, (len(comboList)))]) combo = gameInfo.getAskedCombo() soundController.queueSoundFile(fileLocs.careerSounds + "\\tryCombo.ogg") playComboSteps(combo) print "Let's try doing a combo! " + combo.getName() print combo.getStepNameList() def askForWarmupCombo(): soundController.queueSoundFile(fileLocs.careerSounds + "\\tryCombo.ogg") playComboSteps(warmupCombo) def playComboSteps(combo): steps = combo.getSteps() for step in steps: soundController.queueSoundFile(step.getSoundFile()) def checkForAskedCombo(gameInfo): if gameInfo.getCurrentCombo() == warmupCombo: print "Great Job, you hit the combo!" gameInfo.setAskedCombosHit(gameInfo.getAskedCombosHit() + 1) gameInfo.setAskedCombo(None) global hitWarmup return True return False def comboProcessing(): gameStats.setCurrentCombo(CheckForCombo()) if (gameStats.getCurrentCombo() != None): soundController.playComboInSong(gameStats.getCurrentCombo()) gameStats.clearComboSteps() return True return False def stepProcessing(currentStep): gameStats.addStep(currentStep) gameStats.setBeatsHit(gameStats.getBeatsHit() + 1) gameStats.setBeatsAttempted(gameStats.getBeatsAttempted() + 1) soundController.playHitSound() def missedBeat(): gameStats.setBeatsAttempted(gameStats.getBeatsAttempted() + 1) gameStats.clearGoodSteps() gameStats.clearComboSteps() def playNextPrompt(state, time): """ Takes needed action for given state, returns next appropriate state """ if state == 0: if music.get_pos( ) - time > 5000: # makes sure there's always a bit of a pause -- tweak for each one soundController.queueSoundFile(fileLocs.menuSounds + "\menu_07_01.ogg") return (1, music.get_pos()) #updated state and time return (0, time) #no change to state or time if state == 1: if music.get_pos() - time > 9000: soundController.queueSoundFile(fileLocs.menuSounds + "\menu_07_03.ogg") return (2, music.get_pos()) return (1, time) if state == 2: if music.get_pos() - time > 5000: soundController.queueSoundFile(fileLocs.menuSounds + "\menu_07_02.ogg") return (3, music.get_pos()) return (2, time) if state == 3: if music.get_pos() - time > 5000: askForWarmupCombo() return (4, music.get_pos()) return (3, time) if state == 4: if music.get_pos() - time > 15000: soundController.queueSoundFile(fileLocs.menuSounds + "\menu_07_07.ogg") return (3, music.get_pos()) return (4, time) if state == 5: if time != -1: soundController.queueSoundFile(fileLocs.menuSounds + "\menu_07_05.ogg") soundController.queueSoundFile(fileLocs.menuSounds + "\menu_07_06.ogg") return (5, -1) #start the single player mode and initialize music.set_volume(.5) music.play() errors = [] cntrl = Controller() #createAskComboList(gameInfo) #tutorial-specific vars promptState = 0 lastPromptTime = 0 hitWarmup = False warmupCombo = Combo((GoodStep(6), GoodStep(7), GoodStep(6)), "Warm_Er_Up") # timeSinceCombo = 0 # timeOfCombo = 0 # repeatedCombo = False run = True #start the game loop while run: #get current time position in song t = music.get_pos() * 0.001 dt = GetDelta(t) if t > times[len(times) - 1]: music.stop() run = False break if music.get_pos() > 4000: if not soundController.isPlaying(): promptState, lastPromptTime = playNextPrompt( promptState, lastPromptTime) # timeOfCombo= t soundController.update() if hitWarmup: # run = False if not soundController.isPlaying() and promptState == 5: run = False else: promptState = 5 for event in pygame.event.get(): #check for escape if event.type == pygame.KEYDOWN: if event.key == pygame.K_ESCAPE: music.stop() run = False #see if it's a goodStep currentStep = cntrl.checkEvent(event, t) if currentStep != None: #check to see if you hit the beat #if you hit the beat if HitOnBeat(dt, HIT_TOL) == True: stepProcessing(currentStep) #check to see if it was a combo hitWarmup = comboProcessing() #update the score UpdateScore(gameInfo, dt) checkPositiveSounds(gameInfo) else: #clear the goodSteps and combo list, because you stepped on a wrong beat missedBeat() else: pygame.time.wait(2) clock.tick(30) FlashOrUpdateScreen(gameStats) # soundController.update() gameStats.setCurrentCombo(None) music.fadeout(4000) print "exiting"
def add_product_combo(): """[Agregar combo o producto como objetos y con sus atributos en su archivo de texto respectivo ] """ products_menu = [] combos_menu = [] while True: try: type_food = int(input("\n¿Qué quiere agregar al menú? \n1. Alimento \n2. Bebida \n3. Combo \n>>> ")) if type_food not in range(1,4): raise ValueError break except ValueError: print("\nError: Dato ingresado no forma parte de las opciones dadas") if type_food==1: name_dish = product_name() if file_existence("products_information.txt"): with open("products_information.txt", 'rb') as f: saved_products_list = pickle.load(f) for product in saved_products_list: while (product.name) == name_dish: print("ERROR: El nombre introducido ya existe") name_dish = product_name() while True: try: type_dish = int(input("\n¿Qué clase de alimento es? \n1.De empaque \n2.De preparación \n>>> ")) if type_dish not in range(1,3): raise ValueError break except ValueError: print("\nError: ¡Dato inválido!\n") dish_price = product_price() if type_dish==1: type_dish = 'de empaque' elif type_dish==2: type_dish = 'de preparación' product = Dish(name_dish, dish_price, type_dish) products_menu.append(product) print("\n¡Alimento registrado exitosamente!") elif type_food==2: name_drink = product_name() if file_existence("products_information.txt"): with open("products_information.txt", 'rb') as f: saved_products_list = pickle.load(f) for product in saved_products_list: while (product.name) == name_drink: print("ERROR: El nombre introducido ya existe") name_drink = product_name() while True: try: size_drink = int(input("\n¿Cuál es el tamaño de la bebida? \n1.Pequeño \n2.Mediano \n3.Grande \n>>> ")) if size_drink not in range(1,4): raise ValueError break except ValueError: print("\nError: ¡Dato inválido!\n") drink_price = product_price() if size_drink==1: drink_size = 'pequeño' elif size_drink==2: drink_size = 'mediano' elif size_drink==3: drink_size = 'grande' product = Drink(name_drink, drink_price, drink_size) products_menu.append(product) print("\n¡Bebida registrada exitosamente!") elif type_food==3: name_combo = input("Ingrese el nombre del combo: ") if file_existence("combos_information.txt"): with open("combos_information.txt", 'rb') as f: saved_combos_list = pickle.load(f) for combo in saved_combos_list: while (combo.name) == name_combo: print("ERROR: El nombre introducido ya existe") name_combo = input("Ingrese el nombre del combo: ") combo_products = [] while True: try: products_amount = int(input("\nIngrese la cantidad de productos que tendrá el combo (min: 2 y max: 10): ")) if products_amount not in range(2,10): raise ValueError break except ValueError as identifier: print("Error: Dato ingresado no es válido") print("\nIngrese un solo producto a medida que le vaya preguntando el sistema") for i in range(products_amount): combo_product = input("Ingrese el nombre del producto: ") combo_products.append(combo_product) price_combo = product_price() combo = Combo(name_combo, price_combo, combo_products) combos_menu.append(combo) print("\n¡Combo registrado exitosamente!") if file_existence("combos_information.txt"): with open("combos_information.txt", 'rb') as f: saved_combos = pickle.load(f) for combo in combos_menu: saved_combos.append(combo) with open("combos_information.txt", 'wb') as file: pickle.dump(saved_combos, file) elif not file_existence("combos_information.txt"): with open("combos_information.txt", 'wb') as file: pickle.dump(combos_menu, file) if file_existence("products_information.txt"): with open("products_information.txt", 'rb') as f: saved_products = pickle.load(f) for product in products_menu: saved_products.append(product) with open("products_information.txt", 'wb') as file: pickle.dump(saved_products, file) elif not file_existence("products_information.txt"): with open("products_information.txt", 'wb') as file: pickle.dump(products_menu, file)
def create_combo(): """ Funcion que permite agregar combos al menu """ #Primero se valida si existe un archivo con los datos de platos en el menu, de ser asi se llena una lista con los datos guardados en el mismo, de lo contrario se crea la lista vacía dish_file = "restaurant_dishes.txt" count_dishes = fm.check_empty(dish_file) if count_dishes: dishes = [] else: dishes = fm.fill_dishes(dish_file) #Primero se valida si existe un archivo con los datos de platos en el menu, de ser asi se llena una lista con los datos guardados en el mismo, de lo contrario se crea la lista vacía combo_file = "restaurant_combos.txt" count_combos = fm.check_empty(combo_file) if count_combos: combos = [] else: combos = fm.fill_combos(combo_file) if len(dishes) == 0: print("No hay productos en el menu") else: more_dishes = '1' combo_products = "" count = 1 while more_dishes == '1': print("Seleccione el producto que desea agregar al combo\n") dish_answer = select_product(dishes) combo_products += f"{dishes[dish_answer-1].name}\t" if count >= 2: more_dishes = input('\nPresione 1 si desea agregar mas productos al combo') count += 1 while True: try: name = input('Introduzca el nombre del combo: ').title() price = float(input('Introduzca el precio del producto: ')) break except: print('Valor invalido. Intente nuevamente') price *= 1.16 combo = Combo(name,price,combo_products) combos.append(combo) fm.create_combos_txt(combos,combo_file)
from sugar.graphics.objectchooser import ObjectChooser from sugar.graphics.alert import Alert, NotifyAlert import pango from book import cBook from book import cPage from book import cOption from textbook import tutorial_book from textbook import empty_book from textbook import credits_book from Combo import Combo from ayuda import HelpButton as Ayudas except ImportError: print 'NO SE ESTA EN SUGAR.. SALIENDO' sys.exit() Fonts = Combo() Fonts.set_items([ "Purisa 8", "Purisa 12", "Purisa 24", "Monospace 8", "Monospace 12", "Monospace 24", "Times New Roman 8", "Times New Roman 12", "Times New Roman 24", "FreeSans 8", "FreeSans 12", "FreeSans 24" ]) Title_Tam = Combo() Title_Tam.set_items([ "Purisa 8", "Purisa 12", "Purisa 24", "Monospace 8", "Monospace 12", "Monospace 24", "Times New Roman 8", "Times New Roman 12", "Times New Roman 24", "FreeSans 8", "FreeSans 12", "FreeSans 24" ]) ColorLetra = ColorToolButton() ColorTitle = ColorToolButton() ColorFondo = ColorToolButton() Col = gtk.gdk.Color('#ffffff')