Пример #1
0
    def setupUi(self, MainWindow):
        MainWindow.setObjectName(_fromUtf8("MainWindow"))
        MainWindow.resize(452, 384)
        self.centralwidget = QtGui.QWidget(MainWindow)
        self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
        self.tabWidget = QtGui.QTabWidget(self.centralwidget)
        self.tabWidget.setGeometry(QtCore.QRect(20, 0, 321, 241))
        self.tabWidget.setObjectName(_fromUtf8("tabWidget"))
        self.tab = QtGui.QWidget()
        self.tab.setObjectName(_fromUtf8("tab"))
        self.verticalLayoutWidget = QtGui.QWidget(self.tab)
        self.verticalLayoutWidget.setGeometry(QtCore.QRect(10, 0, 241, 151))
        self.verticalLayoutWidget.setObjectName(_fromUtf8("verticalLayoutWidget"))
        self.verticalLayout = QtGui.QVBoxLayout(self.verticalLayoutWidget)
        self.verticalLayout.setMargin(0)
        self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
        self.listView = QtGui.QListView(self.verticalLayoutWidget)
        self.listView.setObjectName(_fromUtf8("listView"))
        self.verticalLayout.addWidget(self.listView)
        self.tabWidget.addTab(self.tab, _fromUtf8(""))
        self.tab_2 = QtGui.QWidget()
        self.tab_2.setObjectName(_fromUtf8("tab_2"))
        self.calendarWidget = QtGui.QCalendarWidget(self.tab_2)
        self.calendarWidget.setGeometry(QtCore.QRect(0, 10, 304, 145))
        self.calendarWidget.setObjectName(_fromUtf8("calendarWidget"))
        self.tabWidget.addTab(self.tab_2, _fromUtf8(""))
        self.analogClock = AnalogClock(self.centralwidget)
        self.analogClock.setGeometry(QtCore.QRect(170, 240, 100, 100))
        self.analogClock.setObjectName(_fromUtf8("analogClock"))
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtGui.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 452, 22))
        self.menubar.setObjectName(_fromUtf8("menubar"))
        self.menuFoo = QtGui.QMenu(self.menubar)
        self.menuFoo.setObjectName(_fromUtf8("menuFoo"))
        self.menuAbout = QtGui.QMenu(self.menubar)
        self.menuAbout.setObjectName(_fromUtf8("menuAbout"))
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtGui.QStatusBar(MainWindow)
        self.statusbar.setObjectName(_fromUtf8("statusbar"))
        MainWindow.setStatusBar(self.statusbar)
        self.action_Save = QtGui.QAction(MainWindow)
        self.action_Save.setObjectName(_fromUtf8("action_Save"))
        self.action_Quit = QtGui.QAction(MainWindow)
        self.action_Quit.setObjectName(_fromUtf8("action_Quit"))
        self.action_About = QtGui.QAction(MainWindow)
        self.action_About.setObjectName(_fromUtf8("action_About"))
        self.menuFoo.addAction(self.action_Save)
        self.menuFoo.addAction(self.action_Quit)
        self.menuAbout.addAction(self.action_About)
        self.menubar.addAction(self.menuFoo.menuAction())
        self.menubar.addAction(self.menuAbout.menuAction())

        self.retranslateUi(MainWindow)
        self.tabWidget.setCurrentIndex(0)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)
Пример #2
0
    def __init__(self, applet):
        self.__applet = applet

        self.__city_boxes = {}
        self.cache_surface = {}

        # Initialize the base clock so that the clocks can be drawn immediately when exposed
        self.__previous_state = (None, None, applet.applet.settings["theme"])
        self.base_clock = AnalogClock(
            AnalogClockThemeProvider(self.__previous_state[2]), clock_size)

        self.__cities_vbox = gtk.VBox(spacing=6)

        if "cities-timezones" not in applet.applet.settings:
            applet.applet.settings["cities-timezones"] = list()
        self.__cities_timezones = applet.applet.settings["cities-timezones"]

        applet.applet.timing.register(self.draw_clock_cb, draw_clock_interval)
