Beispiel #1
0
    def update_list(self):
        que = self.w1.update()
        rows = self.cur.execute(que).fetchmany(self.count_rows_spin.value())
        self.list_order.clear()
        self.list_order_2.clear()
        for i in rows:
            dish_time_s = self.cur.execute(f'''select cooktime from dish 
                                                    where id = (select dishid from orderdish
                                                    where id = ({i[0]}))''').fetchone()[0]
            date_time_s = self.cur.execute(f'''select datetime from orderclient
                                              where id = {i[1]}''').fetchone()[0]
            dish_count = int(i[4])
            date_time = QDateTime.fromString(date_time_s, date_time_format())
            dish_time = QTime.fromString(dish_time_s, time_format())
            dish_time_minutes = dish_time.hour() * 60 + dish_time.minute() * dish_count
            dish_time = QTime(dish_time_minutes // 60, dish_time_minutes % 60)

            secs_passed = date_time.secsTo(QDateTime.currentDateTime())
            hms = [dish_time.hour() - secs_passed // 3600,
                   dish_time.minute() - secs_passed // 60 % 60,
                   59 - secs_passed % 60]
            time_last = QTime(*hms)
            if time_last.isValid():
                order = [time_last.toString(time_format() + ':ss'), *i[2:]]
            else:
                order = ['Done', *i[2:]]
            item = QListWidgetItem(' - '.join(map(str, order)))
            if not time_last.isValid():
                item.setBackground(QColor(255, 220, 220))
                self.list_order_2.addItem(item)
            else:
                self.list_order.addItem(item)
Beispiel #2
0
    def __set_uhrzeit_datum(self, uhrzeit: str, widget: QtWidgets.QTimeEdit):
        """
        Setzt die Uhrzeit in einem QTimeEdit in der GUI.
        
        Args:
            uhrzeit: Uhrzeit des Termins im Format h:m
            widget: QTimeEdit, welches gesezt wird

        Raise:
            AssertionError: Zeitangabe fehlerhaft
        """

        time = QTime.fromString(uhrzeit, 'h:m')
        assert(QTime.isValid(time))
        widget.setTime(time)
import sys
import time
from PyQt5.QtCore import QTime, Qt, QTimer
from PyQt5.QtWidgets import QLabel, QApplication
# from PyQt5.QtGui import QApplication
print(sys.argv)
app = QApplication(sys.argv)

try:
    # due = QTime.currentTime()
    message = "Alert!"
    if len(sys.argv) < 2:
        raise ValueError
    hours, mins = sys.argv[1].split(":")
    due = QTime(int(hours), int(mins))
    if not due.isValid():
        raise ValueError
    if len(sys.argv) > 2:
        messsage = " ".join(sys.argv[2:])
except ValueError:
    message = "error"

while QTime.currentTime() < due:
    time.sleep(20)

label = QLabel("<font color=red size=72><b>" + message + "</b></font>")
# anchor the label?
label.setWindowFlags(Qt.SplashScreen)  # display the label with splash method
# app has week association with widgets on the surface
label.show()
# 600000 unit is ms