def get_weather(zipcode): '''Will fetch the weather data using the latitude and longitude of a location''' lat, lon, town = get_location(zipcode) url = "https://api.openweathermap.org/data/2.5/onecall?lat={LAT}&lon={LON}&e"\ "xclude=minutely,hourly,alerts&appid={KEY}&units=imperial".format(\ LAT=lat, LON=lon, KEY=WEATHER_KEY) data = requests.get(url) data = data.json() current_temp = str(data["current"]["temp"]) current_temp = str(round(float(current_temp))) current_weather = str(data["current"]["weather"][0]["main"]) icon_curr = str(data["current"]["weather"][0]["icon"]) icon_curr = get_icon(icon_curr) today = [town, current_temp, current_weather, icon_curr] day_1 = pull_weather(0, data) day_2 = pull_weather(1, data) day_3 = pull_weather(2, data) day_4 = pull_weather(3, data) day_5 = pull_weather(4, data) lst = [today, day_1, day_2, day_3, day_4, day_5] return lst
def _open_window(cfg, title): app = wx.App() frame = InheritedMainFrame(None, _VERSION, cfg, title) frame.SetIcon(icon.get_icon()) frame.Show() app.SetTopWindow(frame) app.MainLoop()
def on_about_selected(self, event): about = wx.AboutDialogInfo() about.Name = "Remote ADB Connection Manager" about.Version = self._version about.Copyright = "(C) 2015-2016 Yutaka Kato" about.WebSite = "https://github.com/mikan/racm" about.SetIcon(icon.get_icon()) wx.AboutBox(about)
def convert_to_icon(path): '''Convert Image to QPixmap, which could be used in QIcon(). path -- file/dir path to get the icon image of ''' im = get_icon(path, 'large') im = im.convert('RGBA') data = im.tobytes('raw', 'RGBA') qim = QImage(data, 32, 32, QImage.Format_RGBA8888) return QPixmap.fromImage(qim)
def pull_weather(index, data): '''Pulls the weather data for the specific day''' idx = int(index) dt_day = str(data["daily"][idx]["dt"]) date_day, dow = convert(dt_day) max_day = str(data["daily"][idx]["temp"]["max"]) max_day = str(round(float(max_day))) min_day = str(data["daily"][idx]["temp"]["min"]) min_day = str(round(float(min_day))) weather_day = str(data["daily"][idx]["weather"][0]["main"]) icon_day = str(data["daily"][idx]["weather"][0]["icon"]) icon_day = get_icon(icon_day) lst = [date_day, dow, max_day, min_day, weather_day, icon_day] return lst