From 3ad2fa5159df82a2e80c35ae04c5174a647a38b4 Mon Sep 17 00:00:00 2001 From: "sunlit@home" Date: Fri, 3 Feb 2017 22:59:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86checkbox?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vn.trader/dataRecorder/DR_setting.json | 110 +++++++++++++++++++------ vn.trader/uiBasicWidget.py | 29 +++++-- 2 files changed, 108 insertions(+), 31 deletions(-) diff --git a/vn.trader/dataRecorder/DR_setting.json b/vn.trader/dataRecorder/DR_setting.json index f7c297c5..cbc5d6b0 100644 --- a/vn.trader/dataRecorder/DR_setting.json +++ b/vn.trader/dataRecorder/DR_setting.json @@ -1,31 +1,91 @@ { - "working": false, - - "tick": - [ - ["m1609", "XSPEED"], - ["IF1606", "SGIT"], - ["IH1606", "SGIT"], - ["IH1606", "SGIT"], - ["IC1606", "SGIT"], - ["IC1606", "SGIT"], - ["600036", "LTS", "SZSE"], - ["EUR.USD", "IB", "IDEALPRO", "USD", "外汇"] + "working": true, + "tick": [ + [ + "au1706", + "CTP" + ], + [ + "a1705", + "CTP" + ], + [ + "m1705", + "CTP" + ], + [ + "bu1706", + "CTP" + ], + [ + "SR705", + "CTP" + ], + [ + "TA705", + "CTP" + ], + [ + "MA705", + "CTP" + ], + [ + "RM705", + "CTP" + ], + [ + "FG705", + "CTP" + ], + [ + "OI705", + "CTP" + ] ], - - "bar": - [ - ["IF1605", "SGIT"], - ["IF1606", "SGIT"], - ["IH1606", "SGIT"], - ["IH1606", "SGIT"], - ["IC1606", "SGIT"], - ["IC1606", "SGIT"] + "bar": [ + [ + "au1706", + "CTP" + ], + [ + "a1705", + "CTP" + ], + [ + "m1705", + "CTP" + ], + [ + "bu1706", + "CTP" + ], + [ + "SR705", + "CTP" + ], + [ + "TA705", + "CTP" + ], + [ + "MA705", + "CTP" + ], + [ + "RM705", + "CTP" + ], + [ + "FG705", + "CTP" + ], + [ + "OI705", + "CTP" + ] ], - - "active": - { - "IF0000": "IF1605", + "active": { + "IF0000": "IF1605", "IH0000": "IH1605", "IC0000": "IC1605" } diff --git a/vn.trader/uiBasicWidget.py b/vn.trader/uiBasicWidget.py index f97431a1..9ba0ab93 100644 --- a/vn.trader/uiBasicWidget.py +++ b/vn.trader/uiBasicWidget.py @@ -6,6 +6,7 @@ import os from collections import OrderedDict from PyQt4 import QtGui, QtCore +from PyQt4.QtCore import Qt from eventEngine import * from vtFunction import * @@ -53,6 +54,22 @@ class BasicCell(QtGui.QTableWidgetItem): self.setText(text) +######################################################################## +class CheckBoxCell(QtGui.QTableWidgetItem): + """用来显示复选框的单元格""" + + def __init__(self, isChecked=False, mainEngine=None): + """Constructor""" + super(CheckBoxCell, self).__init__() + self.setFlags(QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsEnabled) + self.setStauts(isChecked) + + def setStauts(self, isChecked=False): + if not isChecked: + self.setCheckState(Qt.Unchecked) + else: + self.setCheckState(Qt.Checked) + ######################################################################## class NumCell(QtGui.QTableWidgetItem): """用来显示数字的单元格""" @@ -1084,9 +1101,9 @@ class ContractMonitor(BasicMonitor): d['productClass'] = {'chinese':u'合约类型', 'cellType':BasicCell} d['size'] = {'chinese':u'大小', 'cellType':BasicCell} d['priceTick'] = {'chinese':u'最小价格变动', 'cellType':BasicCell} - d['tick'] = {'chinese':u'tick', 'cellType':BasicCell} - d['bar'] = {'chinese':u'bar', 'cellType':BasicCell} - d['main'] = {'chinese':u'主力合约', 'cellType':BasicCell} + d['tick'] = {'chinese':u'tick', 'cellType':CheckBoxCell} + d['bar'] = {'chinese':u'bar', 'cellType':CheckBoxCell} + d['main'] = {'chinese':u'主力合约', 'cellType':CheckBoxCell} #d['strikePrice'] = {'chinese':u'期权行权价', 'cellType':BasicCell} #d['underlyingSymbol'] = {'chinese':u'期权标的物', 'cellType':BasicCell} #d['optionType'] = {'chinese':u'期权类型', 'cellType':BasicCell} @@ -1118,10 +1135,10 @@ class ContractMonitor(BasicMonitor): contract = d[key] for n, header in enumerate(self.headerList): - if(not hasattr(contract,header)): - break - content = safeUnicode(contract.__getattribute__(header)) cellType = self.headerDict[header]['cellType'] + content = None + if (hasattr(contract, header)): + content = safeUnicode(contract.__getattribute__(header)) cell = cellType(content) if self.font: