class MLTools(QFrame): reg_tool = pyqtSignal(tuple, name='register_tool_ml') def __init__(self, parent): super().__init__(parent) self.initUI() def initUI(self): self.setStyleSheet('background-color: silver') mod_path = os.path.dirname(Pythonic.__file__) """ image_folder = QDir('images') if not image_folder.exists(): logging.error('Image foulder not found') sys.exit(1) """ self.layout_h = QHBoxLayout() self.svm = MasterTool(self, 'MLSVM', 1) self.svm.setPixmap( QPixmap(os.path.join(mod_path, 'images/MLSVM.png')).scaled(120, 60)) self.svm_predict = MasterTool(self, 'MLSVM_Predict', 1) self.svm_predict.setPixmap( QPixmap(os.path.join(mod_path, 'images/MLSVM_Predict.png')).scaled(120, 60)) self.layout_h.addWidget(self.svm) self.layout_h.addWidget(self.svm_predict) self.layout_h.addStretch(1) self.setLayout(self.layout_h) def mousePressEvent(self, event): child = self.childAt(event.pos()) if not child: return pixmap = QPixmap(child.pixmap()) mimeData = QMimeData() mimeData.setText(child.type) drag = QDrag(self) drag.setPixmap(child.pixmap()) drag.setMimeData(mimeData) drag.setHotSpot(event.pos() - child.pos()) tempPixmap = QPixmap(pixmap) painter = QPainter() painter.begin(tempPixmap) painter.fillRect(pixmap.rect(), QColor(127, 127, 127, 127)) painter.end() child.setPixmap(tempPixmap) if drag.exec_(Qt.CopyAction | Qt.MoveAction, Qt.CopyAction) == Qt.MoveAction: child.close() else: child.show() child.setPixmap(pixmap) def register_tools(self): logging.debug('MLTools::register_tools() called') self.reg_tool.emit(self.svm.toolData()) self.reg_tool.emit(self.svm_predict.toolData())
class BasicTools(QFrame): reg_tool = pyqtSignal(tuple, name='register_tool_basic') def __init__(self, parent): super().__init__(parent) self.initUI() def initUI(self): self.setStyleSheet('background-color: silver') image_folder = QDir('images') self.layout_h = QHBoxLayout() self.op_tool = MasterTool(self, 'ExecOp', 1) self.op_tool.setPixmap(QPixmap('images/ExecOp.png').scaled(120, 60)) self.branch_tool = MasterTool(self, 'ExecBranch', 2) self.branch_tool.setPixmap(QPixmap('images/ExecBranch.png').scaled(120, 60)) self.return_tool = MasterTool(self, 'ExecReturn', 0) self.return_tool.setPixmap(QPixmap('images/ExecReturn.png').scaled(120, 60)) self.proc_tool = MasterTool(self, 'ExecProcess', 2) self.proc_tool.setPixmap(QPixmap('images/ExecProcess.png').scaled(120, 60)) self.ta_tool = MasterTool(self, 'ExecTA', 1) self.ta_tool.setPixmap(QPixmap('images/ExecTA.png').scaled(120, 60)) self.sched_tool = MasterTool(self, 'ExecSched', 1) self.sched_tool.setPixmap(QPixmap('images/ExecSched.png').scaled(120, 60)) # uncomment in future release self.stack_tool = MasterTool(self, 'ExecStack', 1) self.stack_tool.setPixmap(QPixmap('images/ExecStack.png').scaled(120, 60)) self.layout_h.addWidget(self.op_tool) self.layout_h.addWidget(self.branch_tool) self.layout_h.addWidget(self.return_tool) self.layout_h.addWidget(self.proc_tool) self.layout_h.addWidget(self.ta_tool) self.layout_h.addWidget(self.sched_tool) self.layout_h.addWidget(self.stack_tool) self.layout_h.addStretch(1) self.setLayout(self.layout_h) def mousePressEvent(self, event): child = self.childAt(event.pos()) if not child: return mimeData = QMimeData() mimeData.setText(child.type) logging.debug('mousePressEvent() called: {}'.format(event.pos())) drag = QDrag(self) drag.setPixmap(child.pixmap()) drag.setMimeData(mimeData) drag.setHotSpot(event.pos() - child.pos()) if drag.exec_(Qt.CopyAction | Qt.MoveAction, Qt.CopyAction) == Qt.MoveAction: child.close() else: child.show() child.setPixmap(child.pixmap()) def register_tools(self): logging.debug('register_tools() called BasicTools') self.reg_tool.emit(self.op_tool.toolData()) self.reg_tool.emit(self.branch_tool.toolData()) self.reg_tool.emit(self.return_tool.toolData()) self.reg_tool.emit(self.proc_tool.toolData()) self.reg_tool.emit(self.ta_tool.toolData()) self.reg_tool.emit(self.sched_tool.toolData()) #uncomment in future release self.reg_tool.emit(self.stack_tool.toolData())
class ConnectivityTools(QFrame): reg_tool = pyqtSignal(tuple, name='register_tool_connectivity') def __init__(self, parent): super().__init__(parent) self.initUI() def initUI(self): self.setStyleSheet('background-color: silver') image_folder = QDir('images') if not image_folder.exists(): logging.error('Image foulder not found') sys.exit(1) self.layout_h = QHBoxLayout() self.e_mail = MasterTool(self, 'ConnMail', 1) self.e_mail.setPixmap(QPixmap('images/ConnMail.png').scaled(120, 60)) self.rest = MasterTool(self, 'ConnREST', 1) self.rest.setPixmap(QPixmap('images/ConnREST.png').scaled(120, 60)) self.layout_h.addWidget(self.e_mail) self.layout_h.addWidget(self.rest) self.layout_h.addStretch(1) self.setLayout(self.layout_h) def mousePressEvent(self, event): child = self.childAt(event.pos()) if not child: return pixmap = QPixmap(child.pixmap()) mimeData = QMimeData() mimeData.setText(child.type) drag = QDrag(self) drag.setPixmap(child.pixmap()) drag.setMimeData(mimeData) drag.setHotSpot(event.pos() - child.pos()) tempPixmap = QPixmap(pixmap) painter = QPainter() painter.begin(tempPixmap) painter.fillRect(pixmap.rect(), QColor(127, 127, 127, 127)) painter.end() child.setPixmap(tempPixmap) if drag.exec_(Qt.CopyAction | Qt.MoveAction, Qt.CopyAction) == Qt.MoveAction: child.close() else: child.show() child.setPixmap(pixmap) def register_tools(self): logging.debug('ConnectivityTools::register_tools() called') self.reg_tool.emit(self.e_mail.toolData()) self.reg_tool.emit(self.rest.toolData())
class BinanceTools(QFrame): reg_tool = pyqtSignal(tuple, name='register_tool_binance') def __init__(self, parent): super().__init__(parent) self.initUI() def initUI(self): self.setStyleSheet('background-color: silver') mod_path = os.path.dirname(Pythonic.__file__) self.layout_h = QHBoxLayout() self.scheduler = MasterTool(self, 'BinanceSched', 1) self.scheduler.setPixmap( QPixmap(join(mod_path, 'images/BinanceSched.png')).scaled(120, 60)) self.ohlc = MasterTool(self, 'BinanceOHLC', 1) self.ohlc.setPixmap( QPixmap(join(mod_path, 'images/BinanceOHLC.png')).scaled(120, 60)) self.order = MasterTool(self, 'BinanceOrder', 1) self.order.setPixmap( QPixmap(join(mod_path, 'images/BinanceOrder.png')).scaled(120, 60)) self.layout_h.addWidget(self.scheduler) self.layout_h.addWidget(self.ohlc) self.layout_h.addWidget(self.order) self.layout_h.addStretch(1) self.setLayout(self.layout_h) def mousePressEvent(self, event): child = self.childAt(event.pos()) if not child: return pixmap = QPixmap(child.pixmap()) mimeData = QMimeData() mimeData.setText(child.type) drag = QDrag(self) drag.setPixmap(child.pixmap()) drag.setMimeData(mimeData) drag.setHotSpot(event.pos() - child.pos()) tempPixmap = QPixmap(pixmap) painter = QPainter() painter.begin(tempPixmap) painter.fillRect(pixmap.rect(), QColor(127, 127, 127, 127)) painter.end() child.setPixmap(tempPixmap) if drag.exec_(Qt.CopyAction | Qt.MoveAction, Qt.CopyAction) == Qt.MoveAction: child.close() else: child.show() child.setPixmap(pixmap) def register_tools(self): logging.debug('BinanceTools::register_tools() called') self.reg_tool.emit(self.scheduler.toolData()) self.reg_tool.emit(self.ohlc.toolData()) self.reg_tool.emit(self.order.toolData())