From 857b0c243cd025cdc2d30ed709c853ca1e5a8857 Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Fri, 11 Jan 2019 15:49:11 +0800 Subject: [PATCH] [Add] Double click order monitor cells to cancel order --- vnpy/trader/ui/widget.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/vnpy/trader/ui/widget.py b/vnpy/trader/ui/widget.py index 91327d72..1757619a 100644 --- a/vnpy/trader/ui/widget.py +++ b/vnpy/trader/ui/widget.py @@ -507,6 +507,24 @@ class OrderMonitor(BaseMonitor): } } + def init_ui(self): + """ + Connect signal. + """ + super(OrderMonitor, self).init_ui() + + self.setToolTip("双击单元格撤单") + self.itemDoubleClicked.connect(self.cancel_order) + + def cancel_order(self, cell): + """ + Cancel order if cell double clicked. + """ + order = cell.get_data() + req = order.create_cancel_request() + self.main_engine.cancel_order(req, order.gateway_name) + + class PositionMonitor(BaseMonitor): """ Monitor for position data.