mirror of
https://github.com/Death916/deathclock.git
synced 2026-04-10 03:04:40 -07:00
catching up nothing major
This commit is contained in:
parent
5f68c7353a
commit
7a88aeba0f
3 changed files with 12 additions and 5 deletions
|
|
@ -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()
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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():
|
||||
|
|
|
|||
2
main.qml
2
main.qml
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue