✅ update 参数调试
This commit is contained in:
@ -10,6 +10,7 @@ class TCPClient:
|
||||
self.port = port
|
||||
self.client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
self.client_socket.settimeout(5)
|
||||
self.connected = False
|
||||
|
||||
|
||||
def CreatConnect(self):
|
||||
@ -26,9 +27,14 @@ class TCPClient:
|
||||
|
||||
def run(self):
|
||||
while True:
|
||||
time.sleep(30)
|
||||
if (self.send_Command() and self.send_Status()):
|
||||
self.error_count=0
|
||||
time.sleep(0.2)
|
||||
self.connected = self.error_count > 0
|
||||
try:
|
||||
#time.sleep(30)
|
||||
if (self.send_Command() and self.send_Status()):
|
||||
self.error_count = 0
|
||||
except:
|
||||
self.error_count += 1
|
||||
|
||||
|
||||
def send_Command(self):
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
from Model.Position import Real_Position
|
||||
from enum import Enum
|
||||
from COM.COM_Robot import RobotClient
|
||||
from Model.RobotModel import CMDInstructRequest
|
||||
|
||||
|
||||
class FeedStatus(Enum):
|
||||
FNone = 0
|
||||
@ -39,22 +42,28 @@ class Feeding():
|
||||
def run(self):
|
||||
# 获取事件坐标
|
||||
real_position = Real_Position()
|
||||
real_position.init_position(self.robotClient.status_model.world_n[0],
|
||||
self.robotClient.status_model.world_n[1],
|
||||
self.robotClient.status_model.world_n[2],
|
||||
self.robotClient.status_model.world_n[3],
|
||||
self.robotClient.status_model.world_n[4],
|
||||
self.robotClient.status_model.world_n[5],
|
||||
self.robotClient.status_model.world_n[6]);
|
||||
# real_position.init_position(self.robotClient.status_model.world_n[0],
|
||||
# self.robotClient.status_model.world_n[1],
|
||||
# self.robotClient.status_model.world_n[2],
|
||||
# self.robotClient.status_model.world_n[3],
|
||||
# self.robotClient.status_model.world_n[4],
|
||||
# self.robotClient.status_model.world_n[5],
|
||||
# self.robotClient.status_model.world_n[6]);
|
||||
real_position.init_position(0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0);
|
||||
|
||||
|
||||
if self.feedStatus==FeedStatus.FNone:
|
||||
|
||||
pass
|
||||
elif self.feedStatus==FeedStatus.FStart:
|
||||
if self.feedConfig.num != 0:
|
||||
self.feedStatus = FeedStatus.FSafeP
|
||||
|
||||
sendTargPosition(self.feedConfig.safe_position)
|
||||
self.sendTargPosition(self.feedConfig.safe_position)
|
||||
#print(request_command)
|
||||
|
||||
pass
|
||||
@ -62,7 +71,7 @@ class Feeding():
|
||||
|
||||
if self.feedConfig.safe_position.compare(real_position):
|
||||
self.feedStatus = FeedStatus.FPhoto
|
||||
sendTargPosition(self.feedConfig.photo_position)
|
||||
self.sendTargPosition(self.feedConfig.photo_position)
|
||||
|
||||
elif self.feedStatus == FeedStatus.FPhoto:
|
||||
if self.feedConfig.photo_position.compare(real_position):
|
||||
@ -77,7 +86,7 @@ class Feeding():
|
||||
elif self.feedStatus == FeedStatus.FSafeF:
|
||||
if self.feedConfig.safe_position.compare(real_position):
|
||||
self.feedStatus = FeedStatus.FFeedP
|
||||
sendTargPosition(self.feedConfig.feed_position)
|
||||
self.sendTargPosition(self.feedConfig.feed_position)
|
||||
pass #吸嘴开始
|
||||
|
||||
|
||||
@ -88,10 +97,11 @@ class Feeding():
|
||||
self.feedStatus=FeedStatus.FNone
|
||||
else:
|
||||
self.feedStatus = FeedStatus.FSafeP
|
||||
sendTargPosition(self.feedConfig.safe_position)
|
||||
pass
|
||||
self.sendTargPosition(self.feedConfig.safe_position)
|
||||
pass
|
||||
|
||||
def sendTargPosition(self,real_position):
|
||||
from Model.RobotModel import Instruction
|
||||
position_instruction = Instruction()
|
||||
position_instruction.m0 = self.feedConfig.safe_position.X
|
||||
position_instruction.m1 = self.feedConfig.safe_position.Y
|
||||
|
||||
@ -2,6 +2,7 @@ from enum import Enum
|
||||
class Error_Code(Enum):
|
||||
SYS_SUCCESS = 100
|
||||
SYS_NETERROR = 104 #网络异常
|
||||
SYS_NONEPoint = 105
|
||||
|
||||
|
||||
class VisionError_Code(Enum):
|
||||
|
||||
163
app.py
163
app.py
@ -2,6 +2,9 @@ import configparser
|
||||
import json
|
||||
import queue
|
||||
import sys
|
||||
from multiprocessing import Process
|
||||
from PySide6.QtCore import QThread, Signal, Slot
|
||||
from PySide6.QtGui import QIntValidator
|
||||
from PySide6.QtWidgets import QApplication, QMainWindow, QPushButton
|
||||
from datetime import datetime
|
||||
from CU.Command import FeedCommand
|
||||
@ -17,17 +20,16 @@ from Model.Position import Real_Position
|
||||
from threading import Thread
|
||||
from CU.Command import Status
|
||||
|
||||
|
||||
|
||||
class MainWindow(QMainWindow,Ui_MainWindow):
|
||||
def __init__(self):
|
||||
super(MainWindow, self).__init__()
|
||||
self.setupUi(self)
|
||||
self.init_UI()
|
||||
self.init_Run()
|
||||
self.init_FeedLine()
|
||||
self.init_robot_info()
|
||||
start_Runing()
|
||||
self.init_FeedLine()
|
||||
self.start_Runing()
|
||||
|
||||
|
||||
def init_UI(self):
|
||||
self.horizontalSlider_J1.sliderReleased.connect(self.slider_valueChanged)
|
||||
@ -45,8 +47,15 @@ class MainWindow(QMainWindow,Ui_MainWindow):
|
||||
self.pushButton_AddNum.clicked.connect(self.send_addNum_button_click)
|
||||
self.pushButton_SubNum.clicked.connect(self.send_subNum_button_click)
|
||||
self.pushButton_num_free.clicked.connect(self.send_num_button_click)
|
||||
self.lineEdit_j1.returnPressed.connect(self.send_position_returnPressed)
|
||||
self.lineEdit_j2.returnPressed.connect(self.send_position_returnPressed)
|
||||
self.lineEdit_j3.returnPressed.connect(self.send_position_returnPressed)
|
||||
self.lineEdit_j4.returnPressed.connect(self.send_position_returnPressed)
|
||||
self.lineEdit_j5.returnPressed.connect(self.send_position_returnPressed)
|
||||
self.lineEdit_j6.returnPressed.connect(self.send_position_returnPressed)
|
||||
|
||||
self.lineEdit_num.returnPressed.connect(self.send_custom_num_returnPressed)
|
||||
int_validator = QIntValidator(0, 100, self)
|
||||
int_validator = QIntValidator(0, 100, self.lineEdit_num)
|
||||
self.lineEdit_num.setValidator(int_validator)
|
||||
|
||||
# self.horizontalSlider_J1.sliderReleased
|
||||
@ -58,7 +67,7 @@ class MainWindow(QMainWindow,Ui_MainWindow):
|
||||
|
||||
self.command_position_quene = Queue()
|
||||
self.status_address = DataAddress()
|
||||
self.feedLine_dict = dir()
|
||||
self.feedLine_dict = {}
|
||||
self.command_quene = Queue()
|
||||
self.main_threading = None
|
||||
|
||||
@ -66,65 +75,67 @@ class MainWindow(QMainWindow,Ui_MainWindow):
|
||||
ip = self.configReader.get('Robot_Feed', 'IPAddress')
|
||||
port = int(self.configReader.get('Robot_Feed', 'Port'))
|
||||
self.robotClient = RobotClient(ip, port, self.command_position_quene, self.status_address)
|
||||
self.feeding = Feeding(self.robotClient) # 临时
|
||||
self.last_time=time.time()
|
||||
try:
|
||||
self.robotClient.CreatConnect()
|
||||
except:
|
||||
self.set_label_status_style(False)
|
||||
return Error_Code.SYS_NETERROR
|
||||
|
||||
if self.robotClient.is_Connect():
|
||||
if self.robotClient.connected:
|
||||
return 0
|
||||
else:
|
||||
return Error_Code.NETERROR
|
||||
self.feeding = Feeding(self.robotClient) #临时
|
||||
return Error_Code.SYS_NETERROR
|
||||
|
||||
|
||||
def init_FeedLine(self):
|
||||
line_count = self.configReader.get('Robot_Feed', 'LineCount', fallback=0)
|
||||
self.configReader.read('Config/FeedLine.ini')
|
||||
for i in range(line_count):
|
||||
for i in range(int(line_count)):
|
||||
line_str = f'FeedLine{i+1}'
|
||||
safe_position = Real_Position()
|
||||
photo_position = Real_Position()
|
||||
feed_position = Real_Position()
|
||||
|
||||
safe_position.X = self.configReader.get(line_str, 'SafePosition_x', fallback=0)
|
||||
safe_position.Y = self.configReader.get(line_str, 'SafePosition_y', fallback=0)
|
||||
safe_position.Z = self.configReader.get(line_str, 'SafePosition_z', fallback=0)
|
||||
safe_position.U = self.configReader.get(line_str, 'SafePosition_u', fallback=0)
|
||||
safe_position.V = self.configReader.get(line_str, 'SafePosition_v', fallback=0)
|
||||
safe_position.W = self.configReader.get(line_str, 'SafePosition_w', fallback=0)
|
||||
safe_position.X = int(self.configReader.get(line_str, 'SafePosition_x', fallback=0))
|
||||
safe_position.Y = int(self.configReader.get(line_str, 'SafePosition_y', fallback=0))
|
||||
safe_position.Z = int(self.configReader.get(line_str, 'SafePosition_z', fallback=0))
|
||||
safe_position.U = int(self.configReader.get(line_str, 'SafePosition_u', fallback=0))
|
||||
safe_position.V = int(self.configReader.get(line_str, 'SafePosition_v', fallback=0))
|
||||
safe_position.W = int(self.configReader.get(line_str, 'SafePosition_w', fallback=0))
|
||||
|
||||
photo_position.X = self.configReader.get(line_str, 'PhotoPosition_x', fallback=0)
|
||||
photo_position.Y = self.configReader.get(line_str, 'PhotoPosition_y', fallback=0)
|
||||
photo_position.Z = self.configReader.get(line_str, 'PhotoPosition_z', fallback=0)
|
||||
photo_position.U = self.configReader.get(line_str, 'PhotoPosition_u', fallback=0)
|
||||
photo_position.V = self.configReader.get(line_str, 'PhotoPosition_v', fallback=0)
|
||||
photo_position.W = self.configReader.get(line_str, 'PhotoPosition_w', fallback=0)
|
||||
photo_position.X = int(self.configReader.get(line_str, 'PhotoPosition_x', fallback=0))
|
||||
photo_position.Y = int(self.configReader.get(line_str, 'PhotoPosition_y', fallback=0))
|
||||
photo_position.Z = int(self.configReader.get(line_str, 'PhotoPosition_z', fallback=0))
|
||||
photo_position.U = int(self.configReader.get(line_str, 'PhotoPosition_u', fallback=0))
|
||||
photo_position.V = int(self.configReader.get(line_str, 'PhotoPosition_v', fallback=0))
|
||||
photo_position.W = int(self.configReader.get(line_str, 'PhotoPosition_w', fallback=0))
|
||||
|
||||
|
||||
feed_position.X = self.configReader.get(line_str, 'FeedPosition_x', fallback=0)
|
||||
feed_position.Y = self.configReader.get(line_str, 'FeedPosition_y', fallback=0)
|
||||
feed_position.Z = self.configReader.get(line_str, 'FeedPosition_z', fallback=0)
|
||||
feed_position.U = self.configReader.get(line_str, 'FeedPosition_u', fallback=0)
|
||||
feed_position.V = self.configReader.get(line_str, 'FeedPosition_v', fallback=0)
|
||||
feed_position.W = self.configReader.get(line_str, 'FeedPosition_w', fallback=0)
|
||||
feed_position.X = int(self.configReader.get(line_str, 'FeedPosition_x', fallback=0))
|
||||
feed_position.Y = int(self.configReader.get(line_str, 'FeedPosition_y', fallback=0))
|
||||
feed_position.Z = int(self.configReader.get(line_str, 'FeedPosition_z', fallback=0))
|
||||
feed_position.U = int(self.configReader.get(line_str, 'FeedPosition_u', fallback=0))
|
||||
feed_position.V = int(self.configReader.get(line_str, 'FeedPosition_v', fallback=0))
|
||||
feed_position.W = int(self.configReader.get(line_str, 'FeedPosition_w', fallback=0))
|
||||
|
||||
self.feedLine_dict[str(i+1)] = FeedLine(safe_position, photo_position, feed_position)
|
||||
|
||||
pass
|
||||
|
||||
def init_robot_info(self):
|
||||
j1_min = int(self.configReader.get('Robot', 'j1_min'))
|
||||
j1_max = int(self.configReader.get('Robot', 'j1_max'))
|
||||
j2_min = int(self.configReader.get('Robot', 'j2_min'))
|
||||
j2_max = int(self.configReader.get('Robot', 'j2_max'))
|
||||
j3_min = int(self.configReader.get('Robot', 'j3_min'))
|
||||
j3_max = int(self.configReader.get('Robot', 'j3_max'))
|
||||
j4_min = int(self.configReader.get('Robot', 'j4_min'))
|
||||
j4_max = int(self.configReader.get('Robot', 'j4_max'))
|
||||
j5_min = int(self.configReader.get('Robot', 'j5_min'))
|
||||
j5_max = int(self.configReader.get('Robot', 'j5_max'))
|
||||
j6_min = int(self.configReader.get('Robot', 'j6_min'))
|
||||
j6_max = int(self.configReader.get('Robot', 'j6_max'))
|
||||
j1_min = int(self.configReader.get('Robot_Feed', 'j1_min'))
|
||||
j1_max = int(self.configReader.get('Robot_Feed', 'j1_max'))
|
||||
j2_min = int(self.configReader.get('Robot_Feed', 'j2_min'))
|
||||
j2_max = int(self.configReader.get('Robot_Feed', 'j2_max'))
|
||||
j3_min = int(self.configReader.get('Robot_Feed', 'j3_min'))
|
||||
j3_max = int(self.configReader.get('Robot_Feed', 'j3_max'))
|
||||
j4_min = int(self.configReader.get('Robot_Feed', 'j4_min'))
|
||||
j4_max = int(self.configReader.get('Robot_Feed', 'j4_max'))
|
||||
j5_min = int(self.configReader.get('Robot_Feed', 'j5_min'))
|
||||
j5_max = int(self.configReader.get('Robot_Feed', 'j5_max'))
|
||||
j6_min = int(self.configReader.get('Robot_Feed', 'j6_min'))
|
||||
j6_max = int(self.configReader.get('Robot_Feed', 'j6_max'))
|
||||
self.horizontalSlider_J1.setMinimum(j1_min)
|
||||
self.horizontalSlider_J1.setMaximum(j1_max)
|
||||
self.horizontalSlider_J2.setMinimum(j2_min)
|
||||
@ -151,9 +162,14 @@ class MainWindow(QMainWindow,Ui_MainWindow):
|
||||
self.label_j6_max.setText(str(j6_max))
|
||||
|
||||
def start_Runing(self):
|
||||
self.main_threading = Thread(target=run)
|
||||
self.main_threading = Thread(target=self.run)
|
||||
self.robot_connect_threading = Thread(target=self.robotClient.run)
|
||||
self.main_threading.start()
|
||||
|
||||
|
||||
self.robot_connect_threading.start()
|
||||
pass
|
||||
|
||||
def send_startFeed_button_click(self):
|
||||
num = self.horizontalSlider_feedingNum.value()
|
||||
line_index = str(self.comboBox_lineIndex.currentIndex()+1)
|
||||
@ -165,6 +181,7 @@ class MainWindow(QMainWindow,Ui_MainWindow):
|
||||
if button.text() != "自定义":
|
||||
num = int(button.text())
|
||||
self.horizontalSlider_feedingNum.setMaximum(num)
|
||||
self.label_maxNum.setText(str(num))
|
||||
self.horizontalSlider_feedingNum.setValue(0)
|
||||
else:
|
||||
self.pushButton_num_free.hide()
|
||||
@ -180,14 +197,16 @@ class MainWindow(QMainWindow,Ui_MainWindow):
|
||||
def send_custom_num_returnPressed(self):
|
||||
self.pushButton_num_free.show()
|
||||
self.lineEdit_num.hide()
|
||||
self.horizontalSlider_feedingNum.setValue(int(self.lineEdit_num.text()))
|
||||
self.horizontalSlider_feedingNum.setMaximum(int(self.lineEdit_num.text()))
|
||||
self.horizontalSlider_feedingNum.setValue(0)
|
||||
self.label_maxNum.setText(self.lineEdit_num.text())
|
||||
|
||||
def slider_valueChanged(self):
|
||||
global last_time
|
||||
|
||||
now_time = time.time()
|
||||
if(now_time-last_time) < 2:
|
||||
if(now_time-self.last_time) < 2:
|
||||
return
|
||||
last_time = now_time
|
||||
self.last_time = now_time
|
||||
position_instruction = Instruction()
|
||||
position_instruction.m0 = self.horizontalSlider_J1.value()
|
||||
position_instruction.m1 = self.horizontalSlider_J2.value()
|
||||
@ -196,12 +215,14 @@ class MainWindow(QMainWindow,Ui_MainWindow):
|
||||
position_instruction.m4 = self.horizontalSlider_J5.value()
|
||||
position_instruction.m5 = self.horizontalSlider_J6.value()
|
||||
|
||||
self.textEdit_j1.setText(str(self.horizontalSlider_J1.value()))
|
||||
self.textEdit_j2.setText(str(self.horizontalSlider_J2.value()))
|
||||
self.textEdit_j3.setText(str(self.horizontalSlider_J3.value()))
|
||||
self.textEdit_j4.setText(str(self.horizontalSlider_J4.value()))
|
||||
self.textEdit_j5.setText(str(self.horizontalSlider_J5.value()))
|
||||
self.textEdit_j6.setText(str(self.horizontalSlider_J6.value()))
|
||||
|
||||
|
||||
self.lineEdit_j1.setText(str(self.horizontalSlider_J1.value()))
|
||||
self.lineEdit_j2.setText(str(self.horizontalSlider_J2.value()))
|
||||
self.lineEdit_j3.setText(str(self.horizontalSlider_J3.value()))
|
||||
self.lineEdit_j4.setText(str(self.horizontalSlider_J4.value()))
|
||||
self.lineEdit_j5.setText(str(self.horizontalSlider_J5.value()))
|
||||
self.lineEdit_j6.setText(str(self.horizontalSlider_J6.value()))
|
||||
|
||||
instruction_command = CMDInstructRequest()
|
||||
instruction_command.instructions.append(vars(position_instruction))
|
||||
@ -219,7 +240,27 @@ class MainWindow(QMainWindow,Ui_MainWindow):
|
||||
# request_command = vars(cmd_command)
|
||||
# self.robotClient.add_sendQuene(request_command)
|
||||
return
|
||||
def send_position_returnPressed(self):
|
||||
position_instruction = Instruction()
|
||||
position_instruction.m0 = int(self.lineEdit_j1.text())
|
||||
position_instruction.m1 = int(self.lineEdit_j2.text())
|
||||
position_instruction.m2 = int(self.lineEdit_j3.text())
|
||||
position_instruction.m3 = int(self.lineEdit_j4.text())
|
||||
position_instruction.m4 = int(self.lineEdit_j5.text())
|
||||
position_instruction.m5 = int(self.lineEdit_j6.text())
|
||||
|
||||
self.horizontalSlider_J1.setValue(int(self.lineEdit_j1.text()))
|
||||
self.horizontalSlider_J2.setValue(int(self.lineEdit_j2.text()))
|
||||
self.horizontalSlider_J3.setValue(int(self.lineEdit_j3.text()))
|
||||
self.horizontalSlider_J4.setValue(int(self.lineEdit_j4.text()))
|
||||
self.horizontalSlider_J5.setValue(int(self.lineEdit_j5.text()))
|
||||
self.horizontalSlider_J6.setValue(int(self.lineEdit_j6.text()))
|
||||
|
||||
instruction_command = CMDInstructRequest()
|
||||
instruction_command.instructions.append(vars(position_instruction))
|
||||
request_command = vars(instruction_command)
|
||||
print(request_command)
|
||||
self.robotClient.add_sendQuene(request_command)
|
||||
|
||||
|
||||
|
||||
@ -229,7 +270,7 @@ class MainWindow(QMainWindow,Ui_MainWindow):
|
||||
|
||||
def run(self):
|
||||
while True:
|
||||
|
||||
time.sleep(0.2)
|
||||
if not self.command_quene.empty():
|
||||
command = self.command_quene.get()
|
||||
if isinstance(command, FeedCommand) and command.status == Status.Prepareing:
|
||||
@ -238,18 +279,21 @@ class MainWindow(QMainWindow,Ui_MainWindow):
|
||||
self.feeding.feedStatus = FeedStatus.FStart
|
||||
command.status = Status.Runing
|
||||
|
||||
|
||||
self.feeding.run()
|
||||
updateUI(self)
|
||||
try:
|
||||
self.feeding.run()
|
||||
except:
|
||||
print(Error_Code.SYS_NONEPoint)
|
||||
self.updateUI()
|
||||
|
||||
#pass #主线程
|
||||
|
||||
def updateUI(self):
|
||||
if self.robotClient.is_Connect():
|
||||
if self.robotClient.connected:
|
||||
self.set_label_status_style(True)
|
||||
else:
|
||||
self.set_label_status_style(False)
|
||||
self.horizontalSlider_feedingNum.setValue(self.horizontalSlider_feedingNum.maximum()-self.feeding.feedConfig.num)
|
||||
if self.feeding.feedStatus != FeedStatus.FNone:
|
||||
self.horizontalSlider_feedingNum.setValue(self.horizontalSlider_feedingNum.maximum()-self.feeding.feedConfig.num)
|
||||
if self.horizontalSlider_feedingNum.value() == 0:
|
||||
self.stackedWidget_num.setCurrentIndex(0)
|
||||
else:
|
||||
@ -258,8 +302,7 @@ class MainWindow(QMainWindow,Ui_MainWindow):
|
||||
self.label_date.setText(datetime.now().strftime("%Y-%m-%d"))
|
||||
self.label_time.setText(datetime.now().strftime("%H:%M:%S"))
|
||||
|
||||
def set_label_status_style(self,connected:bool):
|
||||
palette = self.label_connect_status.palette()
|
||||
def set_label_status_style(self, connected: bool):
|
||||
if connected:
|
||||
self.label_connect_status.setStyleSheet("""
|
||||
QLabel {
|
||||
|
||||
49900
resources_rc.py
49900
resources_rc.py
File diff suppressed because it is too large
Load Diff
73
test.py
73
test.py
@ -0,0 +1,73 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import time
|
||||
|
||||
import requests
|
||||
|
||||
from PySide6.QtCore import (QThread, Signal, Slot, QSize)
|
||||
from PySide6.QtWidgets import (QApplication, QPushButton, QLabel, QVBoxLayout, QWidget)
|
||||
class WorkerThread(QThread):
|
||||
# 定义一个信号,用于在线程中发送数据给主线程
|
||||
update_label = Signal(str)
|
||||
|
||||
def run(self):
|
||||
while True:
|
||||
for i in range(5):
|
||||
time.sleep(2) # 模拟耗时操作
|
||||
self.update_label.emit(f"{i + 1}")
|
||||
|
||||
class MyThread(QThread):
|
||||
signal_tuple = Signal(tuple)
|
||||
|
||||
|
||||
def run(self):
|
||||
while True:
|
||||
for idx in range(1, 10):
|
||||
time.sleep(2)
|
||||
# 任务完成后发出信号
|
||||
self.signal_tuple.emit((idx, ''))
|
||||
|
||||
|
||||
class MainWindow(QWidget):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent=parent)
|
||||
self.setup_ui()
|
||||
#
|
||||
self.button.clicked.connect(self.setup_thread)
|
||||
|
||||
def setup_ui(self):
|
||||
self.setWindowTitle('demo')
|
||||
self.resize(QSize(250, 180))
|
||||
# 创建一个垂直布局
|
||||
layout = QVBoxLayout()
|
||||
# 创建一个标签
|
||||
self.label = QLabel('This is a label => ')
|
||||
layout.addWidget(self.label)
|
||||
# 创建一个按钮
|
||||
self.button = QPushButton('Send Request')
|
||||
layout.addWidget(self.button)
|
||||
# 将布局设置为主窗口的布局
|
||||
self.setLayout(layout)
|
||||
# 显示窗口
|
||||
self.show()
|
||||
|
||||
def setup_thread(self):
|
||||
self.thread_ = MyThread()
|
||||
self.thread_.signal_tuple.connect(self.thread_finished)
|
||||
self.thread_.start()
|
||||
|
||||
def send_request(self):
|
||||
return requests.get('https://www.csdn.net/').text[:15]
|
||||
|
||||
@Slot(tuple)
|
||||
def thread_finished(self, item):
|
||||
self.label.setText('This is a label => ' + str(item))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app = QApplication([])
|
||||
window = MainWindow()
|
||||
window.show()
|
||||
app.exec()
|
||||
|
||||
|
||||
@ -86,7 +86,8 @@ class Ui_MainWindow(object):
|
||||
self.label_4 = QLabel(self.frame_3)
|
||||
self.label_4.setObjectName(u"label_4")
|
||||
self.label_4.setGeometry(QRect(10, 10, 481, 261))
|
||||
self.label_4.setStyleSheet(u"border-image: url(:bg/Image/robot.png);\n"
|
||||
self.label_4.setStyleSheet(u"\n"
|
||||
"background-image: url(:/bg/Image/robot.png);\n"
|
||||
"background-position:center;\n"
|
||||
"background-repeat:no-repeat;")
|
||||
self.label_4.setScaledContents(True)
|
||||
@ -163,10 +164,10 @@ class Ui_MainWindow(object):
|
||||
"\n"
|
||||
"")
|
||||
self.horizontalSlider_feedingNum.setOrientation(Qt.Orientation.Horizontal)
|
||||
self.label_5 = QLabel(self.frame_3)
|
||||
self.label_5.setObjectName(u"label_5")
|
||||
self.label_5.setGeometry(QRect(800, 160, 31, 21))
|
||||
self.label_5.setStyleSheet(u"font: 9pt \"\u6977\u4f53\";")
|
||||
self.label_maxNum = QLabel(self.frame_3)
|
||||
self.label_maxNum.setObjectName(u"label_maxNum")
|
||||
self.label_maxNum.setGeometry(QRect(800, 160, 31, 21))
|
||||
self.label_maxNum.setStyleSheet(u"font: 9pt \"\u6977\u4f53\";")
|
||||
self.frame_4 = QFrame(self.frame_3)
|
||||
self.frame_4.setObjectName(u"frame_4")
|
||||
self.frame_4.setGeometry(QRect(500, 200, 331, 251))
|
||||
@ -451,11 +452,29 @@ class Ui_MainWindow(object):
|
||||
"}\n"
|
||||
"")
|
||||
self.pushButton_38.setIcon(icon)
|
||||
self.lineEdit_j1 = QLineEdit(self.frame_4)
|
||||
self.lineEdit_j1.setObjectName(u"lineEdit_j1")
|
||||
self.lineEdit_j1.setGeometry(QRect(140, 3, 41, 21))
|
||||
self.lineEdit_j2 = QLineEdit(self.frame_4)
|
||||
self.lineEdit_j2.setObjectName(u"lineEdit_j2")
|
||||
self.lineEdit_j2.setGeometry(QRect(140, 41, 41, 21))
|
||||
self.lineEdit_j3 = QLineEdit(self.frame_4)
|
||||
self.lineEdit_j3.setObjectName(u"lineEdit_j3")
|
||||
self.lineEdit_j3.setGeometry(QRect(140, 82, 41, 21))
|
||||
self.lineEdit_j4 = QLineEdit(self.frame_4)
|
||||
self.lineEdit_j4.setObjectName(u"lineEdit_j4")
|
||||
self.lineEdit_j4.setGeometry(QRect(140, 120, 41, 21))
|
||||
self.lineEdit_j5 = QLineEdit(self.frame_4)
|
||||
self.lineEdit_j5.setObjectName(u"lineEdit_j5")
|
||||
self.lineEdit_j5.setGeometry(QRect(140, 162, 41, 21))
|
||||
self.lineEdit_j6 = QLineEdit(self.frame_4)
|
||||
self.lineEdit_j6.setObjectName(u"lineEdit_j6")
|
||||
self.lineEdit_j6.setGeometry(QRect(140, 200, 41, 21))
|
||||
self.textEdit_log = QTextEdit(self.frame_3)
|
||||
self.textEdit_log.setObjectName(u"textEdit_log")
|
||||
self.textEdit_log.setGeometry(QRect(10, 280, 481, 171))
|
||||
self.textEdit_log.setStyleSheet(u"*{\n"
|
||||
" \n"
|
||||
" background-image: url(:/bg/Image/robot.png);\n"
|
||||
" background-color: #E6ECF5;\n"
|
||||
"}")
|
||||
self.comboBox_lineIndex = QComboBox(self.frame_3)
|
||||
@ -815,7 +834,7 @@ class Ui_MainWindow(object):
|
||||
self.pushButton_4.setText(QCoreApplication.translate("MainWindow", u"\u6295\u6599\u8bbe\u7f6e", None))
|
||||
self.pushButton_5.setText(QCoreApplication.translate("MainWindow", u"IO\u8c03\u8bd5", None))
|
||||
self.label_4.setText("")
|
||||
self.label_5.setText(QCoreApplication.translate("MainWindow", u"10", None))
|
||||
self.label_maxNum.setText(QCoreApplication.translate("MainWindow", u"10", None))
|
||||
self.label_j1_min.setText(QCoreApplication.translate("MainWindow", u"-10", None))
|
||||
self.label_j1_max.setText(QCoreApplication.translate("MainWindow", u"+10", None))
|
||||
self.label_j2_min.setText(QCoreApplication.translate("MainWindow", u"-150", None))
|
||||
@ -866,7 +885,8 @@ class Ui_MainWindow(object):
|
||||
self.pushButton_num4.setText(QCoreApplication.translate("MainWindow", u"40", None))
|
||||
self.pushButton_num_free.setText(QCoreApplication.translate("MainWindow", u"\u81ea\u5b9a\u4e49", None))
|
||||
self.pushButton_num2.setText(QCoreApplication.translate("MainWindow", u"20", None))
|
||||
self.lineEdit_num.setText(QCoreApplication.translate("MainWindow", u"123", None))
|
||||
self.lineEdit_num.setText("")
|
||||
self.lineEdit_num.setPlaceholderText(QCoreApplication.translate("MainWindow", u"0-100", None))
|
||||
self.pushButton_AddNum.setText(QCoreApplication.translate("MainWindow", u"\u8865\u4e00\u888b", None))
|
||||
self.pushButton_SubNum.setText(QCoreApplication.translate("MainWindow", u"\u6263\u4e00\u888b", None))
|
||||
self.pushButton_16.setText(QCoreApplication.translate("MainWindow", u"\u6025\u505c", None))
|
||||
|
||||
72
untitled.ui
72
untitled.ui
@ -169,7 +169,8 @@ border-radius: 10px;</string>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">border-image: url(:bg/Image/robot.png);
|
||||
<string notr="true">
|
||||
background-image: url(:/bg/Image/robot.png);
|
||||
background-position:center;
|
||||
background-repeat:no-repeat;</string>
|
||||
</property>
|
||||
@ -263,7 +264,7 @@ QSlider::sub-page:horizontal
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<widget class="QLabel" name="label_maxNum">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>800</x>
|
||||
@ -987,6 +988,66 @@ font: 10pt "楷体";
|
||||
<iconset theme="QIcon::ThemeIcon::ListAdd"/>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_j1">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>140</x>
|
||||
<y>3</y>
|
||||
<width>41</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_j2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>140</x>
|
||||
<y>41</y>
|
||||
<width>41</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_j3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>140</x>
|
||||
<y>82</y>
|
||||
<width>41</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_j4">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>140</x>
|
||||
<y>120</y>
|
||||
<width>41</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_j5">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>140</x>
|
||||
<y>162</y>
|
||||
<width>41</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_j6">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>140</x>
|
||||
<y>200</y>
|
||||
<width>41</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QTextEdit" name="textEdit_log">
|
||||
<property name="geometry">
|
||||
@ -999,7 +1060,7 @@ font: 10pt "楷体";
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">*{
|
||||
|
||||
background-image: url(:/bg/Image/robot.png);
|
||||
background-color: #E6ECF5;
|
||||
}</string>
|
||||
</property>
|
||||
@ -1294,11 +1355,14 @@ border-radius: 10px;
|
||||
font: 10pt "楷体";</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>123</string>
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignmentFlag::AlignCenter</set>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>0-100</string>
|
||||
</property>
|
||||
</widget>
|
||||
<zorder>lineEdit_num</zorder>
|
||||
<zorder>pushButton_num5</zorder>
|
||||
|
||||
Reference in New Issue
Block a user