62 lines
2.0 KiB
Python
62 lines
2.0 KiB
Python
from PySide6.QtWidgets import (
|
|
QApplication, QWidget, QHBoxLayout, QVBoxLayout, QPushButton,
|
|
QLineEdit, QLabel, QGroupBox, QSpacerItem, QSizePolicy
|
|
)
|
|
from PySide6.QtGui import QIcon
|
|
from PySide6.QtCore import Qt
|
|
|
|
class OptimizedUI(QWidget):
|
|
def __init__(self):
|
|
super().__init__()
|
|
|
|
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)
|
|
|
|
# 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)
|
|
window = OptimizedUI()
|
|
window.show()
|
|
sys.exit(app.exec())
|