Let's code a WEATHER APP in Python! ☀️

  Рет қаралды 14,266

Bro Code

Bro Code

Күн бұрын

Пікірлер: 60
@BroCodez
@BroCodez 3 ай бұрын
openweathermap.org/ import sys import requests from PyQt5.QtWidgets import (QApplication, QWidget, QLabel, QLineEdit, QPushButton, QVBoxLayout) from PyQt5.QtCore import Qt class WeatherApp(QWidget): def __init__(self): super().__init__() self.city_label = QLabel("Enter city name: ", self) self.city_input = QLineEdit(self) self.get_weather_button = QPushButton("Get Weather", self) self.temperature_label = QLabel(self) self.emoji_label = QLabel(self) self.description_label = QLabel(self) self.initUI() def initUI(self): self.setWindowTitle("Weather App") vbox = QVBoxLayout() vbox.addWidget(self.city_label) vbox.addWidget(self.city_input) vbox.addWidget(self.get_weather_button) vbox.addWidget(self.temperature_label) vbox.addWidget(self.emoji_label) vbox.addWidget(self.description_label) self.setLayout(vbox) self.city_label.setAlignment(Qt.AlignCenter) self.city_input.setAlignment(Qt.AlignCenter) self.temperature_label.setAlignment(Qt.AlignCenter) self.emoji_label.setAlignment(Qt.AlignCenter) self.description_label.setAlignment(Qt.AlignCenter) self.city_label.setObjectName("city_label") self.city_input.setObjectName("city_input") self.get_weather_button.setObjectName("get_weather_button") self.temperature_label.setObjectName("temperature_label") self.emoji_label.setObjectName("emoji_label") self.description_label.setObjectName("description_label") self.setStyleSheet(""" QLabel, QPushButton{ font-family: calibri; } QLabel#city_label{ font-size: 40px; font-style: italic; } QLineEdit#city_input{ font-size: 40px; } QPushButton#get_weather_button{ font-size: 30px; font-weight: bold; } QLabel#temperature_label{ font-size: 75px; } QLabel#emoji_label{ font-size: 100px; font-family: Segoe UI emoji; } QLabel#description_label{ font-size: 50px; } """) self.get_weather_button.clicked.connect(self.get_weather) def get_weather(self): api_key = "YOUR API KEY GOES HERE" city = self.city_input.text() url = f"api.openweathermap.org/data/2.5/weather?q={city}&appid={api_key}" try: response = requests.get(url) response.raise_for_status() data = response.json() if data["cod"] == 200: self.display_weather(data) except requests.exceptions.HTTPError as http_error: match response.status_code: case 400: self.display_error("Bad request: Please check your input") case 401: self.display_error("Unauthorized: Invalid API key") case 403: self.display_error("Forbidden: Access is denied") case 404: self.display_error("Not found: City not found") case 500: self.display_error("Internal Server Error: Please try again later") case 502: self.display_error("Bad Gateway: Invalid response from the server") case 503: self.display_error("Service Unavailable: Server is down") case 504: self.display_error("Gateway Timeout: No response from the server") case _: self.display_error(f"HTTP error occurred: {http_error}") except requests.exceptions.ConnectionError: self.display_error("Connection Error: Check your internet connection") except requests.exceptions.Timeout: self.display_error("Timeout Error: The request timed out") except requests.exceptions.TooManyRedirects: self.display_error("Too many Redirects: Check the URL") except requests.exceptions.RequestException as req_error: self.display_error(f"Request Error: {req_error}") def display_error(self, message): self.temperature_label.setStyleSheet("font-size: 30px;") self.temperature_label.setText(message) self.emoji_label.clear() self.description_label.clear() def display_weather(self, data): self.temperature_label.setStyleSheet("font-size: 75px;") temperature_k = data["main"]["temp"] temperature_c = temperature_k - 273.15 temperature_f = (temperature_k * 9/5) - 459.67 weather_id = data["weather"][0]["id"] weather_description = data["weather"][0]["description"] self.temperature_label.setText(f"{temperature_f:.0f}°F") self.emoji_label.setText(self.get_weather_emoji(weather_id)) self.description_label.setText(weather_description) @staticmethod def get_weather_emoji(weather_id): if 200
@শখেরবাড়ি৯৯০
@শখেরবাড়ি৯৯০ 3 ай бұрын
Great🎉
@ZaeNonQ
@ZaeNonQ 3 ай бұрын
this will be good for my non-existent portofolio!
@KouroshKryptic
@KouroshKryptic Ай бұрын
Wdym?
@LouOllivier-Hostin
@LouOllivier-Hostin 2 ай бұрын
You are an incredible human being, congratulations buddy !
@gameios992
@gameios992 3 ай бұрын
Hello Bro, i am studying your course and that is amazing. Thank you. Hope i can become a freelancer by your lessons
@শখেরবাড়ি৯৯০
@শখেরবাড়ি৯৯০ 3 ай бұрын
Thanks for all your videos as a 12 year old i learned a lot . You are pure programming gigachad...
@rohlualalrohluaralte
@rohlualalrohluaralte 3 ай бұрын
He really is a good teacher..I enjoyed this a lot...I'm 9 btw
@felixiyy
@felixiyy 3 ай бұрын
Yea he's an amazing teacher , I'm 7 yrs old , I understood everything❤
@axelgallo8361
@axelgallo8361 3 ай бұрын
yeah he great i`m 4 yer old thank bro code
@heyimrith
@heyimrith 3 ай бұрын
Yea that right as a 11 month old I agree that, I use my brother account
@felixiyy
@felixiyy 3 ай бұрын
Actually my brother who is still in the uterus has learnt quite a lot of programming, he even has made a snake game from bro codes tutorial
@_ba0_
@_ba0_ 2 ай бұрын
Bro is here to save the day again. Thanks to you now I can make guis that don't suck😀
@wrightsolution
@wrightsolution 3 ай бұрын
plz bro make a playlist on javascript projects. You're the only channel in which i could understand and enjoy programming
@yokochannn
@yokochannn 3 ай бұрын
damn bro u already at 2m? your channel is the reason i love do coding and learn about programming. Now i take scicomp course and go back to your channel to learn more
@jjdifsjdfinsd
@jjdifsjdfinsd 27 күн бұрын
Nice video ima doing GCSEs in python at my school so doing this as extra at home really helps thank you for theses videos! ❤
@Hlmg-hw6om
@Hlmg-hw6om 7 сағат бұрын
Great Tutorial. Thank you very much :)
@Krishna-kk5xx
@Krishna-kk5xx 3 ай бұрын
Thanks for this master piece bro
@mistron176
@mistron176 3 ай бұрын
You are a legend man
@meowmeowzza
@meowmeowzza 3 ай бұрын
Bro Code have you ever made a lua course video? I know you did for C++, both of the languages go together very well would love it if you made a lua course!
@fallenkafiel
@fallenkafiel Ай бұрын
How I learn coding with Python by watching coding videos and following along with bro code.
@zyn_rgy
@zyn_rgy 3 ай бұрын
The best Tech Giga-Chad i've ever seen
@nkproduction5570
@nkproduction5570 3 ай бұрын
Bro Code is THE GOAT
@sergeikalabanov7067
@sergeikalabanov7067 3 ай бұрын
Thank you!! Perfect!!
@BeanBagGaming59
@BeanBagGaming59 3 ай бұрын
bro can u please make a tutorial on unreal engine 5 and if you dont know it yet , with your expertise you can prob learn it in like 4 hours lol ur tutorials are the best on youtube forsure so if u can do a tutorial on unreal engine 5 that would be so amazing
@NSA.
@NSA. 3 ай бұрын
Great
@kingfares1371
@kingfares1371 3 ай бұрын
which should I watch this playlist or the 12 hours video??
@Mr.ShubhGoel
@Mr.ShubhGoel 3 ай бұрын
hey dude, i was wondering if you could make setup video of VS CODE for the language C bcz i don't get my output under the OUTPUT bar rather i get it under the terminal bar i wish u would reply soon 😀...
@trithanh8536
@trithanh8536 3 ай бұрын
thank sir
@magnivvvvv
@magnivvvvv 2 ай бұрын
the all thing with the import sys isnt working to me. "no model named requests"
@DeadSoul26-o4q
@DeadSoul26-o4q 3 ай бұрын
Hello, I know this is a weird question but I have a problem with the random module; randit(); in the snake game. It says something about float can't be interpreted into an integer. Bro please help me solve this. Appropriate your work tho :)
@mohameddeeq-l2s
@mohameddeeq-l2s 3 ай бұрын
ask chatgpt
@DeadSoul26-o4q
@DeadSoul26-o4q 2 ай бұрын
@@mohameddeeq-l2s I did and he's not providing useful info
@mintz347
@mintz347 3 ай бұрын
Do some Django,or spring boot project bro??
@QuantumSc
@QuantumSc 26 күн бұрын
Yo bro can you explain what yield means?
@sayaadadurian
@sayaadadurian 3 ай бұрын
Do a lesson on Enums
@AbdulraheemAbdullah-e4w
@AbdulraheemAbdullah-e4w 3 ай бұрын
vote for node js and mern stack course big fan plz upload mern stack course u already have upload php but i dont like php plz upload mern stack
@tarindell187
@tarindell187 3 ай бұрын
Can you please talk about qthreads
@faiza4769
@faiza4769 3 ай бұрын
Bro do pytorch course please
@rajushah8748
@rajushah8748 3 ай бұрын
❤❤
@kavitarattan-jo7qb
@kavitarattan-jo7qb 3 ай бұрын
Do a Face Reval Bro
@abdallahaltozeri3897
@abdallahaltozeri3897 3 ай бұрын
No more Java projects tutorials ?
@BenChoke
@BenChoke 3 ай бұрын
first comment! ur vids are cool!
@Blockify-1
@Blockify-1 3 ай бұрын
Bro "Brake youtube algoritm"like and write random comments
@nimportqoi
@nimportqoi 4 күн бұрын
hello bro code
@rafflewitz
@rafflewitz 3 ай бұрын
Import Cutie 🤯
@vaibhavkumar2366
@vaibhavkumar2366 Ай бұрын
Naming the package QtPy would've been so much better
@FlorianBini
@FlorianBini 28 күн бұрын
Weich Engine
@aDevBilly
@aDevBilly 3 ай бұрын
what a real chad
@nimportqoi
@nimportqoi 4 күн бұрын
ff
@m0rph_699
@m0rph_699 3 ай бұрын
bro pleasee do a face rev
@Thezdring1
@Thezdring1 16 күн бұрын
nah bro is such a gigachad we will probobly get blind just from seeing his face
Python Django Web Framework - Full Course for Beginners
3:45:41
freeCodeCamp.org
Рет қаралды 4,6 МЛН
👩‍💻 Python for Beginners Tutorial
1:03:21
Kevin Stratvert
Рет қаралды 3,4 МЛН
Amazing remote control#devil  #lilith #funny #shorts
00:30
Devil Lilith
Рет қаралды 16 МЛН
World’s strongest WOMAN vs regular GIRLS
00:56
A4
Рет қаралды 48 МЛН
快乐总是短暂的!😂 #搞笑夫妻 #爱美食爱生活 #搞笑达人
00:14
朱大帅and依美姐
Рет қаралды 11 МЛН
Let's code a STOPWATCH in Python! ⏱
17:58
Bro Code
Рет қаралды 8 М.
Learn Python PyQt5 in 1 hour! 🐍 (2024)
1:10:29
Bro Code
Рет қаралды 20 М.
Build a JavaScript WEATHER APP in 30+ minutes! ☀️
38:40
Bro Code
Рет қаралды 54 М.
Python 101: Learn the 5 Must-Know Concepts
20:00
Tech With Tim
Рет қаралды 1,2 МЛН
I ranked EVERY terminal emulator. It was nuts
20:35
typecraft
Рет қаралды 135 М.
10 Important Python Concepts In 20 Minutes
18:49
Indently
Рет қаралды 296 М.
3 Levels of WiFi Hacking
22:12
NetworkChuck
Рет қаралды 2,2 МЛН
Let's code a HANGMAN GAME in Python! 🕺
25:07
Bro Code
Рет қаралды 18 М.
Coding Was HARD Until I Learned These 5 Things...
8:34
Elsa Scola
Рет қаралды 679 М.
Amazing remote control#devil  #lilith #funny #shorts
00:30
Devil Lilith
Рет қаралды 16 МЛН