Пример #3
0
    def draw_clock_cb(self):
        local_time = time.localtime()

        new_state = (local_time[3], local_time[4],
                     self.__applet.applet.settings["theme"],
                     self.__applet.applet.settings["time-24-format"])
        if self.__previous_state == new_state:
            return

        if self.__previous_state[2] != new_state[2]:
            self.base_clock = AnalogClock(
                AnalogClockThemeProvider(new_state[2]), clock_size)

        self.__previous_state = new_state

        # Clear cache because theme might have changed and to avoid memory leaks
        self.cache_surface.clear()

        # Update all clock images and timezone labels
        local_datetime = datetime.now(tz.tzlocal())

        for box in self.__city_boxes.itervalues():
            box.update_clock_image()
            box.update_timezone_label(local_datetime)
Пример #4
0
class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName(_fromUtf8("MainWindow"))
        MainWindow.resize(452, 384)
        self.centralwidget = QtGui.QWidget(MainWindow)
        self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
        self.tabWidget = QtGui.QTabWidget(self.centralwidget)
        self.tabWidget.setGeometry(QtCore.QRect(20, 0, 321, 241))
        self.tabWidget.setObjectName(_fromUtf8("tabWidget"))
        self.tab = QtGui.QWidget()
        self.tab.setObjectName(_fromUtf8("tab"))
        self.verticalLayoutWidget = QtGui.QWidget(self.tab)
        self.verticalLayoutWidget.setGeometry(QtCore.QRect(10, 0, 241, 151))
        self.verticalLayoutWidget.setObjectName(_fromUtf8("verticalLayoutWidget"))
        self.verticalLayout = QtGui.QVBoxLayout(self.verticalLayoutWidget)
        self.verticalLayout.setMargin(0)
        self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
        self.listView = QtGui.QListView(self.verticalLayoutWidget)
        self.listView.setObjectName(_fromUtf8("listView"))
        self.verticalLayout.addWidget(self.listView)
        self.tabWidget.addTab(self.tab, _fromUtf8(""))
        self.tab_2 = QtGui.QWidget()
        self.tab_2.setObjectName(_fromUtf8("tab_2"))
        self.calendarWidget = QtGui.QCalendarWidget(self.tab_2)
        self.calendarWidget.setGeometry(QtCore.QRect(0, 10, 304, 145))
        self.calendarWidget.setObjectName(_fromUtf8("calendarWidget"))
        self.tabWidget.addTab(self.tab_2, _fromUtf8(""))
        self.analogClock = AnalogClock(self.centralwidget)
        self.analogClock.setGeometry(QtCore.QRect(170, 240, 100, 100))
        self.analogClock.setObjectName(_fromUtf8("analogClock"))
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtGui.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 452, 22))
        self.menubar.setObjectName(_fromUtf8("menubar"))
        self.menuFoo = QtGui.QMenu(self.menubar)
        self.menuFoo.setObjectName(_fromUtf8("menuFoo"))
        self.menuAbout = QtGui.QMenu(self.menubar)
        self.menuAbout.setObjectName(_fromUtf8("menuAbout"))
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtGui.QStatusBar(MainWindow)
        self.statusbar.setObjectName(_fromUtf8("statusbar"))
        MainWindow.setStatusBar(self.statusbar)
        self.action_Save = QtGui.QAction(MainWindow)
        self.action_Save.setObjectName(_fromUtf8("action_Save"))
        self.action_Quit = QtGui.QAction(MainWindow)
        self.action_Quit.setObjectName(_fromUtf8("action_Quit"))
        self.action_About = QtGui.QAction(MainWindow)
        self.action_About.setObjectName(_fromUtf8("action_About"))
        self.menuFoo.addAction(self.action_Save)
        self.menuFoo.addAction(self.action_Quit)
        self.menuAbout.addAction(self.action_About)
        self.menubar.addAction(self.menuFoo.menuAction())
        self.menubar.addAction(self.menuAbout.menuAction())

        self.retranslateUi(MainWindow)
        self.tabWidget.setCurrentIndex(0)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):
        MainWindow.setWindowTitle(
            QtGui.QApplication.translate("MainWindow", "MainWindow", None, QtGui.QApplication.UnicodeUTF8)
        )
        self.tabWidget.setToolTip(
            QtGui.QApplication.translate("MainWindow", "click me", None, QtGui.QApplication.UnicodeUTF8)
        )
        self.tabWidget.setTabText(
            self.tabWidget.indexOf(self.tab),
            QtGui.QApplication.translate("MainWindow", "List", None, QtGui.QApplication.UnicodeUTF8),
        )
        self.tabWidget.setTabText(
            self.tabWidget.indexOf(self.tab_2),
            QtGui.QApplication.translate("MainWindow", "Calendar", None, QtGui.QApplication.UnicodeUTF8),
        )
        self.analogClock.setToolTip(
            QtGui.QApplication.translate("MainWindow", "The current time", None, QtGui.QApplication.UnicodeUTF8)
        )
        self.analogClock.setWhatsThis(
            QtGui.QApplication.translate(
                "MainWindow", "The analog clock widget displays the current time.", None, QtGui.QApplication.UnicodeUTF8
            )
        )
        self.menuFoo.setTitle(QtGui.QApplication.translate("MainWindow", "Foo", None, QtGui.QApplication.UnicodeUTF8))
        self.menuAbout.setTitle(
            QtGui.QApplication.translate("MainWindow", "About", None, QtGui.QApplication.UnicodeUTF8)
        )
        self.action_Save.setText(
            QtGui.QApplication.translate("MainWindow", "&Save", None, QtGui.QApplication.UnicodeUTF8)
        )
        self.action_Quit.setText(
            QtGui.QApplication.translate("MainWindow", "&Quit", None, QtGui.QApplication.UnicodeUTF8)
        )
        self.action_About.setText(
            QtGui.QApplication.translate("MainWindow", "&About", None, QtGui.QApplication.UnicodeUTF8)
        )
