| | |
| | | import json |
| | | import logging |
| | | import multiprocessing |
| | | import queue |
| | | import threading |
| | | import time |
| | | from multiprocessing import freeze_support |
| | |
| | | import constant |
| | | import gui_wx |
| | | from network_delegate_manager import LocalKanPanNetworkDelegate |
| | | from utils import network_util, xgb_api |
| | | from utils import network_util, xgb_api, ths_util |
| | | import setting |
| | | from utils import tool |
| | | import win32_util |
| | |
| | | freeze_support() |
| | | |
| | | URL_MSG_LIST = f"http://{constant.WEB_HOST}/kp/msg_list.html" |
| | | |
| | | window_msg_queue = queue.Queue() |
| | | |
| | | |
| | | class BaseBridgeClass(QObject): |
| | |
| | | @pyqtSlot(result=str) |
| | | def get_client(self): |
| | | return setting.get_client() |
| | | |
| | | @pyqtSlot(str) |
| | | def add_code_to_ths(self, code): |
| | | # 添加到同花顺 |
| | | threading.Thread(target=lambda: ths_util.add_code_to_zixuan(code),daemon=True).start() |
| | | |
| | | |
| | | class SecondWindowBridgeClass(BaseBridgeClass): |
| | | @pyqtSlot(str) |
| | | def set_target_code(self, code): |
| | | # 设置目标代码 |
| | | window_msg_queue.put_nowait({"type": "set_target_code", "data": {"code": code}}) |
| | | |
| | | |
| | | class JSBridgeClass(BaseBridgeClass): |
| | |
| | | # JS桥设置 |
| | | channel = QWebChannel(self.webview.page()) |
| | | self.webview.page().setWebChannel(channel) |
| | | self.python_bridge = BaseBridgeClass(self.webview) |
| | | self.python_bridge = SecondWindowBridgeClass(self.webview) |
| | | channel.registerObject("Bridge", self.python_bridge) |
| | | |
| | | # self.signal_update_kpl.connect(self.set_kpl_data) |
| | |
| | | self.wx_pipe.send(json.dumps({"type": "set_code", "code": code})) |
| | | self.webview.page().runJavaScript(f"app.set_target_code('{code}')") |
| | | self.secondWindow.set_target_code(code) |
| | | |
| | | def read_window_msg(self): |
| | | while True: |
| | | try: |
| | | data = window_msg_queue.get() |
| | | if data["type"] == "set_target_code": |
| | | code = data["data"]["code"] |
| | | self.signal_update_code.emit(code) |
| | | except: |
| | | pass |
| | | finally: |
| | | pass |
| | | |
| | | # 菜单及菜单点击事件 |
| | | def __menu(self): |
| | |
| | | |
| | | threading.Thread(target=KPLLimitUpDataManager().run, daemon=True).start() |
| | | threading.Thread(target=xgb_api.run, daemon=True).start() |
| | | threading.Thread(target=self.read_window_msg, daemon=True).start() |
| | | |
| | | def closeEvent(self, event): |
| | | event.accept() |