Пример #1
0
 def __init__(self, parent=None):
     super(Main, self).__init__(parent)
     self.engine = QQmlApplicationEngine(self)
     self.engine.addImportPath("./Modules")
     # 注意,在demo中,部分demo使用到了单例qml,需要使用qmldir来生效,所有需要导入demo
     self.engine.addImportPath("./demo")
     self.engine.load(QUrl.fromLocalFile('main.qml'))
     self.window = self.engine.rootObjects()[0]
Пример #2
0
class Main(QObject):
    def __init__(self,parent=None):
        super().__init__(parent)
        self.engine = QQmlApplicationEngine(self)
        self.engine.load(QUrl.fromLocalFile('application.qml'))
        self.window = self.engine.rootObjects()[0]

    def show(self):
        self.window.show()
Пример #3
0
 def __init__(self,parent=None):
     super(Main, self).__init__(parent)
     self.engine = QQmlApplicationEngine(self)
     self.engine.addImportPath("./modules")
     # 注意,在demo中,部分demo使用到了单例qml,需要使用qmldir来生效,所有需要导入demo
     # self.engine.addImportPath("./demo")
     self.engine.load(QUrl.fromLocalFile('./main.qml'))
     if len(self.engine.rootObjects()) == 0 :
         sys.exit(-1)
     #reloader = ObjectWithAReloadSignal()
     #self.engine.rootObjects().setContextProperty("_reloader", reloader)
     self.window = self.engine.rootObjects()[0]
     self.window.btnClicked.connect(self.on_click)
Пример #4
0
 def __init__(self,parent=None):
     super(Main, self).__init__(parent)
     self.engine = QQmlApplicationEngine(self)
     self.engine.addImportPath("./Modules")
     # 注意,在demo中,部分demo使用到了单例qml,需要使用qmldir来生效,所有需要导入demo
     self.engine.addImportPath("./demo")
     self.engine.load(QUrl.fromLocalFile('main.qml'))
     self.window = self.engine.rootObjects()[0]
