格式统一
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Step6 面板 - 光谱特征提取 (完美对齐无跳动重构版)
|
||||
Step6 面板 - 光谱特征提取 (极致强迫症绝对左对齐版)
|
||||
"""
|
||||
|
||||
import os
|
||||
@ -64,26 +64,27 @@ class Step6FeaturePanel(QWidget):
|
||||
"去耀斑影像:",
|
||||
"Image Files (*.bsq *.dat *.tif);;All Files (*.*)"
|
||||
)
|
||||
self.deglint_img_file.label.setMinimumWidth(100)
|
||||
# FileSelectWidget 内部已经处理了左侧宽度,我们这里强制设为120对齐
|
||||
self.deglint_img_file.label.setMinimumWidth(120)
|
||||
|
||||
self.csv_file = FileSelectWidget(
|
||||
"处理后CSV:",
|
||||
"CSV Files (*.csv);;All Files (*.*)"
|
||||
)
|
||||
self.csv_file.label.setMinimumWidth(100)
|
||||
self.csv_file.label.setMinimumWidth(120)
|
||||
|
||||
self.water_mask_file = FileSelectWidget(
|
||||
"水体掩膜:",
|
||||
"Mask Files (*.dat *.tif);;All Files (*.*)"
|
||||
)
|
||||
self.water_mask_file.label.setMinimumWidth(100)
|
||||
self.water_mask_file.label.setMinimumWidth(120)
|
||||
self.water_mask_file.line_edit.setPlaceholderText("可选,如不选择则自动生成")
|
||||
|
||||
self.glint_mask_file = FileSelectWidget(
|
||||
"耀斑掩膜:",
|
||||
"Mask Files (*.dat *.tif);;All Files (*.*)"
|
||||
)
|
||||
self.glint_mask_file.label.setMinimumWidth(100)
|
||||
self.glint_mask_file.label.setMinimumWidth(120)
|
||||
|
||||
input_layout.addWidget(self.deglint_img_file)
|
||||
input_layout.addWidget(self.csv_file)
|
||||
@ -94,25 +95,26 @@ class Step6FeaturePanel(QWidget):
|
||||
main_layout.addWidget(input_group)
|
||||
|
||||
# ==========================================
|
||||
# 卡片 2:提取参数
|
||||
# 卡片 2:提取参数 (强迫症像素级对齐)
|
||||
# ==========================================
|
||||
params_group = QGroupBox("⚙️ 提取参数")
|
||||
params_layout = QFormLayout()
|
||||
params_layout = QVBoxLayout() # 废除 QFormLayout,使用可控的垂直布局
|
||||
params_layout.setSpacing(16)
|
||||
params_layout.setContentsMargins(20, 24, 20, 20)
|
||||
|
||||
self.radius = QSpinBox()
|
||||
self.radius.setRange(1, 50)
|
||||
self.radius.setValue(5)
|
||||
self.radius.setSuffix(" px")
|
||||
self.radius.setButtonSymbols(QSpinBox.NoButtons)
|
||||
self._add_row_with_fixed_label(params_layout, "采样半径:", self.radius)
|
||||
self.radius.setAlignment(Qt.AlignLeft | Qt.AlignVCenter) # 强制数字靠左
|
||||
self._add_aligned_row(params_layout, "采样半径:", self.radius, "px")
|
||||
|
||||
self.source_epsg = QSpinBox()
|
||||
self.source_epsg.setRange(1000, 99999)
|
||||
self.source_epsg.setValue(4326)
|
||||
self.source_epsg.setButtonSymbols(QSpinBox.NoButtons)
|
||||
self._add_row_with_fixed_label(params_layout, "源坐标系 EPSG:", self.source_epsg)
|
||||
self.source_epsg.setAlignment(Qt.AlignLeft | Qt.AlignVCenter) # 强制数字靠左
|
||||
self._add_aligned_row(params_layout, "源坐标系 EPSG:", self.source_epsg, "")
|
||||
|
||||
params_group.setLayout(params_layout)
|
||||
main_layout.addWidget(params_group)
|
||||
@ -130,7 +132,7 @@ class Step6FeaturePanel(QWidget):
|
||||
"CSV Files (*.csv);;All Files (*.*)",
|
||||
mode="save"
|
||||
)
|
||||
self.output_file.label.setMinimumWidth(100)
|
||||
self.output_file.label.setMinimumWidth(120) # 统一 120px 对齐
|
||||
self.output_file.line_edit.setPlaceholderText("training_spectra.csv")
|
||||
output_layout.addWidget(self.output_file)
|
||||
|
||||
@ -150,20 +152,29 @@ class Step6FeaturePanel(QWidget):
|
||||
main_layout.addStretch()
|
||||
self.setLayout(main_layout)
|
||||
|
||||
def _add_row_with_fixed_label(self, form_layout, label_text, widget):
|
||||
"""辅助方法:创建绝对锁死宽度的对齐行"""
|
||||
lbl = QLabel(label_text)
|
||||
lbl.setMinimumWidth(100)
|
||||
|
||||
def _add_aligned_row(self, parent_layout, label_text, widget, suffix_text):
|
||||
"""核心对齐函数:隐形占位符实现绝对边缘对齐,且标签绝对靠左"""
|
||||
row_layout = QHBoxLayout()
|
||||
row_layout.setContentsMargins(0, 0, 0, 0)
|
||||
row_layout.setSpacing(10)
|
||||
|
||||
# 1. 统一左侧标签宽度为 120px,并强制内容靠左对齐
|
||||
lbl = QLabel(label_text)
|
||||
lbl.setMinimumWidth(120)
|
||||
lbl.setAlignment(Qt.AlignLeft | Qt.AlignVCenter) # 强制靠左!
|
||||
row_layout.addWidget(lbl)
|
||||
|
||||
if hasattr(widget, 'setSizePolicy'):
|
||||
widget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
|
||||
|
||||
# 2. 允许控件水平拉伸,填充满宽
|
||||
widget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
|
||||
widget.setStyleSheet("min-height: 28px;")
|
||||
row_layout.addWidget(widget)
|
||||
form_layout.addRow(row_layout)
|
||||
|
||||
# 3. 隐形占位符:强制挤压 40px 的空间,让右侧边界绝对整齐
|
||||
suffix_lbl = QLabel(suffix_text)
|
||||
suffix_lbl.setFixedWidth(40)
|
||||
row_layout.addWidget(suffix_lbl)
|
||||
|
||||
parent_layout.addLayout(row_layout)
|
||||
|
||||
def get_config(self):
|
||||
"""获取配置"""
|
||||
|
||||
Reference in New Issue
Block a user