예제 #1
0
 def find_trip_details(self):
     # calls the Details class from the trip module
     self.details = Details()
     # opens the config file that contains the users trip details
     file = open('config.txt', encoding='utf-8')
     self.home_country = file.readline().strip()
     self.root.ids.home_country.text = str(self.home_country)
     # displays the users trip order in a chronological list
     self.country_list = []
     for line in file:
         parts = line.strip().split(',')
         print(parts)
         self.details.add(parts[0], parts[1], parts[2])
         self.root.ids.country_selection.values = self.country_list
         self.country_list.append(parts[0])
     file.close()
     return self.country_list
예제 #2
0
 def __init__(self, **kwargs):
     super(CurrencyConvert, self).__init__(**kwargs)
     self.details = Details()
예제 #3
0
    def build(self):
        self.trip_details = Details()
        # main window widget build
        self.title = "Foreign Exchange Calculator"
        self.root = Builder.load_file('gui.kv')
        Window.size = (500, 700)

        # text input disable
        self.root.ids.input_country_amount.disabled = True
        self.root.ids.input_home_country_amount.disabled = True

        # status label - config file
        if not os.path.isfile('config.txt'):
            self.root.ids.status.text = "The config file cannot be loaded"
            return
        else:
            self.root.ids.status.text = "The config file successfully loaded"

        # retrieving home country
        file = open('config.txt', encoding='utf-8')
        home_country = file.readline()
        home_country = home_country.rstrip("\n")
        self.root.ids.home_country_label.text = home_country
        file.close()

        # retrieving values for the spinner
        file = open('config.txt', encoding='utf-8')
        country_names = file.readlines()
        file.close()
        del (country_names[0])
        sorted_country_names = sorted(country_names)
        # removes date details from the country list
        a = -1
        for countries in range(len(sorted_country_names)):
            a += 1
            sorted_country_name = sorted_country_names[a]
            sorted_country_name_split = sorted_country_name.rstrip("\n").split(
                ",")
            country_list_dictionary = currency.get_all_details(
                sorted_country_name_split[0])
            country_name_codes = sorted(country_list_dictionary.keys())
        self.root.ids.country_selection.values = country_name_codes

        # date
        self.root.ids.date.text = self.root.ids.date.text + time.strftime(
            "%Y/%m/%d")

        # current location
        file = open('config.txt', encoding='utf-8')
        country_details = file.readlines()
        del (country_details[0])
        current_time = time.strftime("%Y/%m/%d")
        b = -1
        for i in range(len(country_details)):
            b += 1
            country_details_separated = country_details[b]
            country_details_split = country_details_separated.rstrip(
                "\n").split(",")
            self.trip_details.add(country_details_split[0],
                                  country_details_split[1],
                                  country_details_split[2])
        self.current_location = self.trip_details.current_country(current_time)
        self.root.ids.current_destination_label.text += self.current_location
        return self.root