Exemple #1
0
def lap_helper():
    global current_time
    global last_lap
    global lapTime
    global laps
    global current_lap_num
    time_lap_button_clicked = current_time
    delta_time = time_lap_button_clicked - last_lap
    # check to make sure that the timer is actually running
    if delta_time > 0:
        # add to the lap data
        lapTime = (current_time - last_lap) / 1000000000
        laps.append(lapTime)

        last_lap = current_time
        # plot the new  stats
        updatePlot(axes, laps)
        avg_lap_label.setText(
            str(time_format(seconds=truncate(mean(laps), 2)))[:-4])
        slowest_lap_label.setText(
            str(time_format(seconds=truncate(max(laps), 2)))[:-4])
        fastest_lap_label.setText(
            str(time_format(seconds=truncate(min(laps), 2)))[:-4])
        # add lap time to lap time table
        laptime_table.insertRow(1)
        laptime_table.setItem(
            0, 1,
            QTableWidgetItem(
                str(time_format(seconds=truncate(lapTime, 2)))[:-4]))
        # Always scroll to the newest data point in the table
        laptime_table.scrollToItem(laptime_table.item(0, 0))
        #label the row properly
        lap_num_label = str("Lap " + str(current_lap_num))
        current_lap_num += 1
        laptime_table.setVerticalHeaderItem(1, QTableWidgetItem(lap_num_label))
Exemple #2
0
def reset_helper():
    global current_time
    global laps
    global last_lap
    global current_lap_num
    current_time = 0
    last_lap = 0
    current_lap_num = 1
    # get rid of the reset and resume buttons
    reset_button.setParent(None)
    resume_button.setParent(None)
    # add the lap and resume buttons
    timer_button_hbox.addWidget(lap_button)
    timer_button_hbox.addWidget(resume_button)
    # update the timer count
    timer_label.setText(str(time_format(milliseconds=0)))

    # reset the lap data
    laps = []
    # update the chart
    updatePlot(axes, laps)
    avg_lap_label.setText("0:00:00.00")
    slowest_lap_label.setText("0:00:00.00")
    fastest_lap_label.setText("0:00:00.00")

    #reset table
    laptime_table.setRowCount(0)
    laptime_table.insertRow(0)
    laptime_table.setItem(0, 1, QTableWidgetItem("0:00:00.00"))
    laptime_table.setVerticalHeaderItem(0, QTableWidgetItem("Current lap"))
Exemple #3
0
def counter():
    global current_time
    while (True):
        timer_lock.acquire()
        timer_lock.release()
        start_time = time_ns()
        sleep(.05)
        current_time += time_ns() - start_time
        current_lap_time = current_time - last_lap
        # modify the label of the timer
        timer_label.setText(
            str(time_format(seconds=truncate(current_time /
                                             1000000000, 2)))[:-4])
        # modify the current lap timer
        laptime_table.setItem(
            0, 0,
            QTableWidgetItem(
                str(
                    time_format(seconds=truncate(current_lap_time /
                                                 1000000000, 2)))[:-4]))
Exemple #4
0
    def __search(self, bot, update, args):
        """
		Send search result to command issuer
		"""
        try:
            # read the search file
            data = self.__getSerchbyKey(args[0].lower())
            # print(data)
            res = "Search Result : \n"
            for index, row in data.iterrows():
                form_h, form_m = row["timeForm"].split(":")
                to_h, to_m = row["timeTo"].split(":")
                if self.__in_between(datetime.now().time(),
                                     time_format(int(form_h), int(form_m)),
                                     time_format(int(to_h), int(to_m))):
                    res = res + '\n' + row["message"]
            update.message.reply_text(res)
        except Exception as e:
            try:
                update.message.reply_text('Please enter the text.')
            except Exception as ex:
                print(ex)
Exemple #5
0
from datetime import timedelta as time_format
from statistics import mean

plt.ion()
app = QApplication([])
app.setApplicationName("Sports Timer")
window = QWidget()
current_time = 0
last_lap = 0
lapTime = 0

main_vbox = QVBoxLayout()

main_vbox.addStretch(1)

timer_label = QLabel(str(time_format(milliseconds=0)))
# Center the timer
timer_label.setAlignment(QtCore.Qt.AlignCenter)
# set the font to be large and bold for the real timer
big_font = QtGui.QFont("Times", 38, QtGui.QFont.Bold)
timer_label.setFont(big_font)

# add the timers to the gui
main_vbox.addWidget(timer_label)

main_vbox.addStretch(.25)

# define the area where the buttons are
timer_button_hbox = QHBoxLayout()
# create the button objects
start_button = QPushButton('Start')