forked from gataky/pyStocker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
control.py
103 lines (80 loc) · 3.25 KB
/
control.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
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
#
if __name__ == "__main__":
import pyStocker
from PySide.QtGui import *
from PySide.QtCore import *
from globals import *
from utils import (Button,
Graph,
RangeSlider,
Technicals,
Toolbar1,
Toolbar2,
QIPythonWidget,
DateRange,
StockStats)
import sys
import os
class Control(QWidget):
"""Main program that handles everything"""
def __init__(self, parent=None):
super(Control, self).__init__(parent)
self.exit = False
self.terminalVisible = False
layout1 = QHBoxLayout(self) # Top master layout
layout2 = QVBoxLayout() # widget on the left
layout3 = QVBoxLayout() # terminal on the right
self.toolbar1 = Toolbar1(self)
self.stockStats = StockStats(self)
self.graph = Graph(self)
self.dateRange = DateRange(self)
self.sliders = RangeSlider(self, Qt.Horizontal)
self.toolbar2 = Toolbar2(self)
self.scrollArea = ScrollArea(self)
#~ self.terminal = QIPythonWidget(parent=self,
#~ namespace={"Control":self},
#~ visible=self.terminalVisible)
layout2.addLayout(self.toolbar1)
layout2.addLayout(self.stockStats)
layout2.addWidget(self.graph)
layout2.addLayout(self.dateRange)
layout2.addWidget(self.sliders)
layout2.addLayout(self.toolbar2)
layout2.addWidget(self.scrollArea)
#~ layout3.addWidget(self.terminal)
layout1.addLayout(layout2)
layout1.addLayout(layout3)
self.sliders.sliderMoved.connect(self.graph.setSpan)
QShortcut(QKeySequence("Ctrl+I"), self, self.showTerminal)
def showTerminal(self):
self.toolbar1.terminal(None)
def keyPressEvent(self, event):
if event.key() == Qt.Key_Escape:
if self.exit:
sys.exit()
else:
self.exit = True
class ScrollArea(QScrollArea):
"""Where the technicals will show up, appears after ToolBar2"""
def __init__(self, parent=None):
super(ScrollArea, self).__init__(parent)
self.control = parent
self.techs = Technicals(self)
self.setWidget(self.techs)
self.setWidgetResizable(True)
def addTechnical(self, technicalName):
self.techs.addTechnical(technicalName)