Skip to content

Instantly share code, notes, and snippets.

@codejoust
Created April 22, 2014 15:22
Show Gist options
  • Save codejoust/11183442 to your computer and use it in GitHub Desktop.
Save codejoust/11183442 to your computer and use it in GitHub Desktop.
from Tkinter import *
import json
import urllib2
def get_location():
req = urllib2.urlopen('http://freegeoip.net/json/')
req_str = req.read()
return json.loads(req_str)
def get_todays_weather(coords):
req = urllib2.urlopen('http://api.openweathermap.org/data/2.5/weather?lat=%s&lon=%s' % (coords['latitude'], coords['longitude']))
req_weather_str = req.read()
weather_data = json.loads(req_weather_str)
return weather_data
def convert_to_farenheit(kelvin):
#(K- 273.15)* 1.8000 + 32.00
return (float(kelvin) - 273.15) * 1.8000 + 32.00
def analyze_weather(temp): print "It's %.2f today" % temp
class WindowManager:
def __init__(self):
self.master = Tk()
def add_title(self, title):
Label(text=title, font=('Helvetica', 22)).pack()
def add_dict(self, dictin):
for key, value in dictin.items():
Label(text='%s: %s' % (key, value)).pack()
def show(self):
mainloop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment