keithgalli / gui Goto Github PK
View Code? Open in Web Editor NEWSource Code to go along with my video on how to program a gui in python using Tkinter
Source Code to go along with my video on how to program a gui in python using Tkinter
Hello!
Great vid, it has been a great help in understanding python and GUI interfaces.
I'm having an issue returning the weather in the label text, it keeps printing none.
def format_response(weather):
name = print(weather['name'])
country = print(weather['sys']['country'])
desc = print(weather['weather'][0]['description'])
temp = print('Temp', weather['main']['temp'])
humidity = print('Humidity', weather['main']['humidity'])
return(str(name) + '' +str(country) + '' + str(desc) + '' + str(temp) + '' + str(humidity))
def get_weather(city):
weather_key = '46a3b3ce2a940322a6965e7e6e433cc1'
url = 'http://api.openweathermap.org/data/2.5/weather?'
params = {'APPID': weather_key, 'q': city, 'units': 'metric'}
response = requests.get(url, params=params)
weather = response.json()
label['text'] = format_response(weather)
that's my code, am I doing anything wrong? your assistance will be appreciated, many thanks.
I am running on an issue with the 'import requests' line
and also something is going on with the 'lambda'
Exception in Tkinter callback
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/tkinter/init.py", line 1705, in call
return self.func(*args)
File "/Users/singlefawn/PycharmProjects/test/exportToHTML/1997-02.py", line 55, in
button = tk.Button(frame, text="Get Weather", font=40, command=lambda: get_weather(entry.get()))
File "/Users/singlefawn/PycharmProjects/test/exportToHTML/1997-02.py", line 31, in get_weather
response = requests.get(url, params=params)
NameError: name 'requests' is not defined
What's really cool about your videos are you actually are a great teacher, the beat was great I was able to learn through two sitting sessions of your video for about 4 hours all together. I started learning python two months ago now and moving into actually building a desktop app that runs was a big leap. This one video has exposed me to API understanding all the relwidth stuff plenty of really cool stuff. Please keep up the good work!
background_image = tk.PhotoImage(file = "C:\Users\Aanu\Desktop\Python\download.png"')
background_label = tk.Label(root, image = background_image)
background_label.place(relwidth=1, relheight=1)
There is no error with this and everything seems to be working fine but the image isn't showing
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.