Пример #5
0
    def __init__(self, parent=None):
        super(Window, self).__init__(parent)
        global stopwatchInProgress, timerInProgress
        stopwatchInProgress = False
        timerInProgress = False
        
        self.tabWidget = QtWidgets.QTabWidget()
        self.setCentralWidget(self.tabWidget)

        self.stopwatchCount = QtWidgets.QLabel('00:00.0000')
        self.stopwatchCount.setAlignment(Qt.AlignHCenter)
        self.stopwatchButton = QtWidgets.QPushButton('Start')
        self.stopwatchButton_Stop = QtWidgets.QPushButton('Clear')
        
        self.stopwatchButton_Lap = QtWidgets.QPushButton('Add Lap')
        self.stopwatchButton_Lap.setEnabled(False)
        self.stopwatchButton_Lap.clicked.connect(self.addLap)
        self.lapCount = QtWidgets.QTreeWidget()
        self.lapCount.setHeaderLabels(['#', 'Time'])
        self.lapCount.header().setStretchLastSection(True)
        
        self.stopwatchButton_Stop.clicked.connect(self.clearStopwatch)
        
        self.stopwatchLayout = QtWidgets.QVBoxLayout()
        self.stopwatchLayout.addWidget(self.stopwatchCount)
        self.stopwatchLayout.addWidget(self.stopwatchButton)
        self.stopwatchLayout.addWidget(self.stopwatchButton_Stop)
            
        self.stopwatchLayout.addWidget(self.stopwatchButton_Lap)
        self.stopwatchLayout.addWidget(self.lapCount)
        
        self.stopwatchLW = QtWidgets.QWidget()
        self.stopwatchLW.setLayout(self.stopwatchLayout)
        self.tabWidget.addTab(self.stopwatchLW, 'Stopwatch')
        
        
        
        #### timer
        self.timerCount = QtWidgets.QLabel('00:00.0000')
        
        self.minuteSpin = QtWidgets.QSpinBox()
        self.minuteSpinLabel = QtWidgets.QLabel(' minutes')
        
        self.secondSpin = QtWidgets.QSpinBox()
        self.secondSpinLabel = QtWidgets.QLabel(' seconds')
        
        
        self.spinnerLayout = QtWidgets.QGridLayout()
        self.spinnerLayout.addWidget(self.minuteSpin, 0,0)
        self.spinnerLayout.addWidget(self.minuteSpinLabel, 0,1)
        self.spinnerLayout.addWidget(self.secondSpin, 1,0)
        self.spinnerLayout.addWidget(self.secondSpinLabel, 1,1)
        
        self.spinnerLW = QtWidgets.QWidget()
        self.spinnerLW.setLayout(self.spinnerLayout)
        
        self.timerBar = QtWidgets.QProgressBar()
        self.timerCount.setAlignment(Qt.AlignHCenter)
        self.timerButton = QtWidgets.QPushButton('Start')
        self.timerButton.clicked.connect(self.startTimer)
        
        self.timerLayout = QtWidgets.QVBoxLayout()
        self.timerLayout.addWidget(self.timerCount)
        self.timerLayout.addWidget(self.spinnerLW)
        self.timerLayout.addWidget(self.timerBar)
        self.timerLayout.addWidget(self.timerButton)
        
        self.timerW = QtWidgets.QWidget()
        self.timerW.setLayout(self.timerLayout)
        self.tabWidget.addTab(self.timerW, 'Timer')
        
        
        #### clock
        self.clockWidget = AnalogClock()
        self.timeLabel = QtWidgets.QLabel('Getting the time...')
        self.timeLabel.setAlignment(Qt.AlignHCenter)
        #self.clockWidget.setAlignment(Qt.AlignTop)
        
        
        self.clockLayout = QtWidgets.QVBoxLayout()
        self.clockLayout.addWidget(self.clockWidget)
        self.clockLayout.addWidget(self.timeLabel)
        self.clockLayout.setAlignment(self.clockWidget, Qt.AlignTop)
        self.clockLW = QtWidgets.QWidget()
        self.clockLW.setLayout(self.clockLayout)
        
        self.tabWidget.addTab(self.clockLW, 'Clock')
        #self.clockWidget.setMaximumWidth(200)
        
        
        self.stopwatchButton.clicked.connect(self.startStopwatch)
        
        
        self.stopwatchCount.setStyleSheet('QLabel {font-weight: 100; font-size: 40px;}')
        self.timerCount.setStyleSheet('QLabel {font-weight: 100; font-size: 40px;}')
        self.timeLabel.setStyleSheet('QLabel {font-weight: 100; font-size: 35px;}')

        self.millisecondTimer = QtCore.QTimer()
        self.millisecondTimer.setSingleShot(False)
        self.millisecondTimer.setTimerType(Qt.PreciseTimer)
        self.millisecondTimer.timeout.connect(self.updateMilliseconds)
    
    
        self.millisecondTimer_T = QtCore.QTimer()
        self.millisecondTimer_T.setSingleShot(False)
        self.millisecondTimer_T.setTimerType(Qt.PreciseTimer)
        self.millisecondTimer_T.timeout.connect(self.updateMilliseconds_T)
    
    
        self.clockTimer = QtCore.QTimer()
        self.clockTimer.setSingleShot(False)
        self.clockTimer.setTimerType(Qt.PreciseTimer)
        self.clockTimer.timeout.connect(self.updateClocks)
        self.clockTimer.start(1)
