-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPATC.py
129 lines (96 loc) · 4.22 KB
/
PATC.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# -*- coding: utf-8 -*-
# PYTHON_APP_TIME_COUNTER V0.1
# Herramienta para el control del tiempo que tenemos una aplicación específica activa.
# Solo necesita copiar la dirección del ejecutable de la aplicación en cuestión, y al
# cerrarla, podrá ver en pantalla, el tiempo que la ha tenido en funcionamiento.
# Por hacer:
# -Explorador de archivos para buscar visualmente el ejecutable.
# -Registrar histórico de ejecución, por aplicación utilizada a través de la herramienta.
# -Mejorar aspecto visual.
# -Optimizar código.
# -Escribir "Ayuda". (Si es que lo necesita)
# -¿Conectar registros con base de datos?.
# -Cualquier otra posible incorporación.
# Por: Juan Antonio
# https://sirvaseusted.es
from PyQt5 import QtCore, QtGui, QtWidgets
import os
import time
i = 0
f = 0
s = 0
class Ui_ContadordeTiempo(object):
def setupUi(self, ContadordeTiempo):
ContadordeTiempo.setObjectName("ContadordeTiempo")
ContadordeTiempo.setFixedSize(434, 122)
self.input = QtWidgets.QLineEdit(ContadordeTiempo)
self.input.setGeometry(QtCore.QRect(4, 80, 230, 26))
self.input.setObjectName("input")
self.input.setPlaceholderText("Ej1: vlc Ej2:/usr/bin/vlc")
self.iniciar = QtWidgets.QPushButton(ContadordeTiempo)
self.iniciar.setGeometry(QtCore.QRect(250, 80, 80, 26))
self.iniciar.setObjectName("iniciar")
self.cerrar = QtWidgets.QPushButton(ContadordeTiempo)
self.cerrar.setGeometry(QtCore.QRect(350, 80, 80, 26))
self.cerrar.setObjectName("cerrar")
self.etiqueta = QtWidgets.QLabel(ContadordeTiempo)
self.etiqueta.setGeometry(QtCore.QRect(10, 60, 250, 18))
self.etiqueta.setObjectName("etiqueta")
self.label1 = QtWidgets.QLabel(ContadordeTiempo)
self.label1.setGeometry(QtCore.QRect(50, 10, 58, 18))
self.label1.setObjectName("label1")
self.label0 = QtWidgets.QLabel(ContadordeTiempo)
self.label0.setGeometry(QtCore.QRect(50, 30, 58, 18))
self.label0.setObjectName("label0")
self.label2 = QtWidgets.QLabel(ContadordeTiempo)
self.label2.setGeometry(QtCore.QRect(240, 10, 200, 18))
self.label2.setObjectName("label2")
self.cuenta = QtWidgets.QLabel(ContadordeTiempo)
self.cuenta.setGeometry(QtCore.QRect(310, 40, 200, 18))
font = QtGui.QFont()
font.setPointSize(16)
self.cuenta.setFont(font)
self.cuenta.setTextFormat(QtCore.Qt.AutoText)
self.cuenta.setObjectName("cuenta")
self.tinicial = QtWidgets.QLabel(ContadordeTiempo)
self.tinicial.setGeometry(QtCore.QRect(110, 10, 150, 18))
self.tinicial.setObjectName("tinicial")
self.tfinal = QtWidgets.QLabel(ContadordeTiempo)
self.tfinal.setGeometry(QtCore.QRect(110, 30, 120, 18))
self.tfinal.setObjectName("tfinal")
self.retranslateUi(ContadordeTiempo)
self.cerrar.clicked.connect(ContadordeTiempo.reject)
self.iniciar.clicked.connect(self.Iniciar)
QtCore.QMetaObject.connectSlotsByName(ContadordeTiempo)
def retranslateUi(self, ContadordeTiempo):
_translate = QtCore.QCoreApplication.translate
ContadordeTiempo.setWindowTitle(_translate("ContadordeTiempo", "Contador de Tiempo"))
self.iniciar.setText(_translate("ContadordeTiempo", "Iniciar"))
self.cerrar.setText(_translate("ContadordeTiempo", "Cerrar"))
self.etiqueta.setText(_translate("ContadordeTiempo", "Inserte dirección del ejecutable:"))
self.label1.setText(_translate("ContadordeTiempo", "Inicio:"))
self.label0.setText(_translate("ContadordeTiempo", "Fin:"))
self.label2.setText(_translate("ContadordeTiempo", "Tiempo de Trabajo (Minutos):"))
self.cuenta.setText(_translate("ContadordeTiempo", "00:00"))
self.tinicial.setText(_translate("ContadordeTiempo", "00:00"))
self.tfinal.setText(_translate("ContadordeTiempo", "00:00"))
def Iniciar(self):
global i
i = round(time.time(), 2)
iok = time.strftime("%d-%m-%y %H:%M:%S", time.localtime(i))
self.tinicial.setText(str(iok))
p = self.input.text()
x = os.system("'"+ p +"'")
f = round(time.time(), 2)
fok = time.strftime("%d-%m-%y %H:%M:%S", time.localtime(f))
self.tfinal.setText(str(fok))
s = round((float(f) - float(i))/60, 2)
self.cuenta.setText(str(s))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
ContadordeTiempo = QtWidgets.QDialog()
ui = Ui_ContadordeTiempo()
ui.setupUi(ContadordeTiempo)
ContadordeTiempo.show()
sys.exit(app.exec_())