diff --git a/README.md b/README.md index 3b92203..deaacb0 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,10 @@ A simple Python script that draws a tree pattern using the turtle graphics libra A simple python script that makes you guess what word is hidden by underscores in a variable and shows the value according you input the rigth letter. ### [Raspberry Pi 5 with Câmera OV5647](/rpi5-camera/) -Código de teste da câmera OV56467 em uma Raspberry Pi 5 com Ubuntu 24 e biblioteca OpenCV. +Código de teste da câmera OV56467 em uma Raspberry Pi 5 com Raspberry Pi OS e biblioteca OpenCV. ### [Jogo da Cobra](/snake-game/) -A classic Snake game implementation using the Python curses library that runs in the terminal. \ No newline at end of file +A classic Snake game implementation using the Python curses library that runs in the terminal. + +### [Display Weather Info](/weather-cities-display/) +A simple Python GUI application that shows weather information using tkinter for the graphical interface and OpenWeatherMap API for weather data. \ No newline at end of file diff --git a/weather-cities-display/__init__.py b/weather-cities-display/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/weather-cities-display/city.ico b/weather-cities-display/city.ico new file mode 100644 index 0000000..a8b2f37 Binary files /dev/null and b/weather-cities-display/city.ico differ diff --git a/weather-cities-display/weather_cities_display.py b/weather-cities-display/weather_cities_display.py new file mode 100644 index 0000000..66faf80 --- /dev/null +++ b/weather-cities-display/weather_cities_display.py @@ -0,0 +1,53 @@ +import tkinter +from tkinter import * + +import requests + + +def weather(): + + city = city_listbox.get() + url = "https://openweathermap.org/data/2.5/weather?q={}&appid=b6907d289e10d714a6e88b30761fae22".format(city) + res = requests.get(url) + output = res.json() + + weather_status = output['weather'][0]['description'] + temperature = output['main']['temp'] + humidity = output['main']['humidity'] + wind_speed = output['wind']['speed'] + + weather_status_label.configure(text="Condição do Tempo: " + weather_status + ".") + temperature_label.configure(text="Temperatura: " + str(temperature) + "°.") + humidity_label.configure(text="Humidade: " + str(humidity) + "%.") + wind_speed_label.configure(text="Velocidade do Vento: " + str(wind_speed) + "m/s.") + + +window = Tk() +window.geometry('400x200+200+200') +window.title('Informação de Clima por Cidade') +window['bg'] = 'blue' + +city_name_list = ["Los Angeles", "delhi", "bangalore", "pune"] + +city_listbox = StringVar(window) +city_listbox.set("Selecione a Cidade") + +option = OptionMenu(window, city_listbox, *city_name_list) +option.grid(row=2, column=2, padx=150, pady=10) + +b1 = Button(window, text="Confirma", width=15, command=weather) +b1.grid(row=5, column=2, padx=150) + +weather_status_label = Label(window, font=("times", 10)) +weather_status_label.grid(row=10, column=2) + +temperature_label = Label(window, font=("times", 10, "bold")) +temperature_label.grid(row=12, column=2) + +humidity_label = Label(window, font=("times", 10, "bold")) +humidity_label.grid(row=14, column=2) + +wind_speed_label = Label(window, font=("times", 10, "bold")) +wind_speed_label.grid(row=16, column=2) + +window.mainloop()