diff --git a/src/.idea/dbnavigator.xml b/src/.idea/dbnavigator.xml new file mode 100644 index 0000000..7391c15 --- /dev/null +++ b/src/.idea/dbnavigator.xml @@ -0,0 +1,525 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
\ No newline at end of file diff --git a/src/windows/__pycache__/operateselect_window.cpython-311.pyc b/src/windows/__pycache__/operateselect_window.cpython-311.pyc index d94f42b..3b1284f 100644 Binary files a/src/windows/__pycache__/operateselect_window.cpython-311.pyc and b/src/windows/__pycache__/operateselect_window.cpython-311.pyc differ diff --git a/src/windows/__pycache__/selectRuleOrder.cpython-311.pyc b/src/windows/__pycache__/selectRuleOrder.cpython-311.pyc index 5f9fc81..e061907 100644 Binary files a/src/windows/__pycache__/selectRuleOrder.cpython-311.pyc and b/src/windows/__pycache__/selectRuleOrder.cpython-311.pyc differ diff --git a/src/windows/__pycache__/settingrule_window.cpython-311.pyc b/src/windows/__pycache__/settingrule_window.cpython-311.pyc index be28162..f8503b3 100644 Binary files a/src/windows/__pycache__/settingrule_window.cpython-311.pyc and b/src/windows/__pycache__/settingrule_window.cpython-311.pyc differ diff --git a/src/windows/control/contrltools/setShotArea.py b/src/windows/control/contrltools/setShotArea.py new file mode 100644 index 0000000..52ff704 --- /dev/null +++ b/src/windows/control/contrltools/setShotArea.py @@ -0,0 +1,76 @@ +import pyautogui +import cv2 +import numpy as np + + +class SetShotArea(): + # 获取屏幕宽度和高度 + screen_width, screen_height = pyautogui.size() + + # 用于存储用户绘制的矩形坐标 + rect_coordinates = [] + + # 获取屏幕截图 + capture = pyautogui.screenshot() + + # 将截图转换为OpenCV格式 + capture = np.array(capture) + capture = cv2.cvtColor(capture, cv2.COLOR_RGB2BGR) + + # 回调函数,用于处理鼠标事件 + def on_mouse(self, event, x, y, flags, param): + global rect_coordinates + + # 当左键按下时记录起始坐标,并允许实时更新 + if event == cv2.EVENT_LBUTTONDOWN: + rect_coordinates = [(x, y)] + + # 当鼠标移动时,实时更新矩形大小并绘制在截图上 + if event == cv2.EVENT_MOUSEMOVE and (flags & cv2.EVENT_FLAG_LBUTTON): + temp_capture = self.capture.copy() + cv2.rectangle(temp_capture, rect_coordinates[0], (x, y), (0, 255, 0), 1) + cv2.imshow("Capture", temp_capture) + + # 当左键释放时记录结束坐标,并绘制最终矩形 + elif event == cv2.EVENT_LBUTTONUP: + rect_coordinates.append((x, y)) + cv2.rectangle(self.capture, rect_coordinates[0], rect_coordinates[1], (0, 255, 0), 2) + cv2.imshow("Capture", self.capture) + + # 回调函数,用于处理鼠标事件 + def setShotArea(self): + + # 创建窗口并设置鼠标事件回调函数 + cv2.namedWindow("Capture", cv2.WINDOW_NORMAL) + cv2.setWindowProperty("Capture", cv2.WND_PROP_FULLSCREEN, cv2.WINDOW_FULLSCREEN) + cv2.setMouseCallback("Capture", self.on_mouse) + + while True: + cv2.imshow("Capture", self.capture) + key = cv2.waitKey(1) & 0xFF + + # 当用户按下'Enter'键时截取矩形区域并保存为文件 + if key == 13: + if len(rect_coordinates) == 2: + x1, y1 = rect_coordinates[0] + x2, y2 = rect_coordinates[1] + # 截取矩形区域 + cropped_area = self.capture[min(y1, y2):max(y1, y2), min(x1, x2):max(x1, x2)] + + shotArea = {'left': min(x1, x2), 'top': min(y1, y2), 'width': max(x1, x2) - min(x1, x2), + 'height': max(y1, y2) - min(y1, y2)} + print(shotArea) + return shotArea + + # 保存截图 + # cv2.imwrite("cropped_area.png", cropped_area) + # print("截图已保存为cropped_area(%d,%d;%d,%d).png" % (min(y1, y2), max(y1, y2), min(x1, x2), max(x1, x2))) + break + else: + print("请先绘制矩形区域再按下'Enter'键进行截图!") + + cv2.destroyAllWindows() + + +it = SetShotArea() +q = it.setShotArea() diff --git a/src/windows/control/database/databaseconnact.py b/src/windows/control/database/databaseconnact.py new file mode 100644 index 0000000..db76aa5 --- /dev/null +++ b/src/windows/control/database/databaseconnact.py @@ -0,0 +1,23 @@ +import psycopg2 +# -*- coding: utf-8 -*- +import psycopg2 +# 获得连接 +conn = psycopg2.connect(database="gamerule", user="postgres", password="123456", host="localhost", port="5432") +# 获得游标对象 +cursor = conn.cursor() + +sql = "SELECT * FROM table1;" +# 执行SQL查询 +cursor.execute(sql) + +# 获取查询结果 +rows = cursor.fetchall() + +# 处理查询结果 +for row in rows: + print(row) + +# conn.commit() +# 关闭数据库连接 +conn.close() + diff --git a/src/windows/main_window.py b/src/windows/main_window.py index 42e6935..9f8a750 100644 --- a/src/windows/main_window.py +++ b/src/windows/main_window.py @@ -1,12 +1,14 @@ - import sys -from PyQt5.QtWidgets import QApplication, QMainWindow, QPushButton, QListWidget, QListWidgetItem + +import pyautogui as p +from PyQt5.QtWidgets import QApplication, QMainWindow, QPushButton, QListWidget, QListWidgetItem, QComboBox from PyQt5.QtCore import Qt from PyQt5 import uic from translate_window import translate from settingrule_window import settingrule from selectRuleOrder import orderselet +from control.contrltools.setShotArea import SetShotArea class MyApp(QMainWindow): @@ -15,6 +17,8 @@ class MyApp(QMainWindow): uic.loadUi('res/ui/main_window.ui', self) + self.shotArea = {} + self.translate_window = translate() self.setRule_window = settingrule() self.orderSelect_window = orderselet() @@ -25,6 +29,13 @@ class MyApp(QMainWindow): self.autoplay = self.findChild(QPushButton, 'autoGameBtn') self.ruleList = self.findChild(QListWidget, 'ruleList') + self.language = self.findChild(QComboBox, 'language') + self.choseLocationBtn = self.findChild(QPushButton, 'choseLocationBtn') + + self.language.activated.connect(self.selectTransLanguage) + + self.choseLocationBtn.clicked.connect(self.takeScreenShot) + self.addRuleBtn.clicked.connect(self.show_settingrule_window) self.translateBtn.clicked.connect(self.show_translate_window) self.autoplay.clicked.connect(self.show_orderselect_window) @@ -36,12 +47,18 @@ class MyApp(QMainWindow): self.ruleList.itemClicked.connect(self.onItemClicked) self.listIndexs = self.get_item_indexs(self.ruleList) + def takeScreenShot(self): # 截屏 + shot = SetShotArea() + self.shotArea = shot.setShotArea() + screenshot = p.screenshot(region=(self.shotArea['left'], self.shotArea['top'], + self.shotArea['width'], self.shotArea['height'])) + def show_orderselect_window(self): item_states = self.get_item_states(self.ruleList) for item_text, item_state in item_states.items(): if item_state == Qt.Checked: item = QListWidgetItem(item_text) - item.setFlags(item.flags()|Qt.ItemIsSelectable|Qt.ItemIsUserCheckable|Qt.ItemIsEnabled) + item.setFlags(item.flags() | Qt.ItemIsSelectable | Qt.ItemIsUserCheckable | Qt.ItemIsEnabled) item.setCheckState(Qt.Unchecked) self.orderSelect_window.order_list.addItem(item) self.orderSelect_window.show() @@ -82,6 +99,15 @@ class MyApp(QMainWindow): item_indexs[item_text] = index return item_indexs + def selectTransLanguage(self, index): # 各种语言选项的返回值 + selected_language = self.language.itemText(index) + if selected_language == "日语": + print("jap") + elif selected_language == "法语": + print("fra") + elif selected_language == "英语": + print("eng") + if __name__ == "__main__": app = QApplication(sys.argv) diff --git a/src/windows/operateselect_window.py b/src/windows/operateselect_window.py index 4e40a6b..21f53c6 100644 --- a/src/windows/operateselect_window.py +++ b/src/windows/operateselect_window.py @@ -1,4 +1,4 @@ -from PyQt5.QtWidgets import QMainWindow, QWidget +from PyQt5.QtWidgets import QMainWindow, QWidget, QGridLayout, QLabel, QPushButton from PyQt5 import uic @@ -6,4 +6,46 @@ class operateselect(QMainWindow): def __init__(self): super().__init__() + self.selectedWidget = None uic.loadUi('res/ui/operationSelect_window.ui', self) + + self.findQGridLayout() + self.confirmBtn = self.findChild(QPushButton, 'confirmBtn')#确定按钮 + self.confirmBtn.clicked.connect(self.confirm_clicked) + + + def confirm_clicked(self): + print("已选择:", self.getOperator()) + self.close() + + def findQGridLayout(self): # 找到QGridLayout + grid_layout = self.findChild(QGridLayout, "gridLayout") + if grid_layout: + for i in range(grid_layout.rowCount()): + for j in range(grid_layout.columnCount()): + item = grid_layout.itemAtPosition(i, j) + if item and isinstance(item.widget(), QWidget): + widget = item.widget() + widget.mousePressEvent = lambda event, clickedwidget=widget: self.onWidgetClicked(clickedwidget) + self.selectedWidget = None + + def onWidgetClicked(self, clickedwidget): + # 将之前被选中的QWidget的背景颜色恢复为默认 + if self.selectedWidget: + self.selectedWidget.setStyleSheet("background-color: none;") + # 设置被选中的QWidget的背景颜色为浅蓝色 + clickedwidget.setStyleSheet("background-color: lightblue;") + self.selectedWidget = clickedwidget + + label = self.selectedWidget.findChild(QLabel) + if label: + print("选中的标签文本:", label.text()) + self.setOperator(label.text()) + else: + print("未找到标签文本") + + def setOperator(self,opt_text):#获取到操作类型值 + self.operator_text = opt_text + + def getOperator(self):#返回操作类型值 + return self.operator_text \ No newline at end of file diff --git a/src/windows/res/rules/__pycache__/明日方舟自动清体力.cpython-311.pyc b/src/windows/res/rules/__pycache__/明日方舟自动清体力.cpython-311.pyc index e2b6921..f31afab 100644 Binary files a/src/windows/res/rules/__pycache__/明日方舟自动清体力.cpython-311.pyc and b/src/windows/res/rules/__pycache__/明日方舟自动清体力.cpython-311.pyc differ diff --git a/src/windows/res/rules/明日方舟自动清体力.py b/src/windows/res/rules/明日方舟自动清体力.py index 553a575..cbc30c7 100644 --- a/src/windows/res/rules/明日方舟自动清体力.py +++ b/src/windows/res/rules/明日方舟自动清体力.py @@ -122,9 +122,11 @@ def find_target_level(): print("on purpose chapter") else: return False - while DealPicture.find_photo_center( - '../pictures/level_1-1.png', 1, 0.9) is None and DealPicture.find_photo_center( - '../pictures/level_1-7.png', 1, 0.9) is None: + while (DealPicture.find_photo_center( + '../pictures/level_1-1.png', 1, 0.9) is None + and + DealPicture.find_photo_center('../pictures/level_1-7.png', 1, 0.9) is None): + drag_position = cv2.imread('../pictures/back_btn.png') name = 'level_1-7.png' if DealPicture.find_photo_center('../pictures/back_btn.png', 2): @@ -260,19 +262,23 @@ class WorkerThread(QThread): os.chdir('res/rules') current_directory = os.getcwd() print("Current working directory:", current_directory) - # i = 0 - # if find_target_level(): - # while i < 10: - # fight_time() - # else: - # backToTerminal() - # while fight_time() is False and i < 10: - # while find_target_level() is False: - # while find_target_chapter() is False: - # while backToTerminal() is False: - # print("开始") - # i += 1 + i = 0 + if find_target_level(): + while i < 10: + fight_time() + else: + backToTerminal() + while fight_time() is False: + while find_target_level() is False: + while find_target_chapter() is False: + while backToTerminal() is False: + print("开始") + i += 1 + while i < 10: + fight_time() + i += 1 os.chdir('../../../windows') current_directory = os.getcwd() print("Current working directory:", current_directory) + print("自动战斗完毕") self.finished.emit() diff --git a/src/windows/res/tools/test.py b/src/windows/res/tools/test.py deleted file mode 100644 index 2355eb7..0000000 --- a/src/windows/res/tools/test.py +++ /dev/null @@ -1,7 +0,0 @@ -pOffsetX = 2 -pOffsetY = 1 -if pOffsetX: - poffsetx = pOffsetX - print(1) -if pOffsetY: - poffsety = pOffsetY \ No newline at end of file diff --git a/src/windows/res/tools/translate.py b/src/windows/res/tools/translate.py new file mode 100644 index 0000000..5aee742 --- /dev/null +++ b/src/windows/res/tools/translate.py @@ -0,0 +1,47 @@ +import random +from hashlib import md5 + +import requests +import json + +def translate_text(text, from_lang, to_lang, api_key): + base_url = "https://fanyi-api.baidu.com/api/trans/vip/translate" + + def make_md5(s, encoding='utf-8'): + return md5(s.encode(encoding)).hexdigest() + + salt = random.randint(32768, 65536) + sign = make_md5('20220121001062201' + text + str(salt) + api_key) + + params = { + 'q': text, + 'from': from_lang, + 'to': to_lang, + 'appid': '20220121001062201', + 'salt': salt, + 'sign': sign, + } + response = requests.get(base_url, params=params) + result = response.json() + if 'trans_result' in result: + translated_text = result['trans_result'][0]['dst'] + return translated_text + else: + return '翻译失败' + +# 输入要翻译的文本 +text_to_translate = input("请输入要翻译的文本:") + +# 设置源语言和目标语言 +from_language = 'auto' # 自动检测语言 +to_language = 'zh' # 翻译成中文 + +# 替换为您的API密钥 +api_key = 'LxybddF5Y966dC1BXTc5' + +# 调用翻译函数并输出结果 +translated_text = translate_text(text_to_translate, from_language, to_language, api_key) +if translated_text: + print("翻译结果:", translated_text) +else: + print("翻译失败。") diff --git a/src/windows/res/ui/main_window.ui b/src/windows/res/ui/main_window.ui index a3565be..de0ab40 100644 --- a/src/windows/res/ui/main_window.ui +++ b/src/windows/res/ui/main_window.ui @@ -6,8 +6,8 @@ 0 0 - 352 - 803 + 350 + 809 @@ -114,7 +114,7 @@ 语言选择: - + 50 @@ -123,11 +123,19 @@ 25 + + 日语 + 日语 + + + 法语 + + 英语 diff --git a/src/windows/res/ui/operationSelect_window.ui b/src/windows/res/ui/operationSelect_window.ui index 931bd74..2ff8df1 100644 --- a/src/windows/res/ui/operationSelect_window.ui +++ b/src/windows/res/ui/operationSelect_window.ui @@ -6,212 +6,210 @@ 0 0 - 693 - 431 + 663 + 465 Form - + 0 0 - 691 - 341 + 671 + 471 - + - 0 - 0 - 101 - 101 + 10 + 10 + 641 + 321 - - - - - - - - 点击操作 - + + + + + + + + <html><head/><body><p><br/></p></body></html> + + + <html><head/><body><p>12</p></body></html> + + + + + + + 点击操作 + + + Qt::AutoText + + + Qt::AlignCenter + + + + - - - - - - 130 - 0 - 101 - 101 - - - - - - - - - - 长按操作 - + + + + + + + + + + 长按操作 + + + Qt::AlignCenter + + + + - - - - - - 260 - 0 - 101 - 101 - - - - - - - - - - 左划操作 - + + + + + + + + + + 左滑操作 + + + Qt::AlignCenter + + + + - - - - - - 390 - 0 - 101 - 101 - - - - - - - - - - 右划操作 - + + + + + + + + + + 右滑操作 + + + Qt::AlignCenter + + + + - - - - - - 520 - 0 - 101 - 101 - - - - - - - - - - 键盘点击操作 - + + + + + + + + + + 休眠操作 + + + Qt::AlignCenter + + + + - - - - - - 0 - 130 - 101 - 101 - - - - - - - - - - 休眠操作 - + + + + + + + + + + 上滑操作 + + + Qt::AlignCenter + + + + - - - - - - 130 - 130 - 101 - 101 - - - - - + + + + + + + + + + 键盘点击操作 + + + Qt::AlignCenter + + + + + - - - - 上划操作 - + + + + + + + + + + 下滑操作 + + + Qt::AlignCenter + + + + - + 270 - 130 - 101 - 101 + 370 + 119 + 71 - - - - - - - - 下划操作 - - - - + + 确认 + - - - - 300 - 350 - 91 - 71 - - - - 确认 - - diff --git a/src/windows/res/ui/setRule_window.ui b/src/windows/res/ui/setRule_window.ui index 506ee5e..f286870 100644 --- a/src/windows/res/ui/setRule_window.ui +++ b/src/windows/res/ui/setRule_window.ui @@ -44,11 +44,11 @@ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">图片地址</p></body></html> +</style></head><body style=" font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:11pt;">图片地址</span></p></body></html> - + 220 @@ -100,7 +100,7 @@ p, li { white-space: pre-wrap; } 操作坐标: - + 220 @@ -126,8 +126,8 @@ p, li { white-space: pre-wrap; } <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">0</p></body></html> +</style></head><body style=" font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:11pt;">0</span></p></body></html> @@ -169,8 +169,8 @@ p, li { white-space: pre-wrap; } <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">0</p></body></html> +</style></head><body style=" font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:11pt;">0</span></p></body></html> @@ -245,11 +245,11 @@ p, li { white-space: pre-wrap; } <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">图片地址</p></body></html> +</style></head><body style=" font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:11pt;">图片地址</span></p></body></html> - + 220 @@ -275,12 +275,12 @@ p, li { white-space: pre-wrap; } <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">图片地址</p></body></html> +</style></head><body style=" font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:11pt;">图片地址</span></p></body></html> - + 230 @@ -293,7 +293,7 @@ p, li { white-space: pre-wrap; } next - + 160 @@ -306,7 +306,7 @@ p, li { white-space: pre-wrap; } previous - + 160 @@ -319,7 +319,7 @@ p, li { white-space: pre-wrap; } 保存 - + 30 diff --git a/src/windows/selectRuleOrder.py b/src/windows/selectRuleOrder.py index 109fc51..a97d0df 100644 --- a/src/windows/selectRuleOrder.py +++ b/src/windows/selectRuleOrder.py @@ -1,7 +1,8 @@ import os from PyQt5.QtWidgets import QMainWindow, QListWidget, QPushButton from PyQt5 import uic -from windows.res.rules.明日方舟自动清体力 import WorkerThread + +from res.rules.明日方舟自动清体力 import WorkerThread class orderselet(QMainWindow): diff --git a/src/windows/settingrule_window.py b/src/windows/settingrule_window.py index 1aa9c49..4e81493 100644 --- a/src/windows/settingrule_window.py +++ b/src/windows/settingrule_window.py @@ -1,5 +1,8 @@ -from PyQt5.QtWidgets import QMainWindow, QComboBox +import os + +from PyQt5.QtWidgets import QMainWindow, QComboBox, QPushButton, QTextEdit from PyQt5 import uic +import shutil from operateselect_window import operateselect @@ -10,9 +13,21 @@ class settingrule(QMainWindow): uic.loadUi('res/ui/setRule_window.ui', self) - self.operateChoseBox = self.findChild(QComboBox, 'operateChose') + # 图片地址 + + self.operateChoseBox = self.findChild(QComboBox, 'operateChose') # 操作选择 + self.cancelBtn = self.findChild(QPushButton, 'cancelBtn')#取消选择按钮 + self.preserveBtn = self.findChild(QPushButton, 'preserveBtn') # 保存选择按钮 + self.uploadBtn = self.findChild(QPushButton, 'uploadBtn') # "上传"按钮 + self.uploadBtn_2 = self.findChild(QPushButton, 'uploadBtn_2') + self.uploadBtn_3 = self.findChild(QPushButton, 'uploadBtn_3') self.operateChoseBox.activated.connect(self.handleComboBoxActivated) + self.cancelBtn.clicked.connect(self.cancel_clicked) + self.preserveBtn.clicked.connect(self.preserve_clicked) + self.uploadBtn.clicked.connect(self.write_image_to_folder) + self.uploadBtn_2.clicked.connect(self.write_image_to_folder_2) + self.uploadBtn_3.clicked.connect(self.write_image_to_folder_3) self.operateselect_window = operateselect() @@ -24,3 +39,40 @@ class settingrule(QMainWindow): def create新界面(self): # 显示新界面 self.operateselect_window.show() + + def cancel_clicked(self): + self.close() + + def preserve_clicked(self): + self.close() + + def write_image_to_folder(self): # 将图片写入目标文件 + text_edit = self.findChild(QTextEdit, "textEdit") + self.image_path = text_edit.toPlainText() + print(self.image_path) + destination_path = "D:/代码/pythoncode/src/windows/res/pictures" + if not os.path.exists(self.image_path): + print("image address is not existing!") + return + shutil.copy(self.image_path, destination_path) + + def write_image_to_folder_2(self): # 将图片写入目标文件 + text_edit = self.findChild(QTextEdit, "textEdit_2") + self.image_path = text_edit.toPlainText() + print(self.image_path) + destination_path = "D:/代码/pythoncode/src/windows/res/pictures" + if not os.path.exists(self.image_path): + print("image address is not existing!") + return + shutil.copy(self.image_path, destination_path) + + def write_image_to_folder_3(self): # 将图片写入目标文件 + text_edit = self.findChild(QTextEdit, "textEdit_3") + self.image_path = text_edit.toPlainText() + print(self.image_path) + destination_path = "D:/代码/pythoncode/src/windows/res/pictures" + if not os.path.exists(self.image_path): + print("image address is not existing!") + return + shutil.copy(self.image_path, destination_path) +