From 06664cf0858c6aa3f552446e8cc8c215c8ca9a53 Mon Sep 17 00:00:00 2001 From: Death916 Date: Mon, 18 Dec 2023 13:03:52 -0800 Subject: [PATCH] added score box and weather box starter --- deathclock/main.py | 73 +++++++++++++++++++++++------- main.qml | 110 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 167 insertions(+), 16 deletions(-) create mode 100644 main.qml diff --git a/deathclock/main.py b/deathclock/main.py index e307435..30be27f 100644 --- a/deathclock/main.py +++ b/deathclock/main.py @@ -1,36 +1,77 @@ #deathclock import datetime import time +import sys +from PySide6.QtGui import QGuiApplication +from PySide6.QtQml import QQmlApplicationEngine +from PySide6.QtCore import QTimer, QObject, Signal, Slot +from time import strftime, localtime -def main(): - class clock(): - - def time_and_date(): - print(time.asctime()) +class clock(): + def update_time(self): + curr_time = strftime("%B %d, %I:%M %p", localtime()) - def alarm(): - alarm_time = input("what time should the alarm be set?") + engine.rootObjects()[0].setProperty('currTime', curr_time) + + + return curr_time + # TODO: ADD date + + def time_and_date(): + print(time.asctime()) + + def alarm(): + alarm_time = input("what time should the alarm be set?") - def ring(): - pass + def ring(): + pass - class weather(): - def map(): +class weather(): + def map(): - return + return - def cur_weather(): + def cur_weather(): - pass - - class gui(): pass +class gui(): + def handleTouchAreaPressed(self, signal): + # Implement your desired behavior when the left area is pressed + print("here touch area") + leftTouchAreaMouse = engine.rootObjects()[0].findChild("leftTouchAreaMouse") + leftTouchAreaMouse.connect(b"touchAreaPressed", self.handleTouchAreaPressed) + print("Left area pressed!") +def main(): + gui_obj = gui() + app = QGuiApplication(sys.argv) + global engine + engine = QQmlApplicationEngine() + engine.quit.connect(app.quit) + engine.load( 'main.qml') + timeupdate = clock() + timer = QTimer() + timer.setInterval(100) # msecs 100 = 1/10th sec + timer.timeout.connect(timeupdate.update_time) + + + + timer.start() + + + + + sys.exit(app.exec_()) + + + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/main.qml b/main.qml new file mode 100644 index 0000000..32ca63b --- /dev/null +++ b/main.qml @@ -0,0 +1,110 @@ +// main.qml +import QtQuick +import QtQuick.Controls + +ApplicationWindow { + visible: true + width: 800 + height: 480 + title: "Clockz" + property string currTime: "00:00:00" + property string onTouchPressed: "Left area not pressed" + + Rectangle { + anchors.fill: parent + + Image { + anchors.fill: parent + source: "/home/death916/code/python/pyside/images/background.png" + fillMode: Image.PreserveAspectCrop + } + + // Left touch area + MouseArea { + anchors.left: parent.left + width: 70 + height: parent.height // Full height + + // Header text inside the MouseArea + Text { + anchors.top: parent.top + width: parent.width + height: 30 + text: "Scores" + font.pixelSize: 20 + color: "white" + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + } + + onClicked: { + console.log("Left area pressed!") + onTouchPressed = "Left area pressed" + } + } + + // Colored rectangle to indicate the active area + Rectangle { + anchors.left: parent.left + width: 70 + height: parent.height + color: Qt.rgba(0, 0, 1, 0.3) // Slightly opaque blue + } + + // Display the message on the screen + Text { + anchors.centerIn: parent + text: onTouchPressed + font.pixelSize: 20 + color: "white" + } + + // Weather box + Rectangle { + width: parent.width * 1 / 3 // 1/3 of the parent width + height: parent.height * 1 / 3 // 1/3 of the parent height + color: Qt.rgba(0, 0, 1, 0.5) // Semi-transparent blue + anchors.centerIn: parent + + // Text "Weather" at the top + Text { + anchors.top: parent.top + width: parent.width * 1 / 3 + height: 30 + text: "Weather" + font.pixelSize: 20 + color: "white" + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + } + + Image { + anchors.fill: parent + source: "https://weather.com/weather/radar/interactive/l/458d58193d53af8f2c66d80539989f3acde8455d72b09aaac1ba404dbd35227537bec73d6a4d1261b1978b774d987f45" + fillMode: Image.PreserveAspectCrop + } + + // Additional weather content can be added here + } + + // Clock container + Rectangle { + x: 300 + y: 1 + width: time.implicitWidth + 20 // Adjusted width based on the text size + height: time.implicitHeight + 20 // Adjusted height based on the text size + border.color: "gray" + color: "transparent" + + Text { + id: time + text: currTime + font.pixelSize: 20 + color: "black" + horizontalAlignment: Text.AlignHCenter + } + } + + // ... Additional UI elements as needed ... + } +}