-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGraphTable.py
More file actions
executable file
·151 lines (118 loc) · 4.62 KB
/
GraphTable.py
File metadata and controls
executable file
·151 lines (118 loc) · 4.62 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/usr/bin/python
import sys
import GraphUI
import graph
import datetime
from PySide import QtGui, QtCore
from PySide.QtCore import *
from backend import Parser,Recipe , Controller
from PySide.QtGui import *
from SimpleTable import AddButton,Table
class GraphTable(QtGui.QWidget):
def __init__(self, frame, controller):
super(GraphTable, self).__init__()
self.controller = controller
self.initUI(frame)
def initUI(self,frame):
hbox = QtGui.QHBoxLayout(self)
# set a controller for the table/graph
bottom = QtGui.QFrame(self)
bottom.setFrameShape(QtGui.QFrame.StyledPanel)
self.table = Table()
# set the table's controller
self.table.controller = self.controller
addButton = AddButton(self.table)
layout = QVBoxLayout()
layout.addWidget(self.table)
layout.addWidget(addButton)
addIcon = QtGui.QPixmap('add.png')
addButton.setIcon(addIcon)
addButton.setFixedSize(60,32)
### add the progress bar
progress = QtGui.QProgressBar()
progress.setAlignment(QtCore.Qt.AlignLeft)
progress.setVisible(False)
self.controller.progress = progress
progress.setValue(0)
layout.addWidget(progress)
bottom.setLayout(layout)
historicalLayout = QtGui.QHBoxLayout()
self.startDate = QtGui.QDateEdit()
self.startDate.setDateRange(QtCore.QDate(1990,1,1),QtCore.QDate.currentDate())
self.startDate.setCalendarPopup(True)
self.startDate.dateChanged.connect(self.set_start)
self.endDate = QtGui.QDateEdit()
self.endDate.setDateRange(QtCore.QDate(1990,1,1),QtCore.QDate.currentDate())
self.endDate.setCalendarPopup(True)
self.endDate.dateChanged.connect(self.set_end)
go = QtGui.QPushButton('Run')
go.clicked.connect(self.run_historical)
historical = QtGui.QLabel('Run Historical')
historicalLayout.addWidget(historical)
historicalLayout.addWidget(self.startDate)
historicalLayout.addWidget(self.endDate)
historicalLayout.addWidget(go)
realtimeLayout = QtGui.QHBoxLayout()
realtime = QtGui.QLabel('Run Realtime')
start = QtGui.QPushButton('Start')
start_icon = QtGui.QPixmap('play.png')
start.setIcon(start_icon)
stop_icon = QtGui.QPixmap('stop.png')
go.setIcon(start_icon)
stop = QtGui.QPushButton('Stop')
stop.setIcon(stop_icon)
start.setFixedWidth(100)
stop.setFixedWidth(100)
go.setFixedWidth(100)
start.clicked.connect(self.run_realtime)
stop.clicked.connect(self.stop_realtime)
realtimeLayout.addWidget(realtime)
realtimeLayout.addWidget(start)
realtimeLayout.addWidget(stop)
layout.addLayout(historicalLayout)
layout.addLayout(realtimeLayout)
splitter = QtGui.QSplitter(QtCore.Qt.Vertical)
splitter.addWidget(frame)
splitter.addWidget(bottom)
hbox.addWidget(splitter)
self.setLayout(hbox)
QtGui.QApplication.setStyle(QtGui.QStyleFactory.create('Cleanlooks'))
self.setGeometry(300, 300, 700, 600)
self.setWindowTitle('TradeUp')
self.show()
def reDraw(self,frame):
hbox = QtGui.QHBoxLayout(self)
bottom = QtGui.QFrame(self)
bottom.setFrameShape(QtGui.QFrame.StyledPanel)
splitter = QtGui.QSplitter(QtCore.Qt.Vertical)
splitter.addWidget(frame)
splitter.addWidget(bottom)
hbox.addWidget(splitter)
self.setLayout(hbox)
QtGui.QApplication.setStyle(QtGui.QStyleFactory.create('Cleanlooks'))
self.setGeometry(300, 300, 700, 600)
self.setWindowTitle('TradeUp')
self.show()
def set_start(self):
""" sets start"""
date = self.startDate.date()
d = int(date.day())
m = int(date.month())
y = int(date.year())
self.start = datetime.date(y,m,d)
def set_end(self):
""" sets end"""
date = self.endDate.date()
d = int(date.day())
m = int(date.month())
y = int(date.year())
self.end = datetime.date(y,m,d)
def run_historical(self):
if not self.start or self.end:
self.set_start()
self.set_end()
self.controller.run_historical(self.start, self.end)
def run_realtime(self):
self.controller.run_realtime()
def stop_realtime(self):
self.controller.stop_realtime()