From 466c85355b49b2363b7ea6bc4871bcd0e01d7447 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期三, 19 七月 2023 18:09:15 +0800
Subject: [PATCH] HOST修改

---
 main.py |   33 +++++++++++++++++++++++----------
 1 files changed, 23 insertions(+), 10 deletions(-)

diff --git a/main.py b/main.py
index 1074e2e..93d9132 100644
--- a/main.py
+++ b/main.py
@@ -6,6 +6,7 @@
 from multiprocessing import freeze_support
 import sys
 import torch
+import win32gui
 from PyQt5.QtGui import QFont, QPalette, QColor, QTextOption
 
 from PyQt5.QtWebChannel import QWebChannel
@@ -15,14 +16,16 @@
 
 from PyQt5.QtCore import Qt, pyqtSlot, QObject, pyqtSignal, QTimer, QUrl, QPoint
 
+import constant
 import gui_wx
 import network_util
 import setting
 import tool
+import win32_util
 
 freeze_support()
 
-URL_MSG_LIST = "http://192.168.3.252/kp/msg_list.html"
+URL_MSG_LIST = f"http://{constant.WEB_HOST}/kp/msg_list.html"
 
 
 class BaseBridgeClass(QObject):
@@ -89,6 +92,14 @@
 
     def __setMsg(self, msg):
         print("鏀跺埌淇℃伅锛�", msg)
+        palette = QPalette()
+        if msg.find("鎾ゅ崟") > -1:
+            palette.setColor(QPalette.WindowText, QColor(0, 128, 0))  # 璁剧疆瀛椾綋棰滆壊涓虹豢鑹�
+        elif msg.find("涓嬪崟") > -1:
+            palette.setColor(QPalette.WindowText, QColor(34, 26, 178))  # 璁剧疆瀛椾綋棰滆壊涓洪粍鑹�
+        elif msg.find("鎴愪氦") > -1:
+            palette.setColor(QPalette.WindowText, QColor(255, 0, 0))  # 璁剧疆瀛椾綋棰滆壊涓虹孩鑹�
+        self.label.setPalette(palette)
         self.label.setText(msg)
         self.show()
         self.timer.stop()
@@ -96,18 +107,20 @@
 
     # 璁剧疆淇℃伅
     def setMsg(self, msg):
+        # TODO 娴嬭瘯
         self.msgChange.emit(msg)
 
     def __init__(self):
         super().__init__()
         window_height = 80
         padding = 10
-        window_info = setting.get_float_watch_window_info()
-        if window_info:
-            self.move(window_info[0] + padding - 3, window_info[1] - window_height - 30)
-            self.resize(window_info[2] - (padding - 2) * 2, window_height)
-        else:
-            self.resize(300, 50)
+        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)
         self.setWindowTitle("娑堟伅鎻愮ず")
         self.setWindowFlag(Qt.WindowStaysOnTopHint, True)
         self.setWindowOpacity(0.9)
@@ -237,8 +250,8 @@
     # 璁剧疆鐩爣浠g爜
     def set_target_code(self, code):
         print("set_target_code")
-        self.webview.page().runJavaScript(f"app.set_target_code('{code}')")
         self.wx_pipe.send(json.dumps({"type": "set_code", "code": code}))
+        self.webview.page().runJavaScript(f"app.set_target_code('{code}')")
 
     # 鑿滃崟鍙婅彍鍗曠偣鍑讳簨浠�
     def __menu(self):
@@ -371,11 +384,11 @@
 
         self.setCentralWidget(self.webview)
         self.show()
-        self.webview.load(QUrl("http://192.168.3.252/kp/index23-05-04.html"))
+        self.webview.load(QUrl(f"http://{constant.WEB_HOST}/kp/index23-05-04.html"))
         # self.webview.load(QUrl("http://127.0.0.1:8848/kp/index23-05-04.html"))
 
         self.secondWindow.show()
-        self.secondWindow.loadUrl("http://192.168.3.252/kp/codes_list.html")
+        self.secondWindow.loadUrl(f"http://{constant.WEB_HOST}/kp/codes_list.html")
         # self.secondWindow.loadUrl("http://127.0.0.1:8848/kp/codes_list.html")
 
         # 缁戝畾妲藉嚱鏁�

--
Gitblit v1.8.0