Пример #5
0
class Main(QObject):
    m_nCurrentPage = 0
    def on_click(self, btnName, strContent):
        if btnName == "连接交易" : 
            if(btnConnectTrade.property('text') == '未连接') :
                nSplitPos = strContent.find(':')
                if nSplitPos <= 0 :
                    return
                Host = strContent[:nSplitPos]
                Port = int(strContent[nSplitPos + 1 :])
                print("connecting host %s:%d" %(Host, Port))
                reactor.connectTCP(Host, Port, TSClntFactory())
                if not reactor.running:
                    reactor.run();
            else:
                print('中断连接')
                if reactor.running:
                    reactor.stop()
                drop_connect()

        elif btnName == "连接命令" :
            print("连接命令")
            print(main.window.findChild(QObject, "res_msg"))
            #btnConnectCommand.setProperty('text', '正在连接')
            #_TradePorto.send_data(b'HEHE')
        elif btnName == "发送" :
            #print(strContent)
            reactor.callLater(0, _TradePorto.send_data(strContent.replace('\n','').replace('\t','')))
        elif btnName == '生成' :
            strRequestData=''
            json_object = json.loads(strContent)
            action = (json_object["操作"])
            if action == 'PlaceOrder' :
                #c = json_object["股票代码"]
                #print("股票:%s"%c)
                #print(json_object["交易市场"])
                jsonObj_order = {
                    "c": json_object["股票代码"],
                    "f": 0 if (json_object["交易市场"] == '做多') else 1,
                    "g": 0,
                    "info": "ip=,lip=,mac=,hd=,cpu=,pcn=",
                    "ip": json_object["IP"],
                    "m": 0 if (json_object["交易市场"] == '上海') else 1,
                    "mac": "",
                    "n": "",
                    "okey": "",
                    "ownedbygltrade": 0,
                    "p": float(json_object["送单价格"]),
                    "q": int(json_object["送单数量"]),
                    "rid": 0,
                    "t": 5,
                    "uefK": "",
                    "x": 0
                }
                strRequestData=json.dumps(jsonObj_order)
            elif (action == 'CancelOrder' or action == 'GetEntrust' or action == 'GetInTimeEntrust'):
                jsonObj_order = {
                    "c": json_object["股票代码"],
                    "f": 0 if (json_object["交易市场"] == '做多') else 1,
                    "g": 0,
                    "info": "ip=,lip=,mac=,hd=,cpu=,pcn=",
                    "ip": json_object["IP"],
                    "m": 0 if (json_object["交易市场"] == '上海') else 1,
                    "mac": "",
                    "n": json_object['委托单号'],
                    "okey": "",
                    "ownedbygltrade": 0,
                    "p": float(json_object["送单价格"]),
                    "q": int(json_object["送单数量"]),
                    "rid": 0,
                    "t": 5,
                    "uefK": "",
                    "x": 0
                }
                strRequestData=json.dumps(jsonObj_order)
            elif(action == 'GetResourceData'):
                d = {"资金":0,"持仓":1,"当日委托":2,"当日成交":3,"可撤单":4,"股东代码":5,"普通交易":6,"融资余额":7,"融券余额":8,"可融证券":9,"历史委托":10,"历史成交":11,"资金流水":12,"交割单":13,"融资负债":14}                       
                jsonQryResource = {
                 "end": json_object['开始时间'],
                	"rid": 0,
                	"start": json_object['结束时间'],
                	"type": d[json_object['原始数据']]
                }
                strRequestData=json.dumps(jsonQryResource)

                   
            global g_RequestID
            g_RequestID += 1
            jsonbj_request = {
            	"action": action,
            	"bi": textEndpoint.property('text'),
            	"data": strRequestData,
            	"id": str(g_RequestID)
            }
            textAreaSend.setProperty('text', json.dumps(jsonbj_request))
            
        elif(btnName == '清空'):
            textAreaSend.setProperty('text', '')
            textAreaReplyMsg.setProperty('text', '')
            textAreaReplyData.setProperty('text', '')
        elif(btnName == '上一页'):
            if(self.m_nCurrentPage <= 1):
                print('无上一页')
                return
            self.m_nCurrentPage -= 1
            #print(_TradePorto.m_mapPage2Res[self.m_nCurrentPage])
            btnCurrentPage.setProperty('text', '- ' + str(self.m_nCurrentPage) + ' -')
            textAreaReplyMsg.setProperty('text', _TradePorto.m_mapPage2Res[self.m_nCurrentPage][2])
            textAreaReplyData.setProperty('text', _TradePorto.m_mapPage2Res[self.m_nCurrentPage][1])
            textAreaSend.setProperty('text', _TradePorto.m_mapPage2Res[self.m_nCurrentPage][0])
        elif(btnName == '下一页'):
            #global _TradeProto
            if(self.m_nCurrentPage >= _TradePorto.m_nResCount):
                print('超出页码')
                return
            self.m_nCurrentPage += 1
            btnCurrentPage.setProperty('text', '- ' + str(self.m_nCurrentPage) + ' -')
            textAreaReplyMsg.setProperty('text', _TradePorto.m_mapPage2Res[self.m_nCurrentPage][2])
            textAreaReplyData.setProperty('text', _TradePorto.m_mapPage2Res[self.m_nCurrentPage][1])
            textAreaSend.setProperty('text', _TradePorto.m_mapPage2Res[self.m_nCurrentPage][0])
            #print(_TradePorto.m_mapPage2Res[self.m_nCurrentPage])
        else :
            print("undefined btn clicked :%s" %strContent)
            #print(self.window.findChild(QObject, "login_dialog").itemAt (3).children[1].property('text'))
            
    def __init__(self,parent=None):
        super(Main, self).__init__(parent)
        self.engine = QQmlApplicationEngine(self)
        self.engine.addImportPath("./modules")
        # 注意,在demo中,部分demo使用到了单例qml,需要使用qmldir来生效,所有需要导入demo
        # self.engine.addImportPath("./demo")
        self.engine.load(QUrl.fromLocalFile('./main.qml'))
        if len(self.engine.rootObjects()) == 0 :
            sys.exit(-1)
        #reloader = ObjectWithAReloadSignal()
        #self.engine.rootObjects().setContextProperty("_reloader", reloader)
        self.window = self.engine.rootObjects()[0]
        self.window.btnClicked.connect(self.on_click)
        #btnConnectTrade.setProperty('text', '已连接')


    def show(self):
        self.window.show()