☢️ update 初步更新投料框架
This commit is contained in:
@ -1,42 +1,61 @@
|
||||
import sys
|
||||
import time
|
||||
from PySide6.QtWidgets import (
|
||||
QApplication, QWidget, QHBoxLayout, QVBoxLayout, QPushButton,
|
||||
QLineEdit, QLabel, QGroupBox, QSpacerItem, QSizePolicy
|
||||
)
|
||||
from PySide6.QtGui import QIcon
|
||||
from PySide6.QtCore import Qt
|
||||
|
||||
from PySide6.QtCore import QThread, Signal, Slot
|
||||
from PySide6.QtWidgets import QMainWindow, QApplication, QLineEdit
|
||||
|
||||
from ui_untitled import Ui_MainWindow
|
||||
|
||||
|
||||
class WorkerThread(QThread):
|
||||
# 定义一个信号,用于在计数完成后发送结果到主线程
|
||||
result_signal = Signal(int)
|
||||
finished = Signal()
|
||||
|
||||
def run(self):
|
||||
count = 0
|
||||
for i in range(1, 11):
|
||||
count += i
|
||||
time.sleep(1) # 模拟耗时操作
|
||||
self.result_signal.emit(count)
|
||||
# 发射信号
|
||||
|
||||
self.finished.emit()
|
||||
|
||||
|
||||
class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
class OptimizedUI(QWidget):
|
||||
def __init__(self):
|
||||
super(MainWindow, self).__init__()
|
||||
self.setupUi(self)
|
||||
#self.line = QLineEdit("设置")
|
||||
super().__init__()
|
||||
|
||||
# self.btn_1.clicked.connect(self.start_count)
|
||||
self.setWindowTitle("UI Optimization")
|
||||
self.setFixedSize(600, 150)
|
||||
self.init_ui()
|
||||
|
||||
# 创建并启动后台线程
|
||||
def init_ui(self):
|
||||
# 主布局
|
||||
main_layout = QHBoxLayout(self)
|
||||
main_layout.setSpacing(10)
|
||||
|
||||
# 1. 坐标输入框组
|
||||
coord_group = QGroupBox("坐标")
|
||||
coord_layout = QVBoxLayout()
|
||||
for _ in range(2): # 两行坐标输入
|
||||
row_layout = QHBoxLayout()
|
||||
for label in ["x", "y", "z"]:
|
||||
row_layout.addWidget(QLineEdit(), 1)
|
||||
coord_layout.addLayout(row_layout)
|
||||
coord_group.setLayout(coord_layout)
|
||||
|
||||
if __name__ == '__main__':
|
||||
# 2. 功能按钮组
|
||||
button_layout = QVBoxLayout()
|
||||
get_btn = QPushButton("获取位置")
|
||||
save_btn = QPushButton("保存位置")
|
||||
for btn in [get_btn, save_btn]:
|
||||
btn.setStyleSheet("background-color: #a8e6cf; border-radius: 5px;")
|
||||
button_layout.addWidget(btn)
|
||||
|
||||
# 3. 右侧操作按钮
|
||||
add_point_btn = QPushButton("添加中间点")
|
||||
add_point_btn.setIcon(QIcon.fromTheme("list-add"))
|
||||
add_point_btn.setStyleSheet("background-color: #61c0bf; border-radius: 5px; color: white;")
|
||||
dropdown_btn = QPushButton("▼")
|
||||
dropdown_btn.setFixedWidth(30)
|
||||
|
||||
right_layout = QHBoxLayout()
|
||||
right_layout.addWidget(add_point_btn)
|
||||
right_layout.addWidget(dropdown_btn)
|
||||
|
||||
# 添加控件到主布局
|
||||
main_layout.addWidget(QPushButton("破碎点"), 1)
|
||||
main_layout.addWidget(coord_group, 3)
|
||||
main_layout.addLayout(button_layout, 2)
|
||||
main_layout.addLayout(right_layout, 2)
|
||||
|
||||
if __name__ == "__main__":
|
||||
import sys
|
||||
app = QApplication(sys.argv)
|
||||
win = MainWindow()
|
||||
win.show()
|
||||
app.exec()
|
||||
|
||||
window = OptimizedUI()
|
||||
window.show()
|
||||
sys.exit(app.exec())
|
||||
|
||||
Reference in New Issue
Block a user