初始化
This commit is contained in:
1
tools/ui/components/__init__.py
Normal file
1
tools/ui/components/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
# UI界面模块
|
||||
67
tools/ui/components/file_list_group.py
Normal file
67
tools/ui/components/file_list_group.py
Normal file
@@ -0,0 +1,67 @@
|
||||
'''
|
||||
pyqt6 文件列表分组
|
||||
'''
|
||||
from PyQt6.QtWidgets import QApplication, QVBoxLayout, QHBoxLayout, QPushButton, QListWidget, QGroupBox
|
||||
from PyQt6.QtCore import pyqtSignal
|
||||
|
||||
|
||||
class FileListGroup(QGroupBox):
|
||||
|
||||
load_files = pyqtSignal()
|
||||
def __init__(self, parent=None, title="文件列表"):
|
||||
super().__init__(title, parent)
|
||||
self.init_ui()
|
||||
|
||||
def init_ui(self):
|
||||
layout = QVBoxLayout(self)
|
||||
|
||||
# 文件列表
|
||||
self.file_list = QListWidget()
|
||||
self.file_list.setSelectionMode(QListWidget.SelectionMode.MultiSelection)
|
||||
layout.addWidget(self.file_list)
|
||||
|
||||
# 文件列表操作按钮
|
||||
file_list_btn_layout = QHBoxLayout()
|
||||
|
||||
# 加载文件按钮
|
||||
self.load_file_btn = QPushButton("加载文件")
|
||||
self.load_file_btn.clicked.connect(self.on_load_files)
|
||||
|
||||
# 全选/全不选按钮
|
||||
select_all_btn = QPushButton("全选")
|
||||
select_all_btn.clicked.connect(self.on_select_all_files)
|
||||
select_none_btn = QPushButton("全不选")
|
||||
select_none_btn.clicked.connect(self.on_select_none_files)
|
||||
|
||||
# 添加按钮到布局
|
||||
file_list_btn_layout.addWidget(self.load_file_btn)
|
||||
file_list_btn_layout.addWidget(select_all_btn)
|
||||
file_list_btn_layout.addWidget(select_none_btn)
|
||||
|
||||
layout.addLayout(file_list_btn_layout)
|
||||
|
||||
def on_load_files(self):
|
||||
# 通过信号槽机制,添加文件列表
|
||||
self.load_files.emit()
|
||||
|
||||
def on_select_all_files(self):
|
||||
# 全选文件
|
||||
for i in range(self.file_list.count()):
|
||||
item = self.file_list.item(i)
|
||||
if item:
|
||||
item.setSelected(True)
|
||||
|
||||
def on_select_none_files(self):
|
||||
# 全不选文件
|
||||
for i in range(self.file_list.count()):
|
||||
item = self.file_list.item(i)
|
||||
if item:
|
||||
item.setSelected(False)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app = QApplication([])
|
||||
app.setStyle("Fusion")
|
||||
window = FileListGroup()
|
||||
window.show()
|
||||
app.exec()
|
||||
64
tools/ui/components/input_group.py
Normal file
64
tools/ui/components/input_group.py
Normal file
@@ -0,0 +1,64 @@
|
||||
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()
|
||||
Reference in New Issue
Block a user