CanadianGamer

View.py

Aug 6th, 2023
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. from view.view import View
  2. from model.weather import Weather
  3. from model.mapbox import MapBox
  4.  
  5.  
  6. class Controller:
  7.  
  8. def __init__(self) -> None:
  9. self.view = View(self)
  10. self.weather = Weather()
  11. self.mapbox = MapBox()
  12.  
  13. self.updateGUI()
  14.  
  15.  
  16. def main(self):
  17. self.view.main()
  18.  
  19.  
  20. def updateGUI(self):
  21. if 'error' not in self.weather.weatherData:
  22. self.view.varLocation.set(self.weather.getLocation())
  23. self.view.varCondition.set(self.weather.getConditionText())
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30. def handleButtonSearch(self, event=None):
  31. location = self.view.varSearch.get()
  32. if location != '':
  33. self.weather = Weather(location)
  34. self.updateGUI()
  35.  
  36.  
  37. def handleComboSearch(self, event=None):
  38. location = self.view.varSearch.get()
  39. if len(location) > 3:
  40. self.mapbox.updateQuery(location)
  41. self.view.comboSearch.configure(values=self.mapbox.getNames())
  42. else:
  43. self.view.comboSearch.configure(values=[])
  44.  
Advertisement
Add Comment
Please, Sign In to add comment