from PyQt6.QtWidgets import (QGroupBox, QVBoxLayout, QHBoxLayout, QLabel, QLineEdit, QPushButton, QFileDialog) class InputGroup(QGroupBox): """输入设置组件""" def __init__(self, title="输入设置", parent=None): super().__init__(title, parent) self.init_ui() def init_ui(self): layout = QVBoxLayout(self) # 模板文件选择 template_layout = QHBoxLayout() template_layout.addWidget(QLabel("配置文件:")) self.template_path = QLineEdit() template_layout.addWidget(self.template_path) template_btn = QPushButton("浏览...") template_btn.clicked.connect(self.browse_template) template_layout.addWidget(template_btn) layout.addLayout(template_layout) # 数据源选择 data_layout = QHBoxLayout() data_layout.addWidget(QLabel("数据源:")) self.data_source = QLineEdit() data_layout.addWidget(self.data_source) data_btn = QPushButton("浏览...") data_btn.clicked.connect(self.browse_data_source) data_layout.addWidget(data_btn) layout.addLayout(data_layout) def browse_template(self): """浏览选择模板文件""" file_path, _ = QFileDialog.getOpenFileName( self, "选择模板文件", "", "ArcGIS Pro Project (*.aprx);;All Files (*.*)" ) if file_path: self.template_path.setText(file_path) def browse_data_source(self): """浏览选择数据源""" dir_path = QFileDialog.getExistingDirectory( self, "选择数据源目录" ) if dir_path: self.data_source.setText(dir_path) def get_template_path(self): """获取模板文件路径""" return self.template_path.text() def get_data_source(self): """获取数据源路径""" return self.data_source.text() def clear(self): """清除输入""" self.template_path.clear() self.data_source.clear()