예제 #1
0
def main():
    # file_input("Pepe.txt")
    gui = input("Do you want to use the G)UI or C)onsole?: ")
    if gui == 'C':
        mode = input("Do you wish to import custom currencies via a file? (y or n): ")
        valid = False
        while not valid:
            if mode == "y":
                valid = True
                dic, new_name = file_input()
                o = input("What is your starting currency?: ")
                name = input("What do you want to convert to?: ")
                amount = float(input("How much do you want to convert?: "))
                money = Currency(o, name, amount)
                money.add_entry(new_name, dic)
                converted = money.convert()
                # money.show_rates()
                print("Converted {:,.2f} {} to {:,.2f} {}".format(amount, o, converted, name))
            elif mode == "n":
                valid = True
                original = input("What is your starting currency?: ")
                amount = float(input("How much do you want to convert?: "))
                name = input("What do you want to convert to?: ")
                money = Currency(original, name, amount)
                converted = money.convert()
                # money.show_rates()
                print("Converted {:,.2f} {} to {:,.2f} {}".format(amount, original, converted, name))
            else:
                print("Invalid choice, try again...")
                valid = False
    else:
        GUI().run()