| | |
| | | from PyQt5.QtGui import QFont, QPalette, QColor, QTextOption |
| | | |
| | | from PyQt5.QtWebChannel import QWebChannel |
| | | from PyQt5.QtWebEngineWidgets import QWebEngineView, QWebEngineSettings |
| | | from PyQt5.QtWebEngineWidgets import QWebEngineView, QWebEngineSettings, QWebEnginePage |
| | | from PyQt5.QtWidgets import QMainWindow, QApplication, QAction, QMessageBox, QLabel |
| | | |
| | | from PyQt5.QtCore import Qt, pyqtSlot, QObject, pyqtSignal, QTimer, QUrl, QPoint |
| | |
| | | result, need_delegate = LocalKanPanNetworkDelegate.http_delegate_request(url) |
| | | if not need_delegate: |
| | | result = network_util.http_get(url) |
| | | print(url, "请求结果:",url, result) |
| | | print(url, "请求结果:", result) |
| | | self.signal_request.emit(callback_info[0], callback_info[1], result) |
| | | return result |
| | | except Exception as e: |
| | | print("链接请求出错:"+ url) |
| | | logging.exception(e) |
| | | |
| | | def __socket_request(self, text, callback_info): |
| | | def __socket_request(self, text, callback_info, port=None): |
| | | try: |
| | | print("socket請求:", text) |
| | | result = network_util.socket_request(text) |
| | | print("请求结果:",text, result) |
| | | if port: |
| | | result = network_util.socket_request(text, port=port) |
| | | else: |
| | | result = network_util.socket_request(text) |
| | | print("请求结果:", result) |
| | | self.signal_request.emit(callback_info[0], callback_info[1], result) |
| | | return result |
| | | except Exception as e: |
| | |
| | | pass |
| | | callback_info = json.loads(callback_info) |
| | | t1 = threading.Thread(target=lambda: self.__socket_request(text, callback_info)) |
| | | t1.setDaemon(True) |
| | | t1.start() |
| | | |
| | | @pyqtSlot(str, str) |
| | | def ls_socket_request(self, text, callback_info): |
| | | print("ls_socket_request", text) |
| | | try: |
| | | text_json = json.loads(text) |
| | | params = [] |
| | | for k in text_json: |
| | | if k == "sign": |
| | | continue |
| | | if type(text_json[k]) == dict or type(text_json[k]) == list: |
| | | params.append(f"{k}={json.dumps(text_json[k], separators=(',', ':'))}") |
| | | else: |
| | | params.append(f"{k}={text_json[k]}") |
| | | params.sort() |
| | | params.append("%Yeshi2014@#.") |
| | | params_str = "&".join(params) |
| | | md5 = hashlib.md5() |
| | | md5.update(params_str.encode("utf-8")) |
| | | md5_hash = md5.hexdigest() |
| | | text_json["sign"] = md5_hash |
| | | text = json.dumps(text_json) |
| | | except: |
| | | pass |
| | | callback_info = json.loads(callback_info) |
| | | t1 = threading.Thread(target=lambda: self.__socket_request(text, callback_info, port=14008)) |
| | | t1.setDaemon(True) |
| | | t1.start() |
| | | |
| | |
| | | window_height = 80 |
| | | padding = 10 |
| | | self.resize(300, 50) |
| | | hwnds = win32_util.search_window("悬浮盯盘") |
| | | if hwnds: |
| | | rect = win32gui.GetWindowRect(hwnds[0]) |
| | | self.move(rect[0] + padding - 3, rect[1] - window_height - 30) |
| | | if rect[2] - rect[0] > 0: |
| | | self.resize((rect[2] - rect[0]) - (padding - 2) * 2, window_height) |
| | | # hwnds = win32_util.search_window("悬浮盯盘", is_one_result=True) |
| | | # if hwnds: |
| | | # rect = win32gui.GetWindowRect(hwnds[0]) |
| | | # self.move(rect[0] + padding - 3, rect[1] - window_height - 30) |
| | | # if rect[2] - rect[0] > 0: |
| | | # self.resize((rect[2] - rect[0]) - (padding - 2) * 2, window_height) |
| | | self.setWindowTitle("消息提示") |
| | | self.setWindowFlag(Qt.WindowStaysOnTopHint, True) |
| | | self.setWindowOpacity(0.9) |
| | |
| | | print("") |
| | | |
| | | |
| | | class WebEnginePage(QWebEnginePage): |
| | | def javaScriptConsoleMessage(self, level, message, lineNumber, sourceID): |
| | | """处理 JavaScript 控制台消息""" |
| | | print(f"JavaScript Console Error: {message} at line {lineNumber} of {sourceID}") |
| | | |
| | | def onLoadFailed(self, errorCode, failingUrl, errorDescription): |
| | | """处理加载失败的情况""" |
| | | print(f"Failed to load URL: {failingUrl}, Error: {errorDescription}, Code: {errorCode}") |
| | | |
| | | |
| | | class MainWindow(QMainWindow): |
| | | signal_update_code = pyqtSignal(str) |
| | | |
| | |
| | | size = (self.width(), self.height()) |
| | | self.wx_pipe.send(json.dumps({"type": "codes_setting", "pos": (ps[0] + size[0] / 2, ps[1] + size[1] / 2)})) |
| | | |
| | | def __show_dead_hwnds(): |
| | | self.wx_pipe.send(json.dumps({"type": "show_dead_hwnds"})) |
| | | |
| | | def __manage_ths_pos(): |
| | | ps = (self.x(), self.y()) |
| | | size = (self.width(), self.height()) |
| | |
| | | def __clear_webview_cache(): |
| | | self.webview.page().profile().clearHttpCache() |
| | | |
| | | def __show_ths_flash_trade(): |
| | | hwnds = ths_util.get_flash_trade_hwnds() |
| | | for hwnd in hwnds: |
| | | if not win32gui.IsWindowVisible(hwnd): |
| | | win32gui.BringWindowToTop(hwnd) |
| | | win32_util.move_window(hwnd, 0, 0) |
| | | |
| | | menubar = self.menuBar() |
| | | |
| | | setting_ = menubar.addMenu('&设置') |
| | | |
| | | juejin_action = QAction("&掘金参数配置", self) |
| | | juejin_action.triggered.connect(__set_juejin_params) |
| | | setting_.addAction(juejin_action) |
| | | |
| | | action = QAction("&代码管理", self) |
| | | action.triggered.connect(__manage_code) |
| | | setting_.addAction(action) |
| | | |
| | | action = QAction("&下载涨停代码", self) |
| | | action.triggered.connect(__download_codes) |
| | | setting_.addAction(action) |
| | | |
| | | action = QAction("&GPU检测", self) |
| | | action.triggered.connect(__gpu_is_avaiable) |
| | |
| | | action.triggered.connect(__clear_webview_cache) |
| | | setting_.addAction(action) |
| | | |
| | | action = QAction("&掘金分时数据下载", self) |
| | | action.triggered.connect(__juejin_tick_download) |
| | | setting_.addAction(action) |
| | | |
| | | action = QAction("&同花顺代码识别", self) |
| | | action.triggered.connect(__ths_ocr_code) |
| | | setting_.addAction(action) |
| | | |
| | | auto_ = menubar.addMenu('&自动化') |
| | | action = QAction("&同花顺设置", self) |
| | | action.triggered.connect(__manage_ths_pos) |
| | | auto_.addAction(action) |
| | | action = QAction("&死句柄管理", self) |
| | | action.triggered.connect(__show_dead_hwnds) |
| | | setting_.addAction(action) |
| | | |
| | | view_ = menubar.addMenu('&视图') |
| | | action = QAction("&打开副屏", self) |
| | |
| | | action.triggered.connect(__show_his_msg_window) |
| | | view_.addAction(action) |
| | | |
| | | view_ = menubar.addMenu('&代码管理') |
| | | view_.aboutToShow.connect(__manage_code) |
| | | |
| | | view_ = menubar.addMenu('&显示一键卖出') |
| | | view_.aboutToShow.connect(__show_ths_flash_trade) |
| | | |
| | | def __init__(self, wx_pipe): |
| | | super().__init__() |
| | |
| | | self.center() |
| | | self.setWindowFlag(Qt.WindowStaysOnTopHint, True) |
| | | self.webview = QWebEngineView() |
| | | self.webview.setPage(WebEnginePage()) |
| | | self.webview.settings().setAttribute(QWebEngineSettings.JavascriptEnabled, True) |
| | | self.__menu() |
| | | # JS桥设置 |
| | |
| | | except Exception as e: |
| | | print("") |
| | | self.wx_pipe.send(json.dumps({"type": "exit"})) |
| | | wxGuiProcess.terminate() |
| | | wxGuiProcess.join() |
| | | sys.exit(0) |
| | | |
| | | # 读取消息 |
| | |
| | | if __name__ == "__main__": |
| | | freeze_support() |
| | | p1, p2 = multiprocessing.Pipe() |
| | | global wxGuiProcess |
| | | wxGuiProcess = Process(target=gui_wx.run, args=(p1,)) |
| | | wxGuiProcess.start() |
| | | |