forked from UmSenhorQualquer/pyforms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathControlEventsGraph.py
More file actions
115 lines (80 loc) · 3 KB
/
Copy pathControlEventsGraph.py
File metadata and controls
115 lines (80 loc) · 3 KB
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
#!/usr/bin/python
# -*- coding: utf-8 -*-
__author__ = "Ricardo Ribeiro"
__credits__ = ["Ricardo Ribeiro"]
__license__ = "MIT"
__version__ = "0.0"
__maintainer__ = "Ricardo Ribeiro"
__email__ = "ricardojvr@gmail.com"
__status__ = "Development"
from __init__ import *
import random, time
from PyQt4 import QtCore
class SimpleExample(BaseWidget):
def __init__(self):
super(SimpleExample,self).__init__('Simple example')
#Definition of the forms fields
self._control0 = ControlEventsGraph('Check me')
self._control1 = ControlEventsGraph('Check me')
self._control2 = ControlEventsGraph('Check me')
self._control3 = ControlEventsGraph('Check me')
self._txt = ControlText('Time')
self._btn = ControlButton('Click')
self._btn1 = ControlButton('Click 1')
self._formset = [
('_btn','_btn1'),
('_control0','_control1'),
('_control2','_control3'),
'_txt']
self._btn.value = self.__btn
self._btn1.value = self.__btn1
self._start = time.time()
self.INTERVAL = 500
self.N_TRACKS = 8
def __btn(self):
for i in range(40):
s = random.randint( 0, 10000 )
o = random.randint( 0, 1000 )
self._control0.add_event( s, s+o, track=random.randint(0,self.N_TRACKS) )
#self._control0.add_event( random.randint(0, 10000), s+o, track=random.randint(0,self.N_TRACKS), color="#00FFDD")
self._control0.value = 5000
def __addEvent0(self):
b = self._control0.value
e = b+self.INTERVAL
self._control0.add_event( b, e, track=random.randint(0,self.N_TRACKS) )
self._control0.value = e
self._txt.value = str(time.time() - self._start)
def __addEvent1(self):
b = self._control1.value
e = b+self.INTERVAL
self._control1.add_event( b, e, track=random.randint(0,self.N_TRACKS) )
self._control1.value = e
def __addEvent2(self):
b = self._control2.value
e = b+self.INTERVAL
self._control2.add_event( b, e, track=random.randint(0,self.N_TRACKS) )
self._control2.value = e
def __addEvent3(self):
b = self._control3.value
e = b+self.INTERVAL
self._control3.add_event( b, e, track=random.randint(0,self.N_TRACKS) )
self._control3.value = e
def __btn1(self):
self._start = time.time()
timer = QtCore.QTimer(self.form)
timer.timeout.connect(self.__addEvent0)
timer.start(self.INTERVAL)
timer = QtCore.QTimer(self.form)
timer.timeout.connect(self.__addEvent1)
timer.start(self.INTERVAL)
timer = QtCore.QTimer(self.form)
timer.timeout.connect(self.__addEvent2)
timer.start(self.INTERVAL)
timer = QtCore.QTimer(self.form)
timer.timeout.connect(self.__addEvent3)
timer.start(self.INTERVAL)
##################################################################################################################
##################################################################################################################
##################################################################################################################
#Execute the application
if __name__ == "__main__": pyforms.startApp( SimpleExample )