Пример #6
0
class Window(QtWidgets.QMainWindow):
    """Main Window"""
    
    def __init__(self, parent=None):
        super(Window, self).__init__(parent)
        global stopwatchInProgress, timerInProgress
        stopwatchInProgress = False
        timerInProgress = False
        
        self.tabWidget = QtWidgets.QTabWidget()
        self.setCentralWidget(self.tabWidget)

        self.stopwatchCount = QtWidgets.QLabel('00:00.0000')
        self.stopwatchCount.setAlignment(Qt.AlignHCenter)
        self.stopwatchButton = QtWidgets.QPushButton('Start')
        self.stopwatchButton_Stop = QtWidgets.QPushButton('Clear')
        
        self.stopwatchButton_Lap = QtWidgets.QPushButton('Add Lap')
        self.stopwatchButton_Lap.setEnabled(False)
        self.stopwatchButton_Lap.clicked.connect(self.addLap)
        self.lapCount = QtWidgets.QTreeWidget()
        self.lapCount.setHeaderLabels(['#', 'Time'])
        self.lapCount.header().setStretchLastSection(True)
        
        self.stopwatchButton_Stop.clicked.connect(self.clearStopwatch)
        
        self.stopwatchLayout = QtWidgets.QVBoxLayout()
        self.stopwatchLayout.addWidget(self.stopwatchCount)
        self.stopwatchLayout.addWidget(self.stopwatchButton)
        self.stopwatchLayout.addWidget(self.stopwatchButton_Stop)
            
        self.stopwatchLayout.addWidget(self.stopwatchButton_Lap)
        self.stopwatchLayout.addWidget(self.lapCount)
        
        self.stopwatchLW = QtWidgets.QWidget()
        self.stopwatchLW.setLayout(self.stopwatchLayout)
        self.tabWidget.addTab(self.stopwatchLW, 'Stopwatch')
        
        
        
        #### timer
        self.timerCount = QtWidgets.QLabel('00:00.0000')
        
        self.minuteSpin = QtWidgets.QSpinBox()
        self.minuteSpinLabel = QtWidgets.QLabel(' minutes')
        
        self.secondSpin = QtWidgets.QSpinBox()
        self.secondSpinLabel = QtWidgets.QLabel(' seconds')
        
        
        self.spinnerLayout = QtWidgets.QGridLayout()
        self.spinnerLayout.addWidget(self.minuteSpin, 0,0)
        self.spinnerLayout.addWidget(self.minuteSpinLabel, 0,1)
        self.spinnerLayout.addWidget(self.secondSpin, 1,0)
        self.spinnerLayout.addWidget(self.secondSpinLabel, 1,1)
        
        self.spinnerLW = QtWidgets.QWidget()
        self.spinnerLW.setLayout(self.spinnerLayout)
        
        self.timerBar = QtWidgets.QProgressBar()
        self.timerCount.setAlignment(Qt.AlignHCenter)
        self.timerButton = QtWidgets.QPushButton('Start')
        self.timerButton.clicked.connect(self.startTimer)
        
        self.timerLayout = QtWidgets.QVBoxLayout()
        self.timerLayout.addWidget(self.timerCount)
        self.timerLayout.addWidget(self.spinnerLW)
        self.timerLayout.addWidget(self.timerBar)
        self.timerLayout.addWidget(self.timerButton)
        
        self.timerW = QtWidgets.QWidget()
        self.timerW.setLayout(self.timerLayout)
        self.tabWidget.addTab(self.timerW, 'Timer')
        
        
        #### clock
        self.clockWidget = AnalogClock()
        self.timeLabel = QtWidgets.QLabel('Getting the time...')
        self.timeLabel.setAlignment(Qt.AlignHCenter)
        #self.clockWidget.setAlignment(Qt.AlignTop)
        
        
        self.clockLayout = QtWidgets.QVBoxLayout()
        self.clockLayout.addWidget(self.clockWidget)
        self.clockLayout.addWidget(self.timeLabel)
        self.clockLayout.setAlignment(self.clockWidget, Qt.AlignTop)
        self.clockLW = QtWidgets.QWidget()
        self.clockLW.setLayout(self.clockLayout)
        
        self.tabWidget.addTab(self.clockLW, 'Clock')
        #self.clockWidget.setMaximumWidth(200)
        
        
        self.stopwatchButton.clicked.connect(self.startStopwatch)
        
        
        self.stopwatchCount.setStyleSheet('QLabel {font-weight: 100; font-size: 40px;}')
        self.timerCount.setStyleSheet('QLabel {font-weight: 100; font-size: 40px;}')
        self.timeLabel.setStyleSheet('QLabel {font-weight: 100; font-size: 35px;}')

        self.millisecondTimer = QtCore.QTimer()
        self.millisecondTimer.setSingleShot(False)
        self.millisecondTimer.setTimerType(Qt.PreciseTimer)
        self.millisecondTimer.timeout.connect(self.updateMilliseconds)
    
    
        self.millisecondTimer_T = QtCore.QTimer()
        self.millisecondTimer_T.setSingleShot(False)
        self.millisecondTimer_T.setTimerType(Qt.PreciseTimer)
        self.millisecondTimer_T.timeout.connect(self.updateMilliseconds_T)
    
    
        self.clockTimer = QtCore.QTimer()
        self.clockTimer.setSingleShot(False)
        self.clockTimer.setTimerType(Qt.PreciseTimer)
        self.clockTimer.timeout.connect(self.updateClocks)
        self.clockTimer.start(1)

    def updateClocks(self):
        hour = QtCore.QTime.currentTime().hour()
        if hour > 12:
            hour = hour - 12
            tod = 'PM'
        else:
            tod = 'AM'
        minute = QtCore.QTime.currentTime().minute()
        self.timeLabel.setText(str(hour) + ':' + str(minute) + ' ' + tod)
        self.clockWidget.update()


    def startTimer(self):
        global timerInProgress, minutesLeft, secondsLeft, millisecondsLeft, millisecondCounter
        if not timerInProgress:
            minutesLeft = self.minuteSpin.value()
            minutesLeft_MS = self.minutesToMilliseconds(minutesLeft)
            
            secondsLeft = self.secondSpin.value()
            secondsLeft_MS = self.secondsToMilliseconds(secondsLeft)
            
            self.secondSpin.hide()
            self.secondSpinLabel.hide()
            self.minuteSpin.hide()
            self.minuteSpinLabel.hide()
            
            totalMS = minutesLeft_MS + secondsLeft_MS
            self.timerBar.setRange(0, totalMS)
            self.millisecondTimer_T.start(1)
            timerInProgress = True
            self.timerButton.setText('Stop')
        else:
            self.millisecondTimer_T.stop()
            self.timerBar.setValue(0)
            minutesLeft, secondsLeft, millisecondsLeft, millisecondCounter = 0,0,0,0
            timerInProgress = False
            self.timerCount.setText('00:00.0000')
            
            self.secondSpin.show()
            self.secondSpinLabel.show()
            self.minuteSpin.show()
            self.minuteSpinLabel.show()
            
            self.timerButton.setText('Start')
    
    
    def startStopwatch(self):
        global stopwatchInProgress
        if not stopwatchInProgress:
            self.millisecondTimer.start(1)
            stopwatchInProgress = True
            self.stopwatchButton.setText('Pause')
            self.stopwatchButton_Stop.setEnabled(False)
            self.stopwatchButton_Lap.setEnabled(True)
            self.stopwatchButton_Lap.setText('Add Lap')
        else:
            self.millisecondTimer.stop()
            stopwatchInProgress = False
            self.stopwatchButton.setText('Resume')
            self.stopwatchButton_Lap.setEnabled(True)
            self.stopwatchButton_Stop.setEnabled(True)
            self.stopwatchButton_Lap.setText('Clear Laps')

    def clearStopwatch(self):
        global minutes, seconds, milliseconds
        self.millisecondTimer.stop()
        self.stopwatchCount.setText('00:00.0000')
        minutes, seconds, milliseconds = 0,0,0
        stopwatchInProgress = False
        self.stopwatchButton.setText('Start')
    
    def addLap(self):
        global numberoflaps
        if stopwatchInProgress:
            numberoflaps += 1
            newLapItem = QtWidgets.QTreeWidgetItem()
            newLapItem.setText(0, str(numberoflaps))
            newLapItem.setText(1, self.stopwatchCount.text())
            self.lapCount.addTopLevelItem(newLapItem)
        elif not stopwatchInProgress:
            self.lapCount.clear()
            numberoflaps = 0
        
    def updateMilliseconds(self):
        global minutes, seconds, milliseconds
        milliseconds = int(milliseconds) + 1
        if int(milliseconds) > 1000:
            milliseconds = 00
            seconds = int(seconds) + 1
            if int(seconds) == 60:
                seconds = 0
                minutes = int(minutes) + 1

        if int(minutes) < 10: minutes = '0' + str(int(minutes))
        if int(seconds) < 10: seconds = '0' + str(int(seconds))
        if int(milliseconds) < 10: milliseconds = '000' + str(int(milliseconds))
        elif int(milliseconds) < 100 and int(milliseconds) > 10: milliseconds = '00' + str(int(milliseconds))
        elif int(milliseconds) < 1000 and int(milliseconds) > 100: milliseconds = '0' + str(int(milliseconds))

        self.stopwatchCount.setText(str(minutes) + ':' + str(seconds) + '.' + str(milliseconds))


    def updateMilliseconds_T(self):
        global minutesLeft, secondsLeft, millisecondsLeft, millisecondCounter
        millisecondCounter += 1

        self.timerBar.setValue(millisecondCounter)
        #print(str(minutesLeft) + ' minutes left\n' + str(secondsLeft) + ' seconds left\n' + str(millisecondsLeft) + ' milliseconds left\n\n')
        millisecondsLeft = int(millisecondsLeft) - 1
        if int(millisecondsLeft) < 0:
            millisecondsLeft = 999
            secondsLeft = int(secondsLeft) - 1
            if int(secondsLeft) < 0:
                secondsLeft = 59
                minutesLeft = int(minutesLeft) - 1
                if int(minutesLeft) < 0:
                    minutesLeft = 0

        if int(minutesLeft) < 10: minutesLeft = '0' + str(int(minutesLeft))
        if int(secondsLeft) < 10: secondsLeft = '0' + str(int(secondsLeft))
        if int(millisecondsLeft) < 10: millisecondsLeft = '000' + str(int(millisecondsLeft))
        elif int(millisecondsLeft) < 100 and int(millisecondsLeft) > 10: millisecondsLeft = '00' + str(int(millisecondsLeft))
        elif int(millisecondsLeft) < 1000 and int(millisecondsLeft) > 100: millisecondsLeft = '0' + str(int(millisecondsLeft))

        self.timerCount.setText(str(minutesLeft) + ':' + str(secondsLeft) + '.' + str(millisecondsLeft))

        if self.timerCount.text() == '00:00.0000': self.alarmForFinishedTimer()

    def alarmForFinishedTimer(self):
        global minutesLeft, secondsLeft, millisecondsLeft, millisecondCounter
        self.millisecondTimer_T.stop()
    
        self.timerMSG = QtWidgets.QMessageBox()
        self.timerMSG.setText('The timer has completed.')
        QtMultimedia.QSound.play('submarine.wav')
        minutesLeft, secondsLeft, millisecondsLeft, millisecondCounter = 0,0,0,0
        self.timerBar.setValue(0)
        self.timerMSG.exec_()


    def minutesToMilliseconds(self, minutes):
        return minutes * 60000

    def secondsToMilliseconds(self, seconds):
        return seconds * 1000