Ejemplo n.º 1
0
    def log_text(self, message_type, text):
        """Logs the given text to the QPlainTextWidget"""
        current_time = QTime.currentTime().toString()
        if message_type == MessageType.ERROR:
            self.log_widget.insertHtml(
                f'[{current_time}] {ERROR_HTML}{text}<br>')
        elif message_type == MessageType.GENERIC:
            self.log_widget.insertHtml(f'[{current_time}] {text}<br>')
        elif message_type == MessageType.DEBUG and ENABLE_DEBUG:
            self.log_widget.insertHtml(
                f'[{current_time}] {DEBUG_HTML}{text}<br>')

        self.log_widget.moveCursor(QTextCursor.End)
        if ENABLE_DEBUG:
            print(text)
Ejemplo n.º 2
0
    def init_settings():
        """Time conf
        """

        time_now = QTime.currentTime()
        time_start = settings_time_start()
        time_end = settings_time_end()

        if not time_start:
            SETTINGS.setValue('time_start', time_now.toString())
        if not time_end:
            SETTINGS.setValue('time_end', time_now.toString())
        if not SETTINGS.value('color'):
            SETTINGS.setValue('color', '#FFFFFF')

        SETTINGS.sync()
Ejemplo n.º 3
0
 def run(self):
     width = SETTINGS.value('screen_width')
     time_delta = settings_time_delta()
     if time_delta < 1:
         time_delta = 1
     while True:
         frequency = time_delta / 1000 / width
         if frequency < 0.0166:
             frequency = 0.0166
         delta = (settings_time_end().msecsSinceStartOfDay() -
                  QTime.currentTime().msecsSinceStartOfDay())
         process = 1 - delta / time_delta
         if process > 100 or process < 0:
             break
         pixel = int(process * width)
         self.countChanged.emit(pixel)
         sleep(frequency)
     self.countChanged.emit(width)
Ejemplo n.º 4
0
 def updateTimes(self):
     # function which is called to update labels
     self.elapsedTime.setText(time.strftime('%H:%M:%S', time.gmtime(self.counter // 2)))
     self.localTime.setText("{}{}{} {}".format(str(QTime.currentTime().hour() % 12).zfill(2) if QTime.currentTime().hour() % 12 != 0 else "12", ":" if self.counter % 2 == 0 else " ", str(QTime.currentTime().minute()).zfill(2), "PM" if QTime.currentTime().hour() >= 12 else "AM"))
     self.counter = self.counter % (2*86400) + 1
Ejemplo n.º 5
0
 def start(self):
     self.time_edit.setEnabled(False)
     self.alarm = self.time_edit.time()
     self.timer.start(QTime.currentTime().msecsTo(self.alarm))
     self.started.emit()
Ejemplo n.º 6
0
 def update_label(self):
     current = QTime.currentTime()
     self.current_label.setText('{hour:02}:{min:02}:{sec:02}'.format(
         hour=current.hour(), min=current.minute(), sec=current.second()))
Ejemplo n.º 7
0
 def set_around_time(self):
     current = QTime.currentTime()
     if current.minute() < 29:
         self.time_edit.setTime(QTime(current.hour(), 30))
     else:
         self.time_edit.setTime(QTime(current.hour() + 1, 0))