catching up nothing major

This commit is contained in:
Death916 2024-02-12 19:00:02 -08:00
parent 5f68c7353a
commit 7a88aeba0f
3 changed files with 12 additions and 5 deletions

View file

@ -56,12 +56,17 @@ def main():
engine.load( 'main.qml')
# create instance of weather class
weather_obj = weather.Weather()
weather_obj.download_sacramento_weather_map(engine)
weather_obj.weatherUpdated.connect(lambda weather_map_path: engine.rootContext().setContextProperty("weatherMapPath", weather_map_path))
# set timer for weather map
weatherTimer = QTimer()
weatherTimer.setInterval(600000) # 10 minutes
weatherTimer.setInterval(300000) # 10 minutes
weatherTimer.timeout.connect(weather_obj.download_sacramento_weather_map(engine))
weather_obj.download_sacramento_weather_map(engine)
weatherTimer.start()

View file

@ -8,14 +8,14 @@ from PySide6.QtQml import QQmlApplicationEngine
class Weather(QObject):
weatherUpdated = Signal(str)
def __init__(self):
super().__init__()
def download_sacramento_weather_map(self, engine):
def download_sacramento_weather_map(self,engine):
url = "https://www.google.com/search?q=weather&hl=en-GB"
service = Service(executable_path='/home/death916/code/python/deathclock/deathclock/chromedriver')
options = webdriver.ChromeOptions()
@ -27,12 +27,14 @@ class Weather(QObject):
screenshot_path = 'sacramento_weather_map.png'
map_element.screenshot(screenshot_path)
print("screen shot taken")
weather_context = engine.rootContext()
image = screenshot_path
weather_context = engine.rootContext()
weather_context.setContextProperty("weatherImage", image)
driver.quit()
self.weatherUpdated.emit(image)
return screenshot_path
def cur_weather():

View file

@ -83,7 +83,7 @@ ApplicationWindow {
Image {
anchors.fill: parent
source: weatherImage
source: weatherMapPath
//fillMode: Image.fill // Fill the entire area // Uncomment this line to fill the entire area
}