Coder Social home page Coder Social logo

gui's Issues

Return issue

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.

The image isn't showing.

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

This was such a great course btw! few issues

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!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.