SHARE
TWEET

Untitled

IgFil Jul 21st, 2019 189 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from tkinter import *
  2. from tkinter import scrolledtext
  3. import pyowm
  4. from yandex.Translater import Translater
  5. trans = Translater()
  6. owm = pyowm.OWM('4613a2063bd329d8886d085321fbf742')
  7.  
  8.  
  9. def clicked():
  10.     txt.delete(1.0,END)
  11.     trans.set_key('trnsl.1.1.20190719T155509Z.1bbb471edc0c0bc1.0a6d2b3a0871e6a62f32efb3d559b0457b464c37')
  12.     trans.set_from_lang('en')
  13.     trans.set_to_lang('ru')
  14.     trans.set_default_ui('ru')
  15.     observation = owm.weather_at_place(input1.get())
  16.     w = observation.get_weather()
  17.     weather_satus = w.get_detailed_status()
  18.     weather_wind_speed = w.get_wind()['speed']
  19.     weather_wind_deg = int(w.get_wind()['deg'])
  20.     if 0 <= weather_wind_deg < 90:
  21.         global weather_wind_azimut
  22.         weather_wind_azimut = "Северный"
  23.     if 90 <= weather_wind_deg < 180:
  24.         weather_wind_azimut = "Восточный"
  25.     if 180 <= weather_wind_deg < 270:
  26.          weather_wind_azimut = "Южный"
  27.     if 270 <= weather_wind_deg < 359:
  28.         weather_wind_azimut = "Западный"
  29.  
  30.  
  31.     trans.set_text(weather_satus)
  32.     weather_temp_now = w.get_temperature('celsius')['temp']
  33.     txt.insert(1.0,
  34.     "В населённом пункте:" + str(input1.get()) + ".\n Температура сейчас:" + str(weather_temp_now) + "C°"
  35.     + "\n Состояние:" + str(trans.translate())+"\n Ветер: "+ str(weather_wind_azimut) + "\n Скорость вертра: " + str(weather_wind_speed) + "м/c")
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42. #Окно
  43. root = Tk()
  44. root.title("Погода")
  45. root.geometry("900x600")
  46. #Элементы
  47. txt = scrolledtext.ScrolledText(root, width = 80 ,height=20)
  48. lbl1 = Label(root,text="Погода V1.0(BETA)")
  49. lbl2 = Label(root,text="Введите ваш город")
  50. input1 = Entry(root,width=50)
  51. btn_1 = Button(root,text="Ввод",command=clicked)
  52. #Размещенияе
  53. lbl1.place(x=450,y=1)
  54. lbl2.place(x=10,y=20)
  55. input1.place(x=130,y=22)
  56. btn_1.place(x=10,y=40)
  57. txt.place(x=10,y=80)
  58. root.mainloop()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top