add codes
This commit is contained in:
parent
04bcb00670
commit
39f89b8f25
101
all_info2.csv
Normal file
101
all_info2.csv
Normal file
@ -0,0 +1,101 @@
|
||||
IP地址,MAC地址,版本号,通道1名称,通道1绑定设备,通道2名称,通道2绑定设备
|
||||
192.168.0.161,50-29-4D-20-12-01,1.1,通道1名称,通道1绑定设备,通道2名称,通道2绑定设备
|
||||
192.168.0.177,50-29-4D-20-12-02,2.1,通道2名称,通道2绑定设备,通道3名称,通道3绑定设备
|
||||
192.168.0.174,50-29-4D-20-12-03,3.1,通道3名称,通道3绑定设备,通道4名称,通道4绑定设备
|
||||
192.168.0.185,50-29-4D-20-12-04,4.1,通道4名称,通道4绑定设备,通道5名称,通道5绑定设备
|
||||
192.168.0.168,50-29-4D-20-12-05,5.1,通道5名称,通道5绑定设备,通道6名称,通道6绑定设备
|
||||
192.168.0.161,50-29-4D-20-12-01,1.1,通道1名称,通道1绑定设备,通道2名称,通道2绑定设备
|
||||
192.168.0.177,50-29-4D-20-12-02,2.1,通道2名称,通道2绑定设备,通道3名称,通道3绑定设备
|
||||
192.168.0.174,50-29-4D-20-12-03,3.1,通道3名称,通道3绑定设备,通道4名称,通道4绑定设备
|
||||
192.168.0.185,50-29-4D-20-12-04,4.1,通道4名称,通道4绑定设备,通道5名称,通道5绑定设备
|
||||
192.168.0.168,50-29-4D-20-12-05,5.1,通道5名称,通道5绑定设备,通道6名称,通道6绑定设备
|
||||
192.168.0.161,50-29-4D-20-12-01,1.1,通道1名称,通道1绑定设备,通道2名称,通道2绑定设备
|
||||
192.168.0.177,50-29-4D-20-12-02,2.1,通道2名称,通道2绑定设备,通道3名称,通道3绑定设备
|
||||
192.168.0.174,50-29-4D-20-12-03,3.1,通道3名称,通道3绑定设备,通道4名称,通道4绑定设备
|
||||
192.168.0.185,50-29-4D-20-12-04,4.1,通道4名称,通道4绑定设备,通道5名称,通道5绑定设备
|
||||
192.168.0.168,50-29-4D-20-12-05,5.1,通道5名称,通道5绑定设备,通道6名称,通道6绑定设备
|
||||
192.168.0.161,50-29-4D-20-12-01,1.1,通道1名称,通道1绑定设备,通道2名称,通道2绑定设备
|
||||
192.168.0.177,50-29-4D-20-12-02,2.1,通道2名称,通道2绑定设备,通道3名称,通道3绑定设备
|
||||
192.168.0.174,50-29-4D-20-12-03,3.1,通道3名称,通道3绑定设备,通道4名称,通道4绑定设备
|
||||
192.168.0.185,50-29-4D-20-12-04,4.1,通道4名称,通道4绑定设备,通道5名称,通道5绑定设备
|
||||
192.168.0.168,50-29-4D-20-12-05,5.20,通道5名称,通道5绑定设备,通道6名称,通道6绑定设备
|
||||
192.168.0.161,50-29-4D-20-12-01,1.1,通道1名称,通道1绑定设备,通道2名称,通道2绑定设备
|
||||
192.168.0.177,50-29-4D-20-12-02,2.1,通道2名称,通道2绑定设备,通道3名称,通道3绑定设备
|
||||
192.168.0.174,50-29-4D-20-12-03,3.1,通道3名称,通道3绑定设备,通道4名称,通道4绑定设备
|
||||
192.168.0.185,50-29-4D-20-12-04,4.1,通道4名称,通道4绑定设备,通道5名称,通道5绑定设备
|
||||
192.168.0.168,50-29-4D-20-12-05,5.1,通道5名称,通道5绑定设备,通道6名称,通道6绑定设备
|
||||
192.168.0.161,50-29-4D-20-12-01,1.1,通道1名称,通道1绑定设备,通道2名称,通道2绑定设备
|
||||
192.168.0.177,50-29-4D-20-12-02,2.1,通道2名称,通道2绑定设备,通道3名称,通道3绑定设备
|
||||
192.168.0.174,50-29-4D-20-12-03,3.1,通道3名称,通道3绑定设备,通道4名称,通道4绑定设备
|
||||
192.168.0.185,50-29-4D-20-12-04,4.1,通道4名称,通道4绑定设备,通道5名称,通道5绑定设备
|
||||
192.168.0.168,50-29-4D-20-12-05,5.1,通道5名称,通道5绑定设备,通道6名称,通道6绑定设备
|
||||
192.168.0.161,50-29-4D-20-12-01,1.1,通道1名称,通道1绑定设备,通道2名称,通道2绑定设备
|
||||
192.168.0.177,50-29-4D-20-12-02,2.1,通道2名称,通道2绑定设备,通道3名称,通道3绑定设备
|
||||
192.168.0.174,50-29-4D-20-12-03,3.1,通道3名称,通道3绑定设备,通道4名称,通道4绑定设备
|
||||
192.168.0.185,50-29-4D-20-12-04,4.1,通道4名称,通道4绑定设备,通道5名称,通道5绑定设备
|
||||
192.168.0.168,50-29-4D-20-12-05,5.1,通道5名称,通道5绑定设备,通道6名称,通道6绑定设备
|
||||
192.168.0.161,50-29-4D-20-12-01,1.1,通道1名称,通道1绑定设备,通道2名称,通道2绑定设备
|
||||
192.168.0.177,50-29-4D-20-12-02,2.1,通道2名称,通道2绑定设备,通道3名称,通道3绑定设备
|
||||
192.168.0.174,50-29-4D-20-12-03,3.1,通道3名称,通道3绑定设备,通道4名称,通道4绑定设备
|
||||
192.168.0.185,50-29-4D-20-12-04,4.1,通道4名称,通道4绑定设备,通道5名称,通道5绑定设备
|
||||
192.168.0.168,50-29-4D-20-12-05,5.41,通道5名称,通道5绑定设备,通道6名称,通道6绑定设备
|
||||
192.168.0.161,50-29-4D-20-12-01,1.1,通道1名称,通道1绑定设备,通道2名称,通道2绑定设备
|
||||
192.168.0.177,50-29-4D-20-12-02,2.1,通道2名称,通道2绑定设备,通道3名称,通道3绑定设备
|
||||
192.168.0.174,50-29-4D-20-12-03,3.1,通道3名称,通道3绑定设备,通道4名称,通道4绑定设备
|
||||
192.168.0.185,50-29-4D-20-12-04,4.1,通道4名称,通道4绑定设备,通道5名称,通道5绑定设备
|
||||
192.168.0.168,50-29-4D-20-12-05,5.1,通道5名称,通道5绑定设备,通道6名称,通道6绑定设备
|
||||
192.168.0.161,50-29-4D-20-12-01,1.1,通道1名称,通道1绑定设备,通道2名称,通道2绑定设备
|
||||
192.168.0.177,50-29-4D-20-12-02,2.1,通道2名称,通道2绑定设备,通道3名称,通道3绑定设备
|
||||
192.168.0.174,50-29-4D-20-12-03,3.1,通道3名称,通道3绑定设备,通道4名称,通道4绑定设备
|
||||
192.168.0.185,50-29-4D-20-12-04,4.1,通道4名称,通道4绑定设备,通道5名称,通道5绑定设备
|
||||
192.168.0.168,50-29-4D-20-12-05,5.1,通道5名称,通道5绑定设备,通道6名称,通道6绑定设备
|
||||
192.168.0.161,50-29-4D-20-12-01,1.1,通道1名称,通道1绑定设备,通道2名称,通道2绑定设备
|
||||
192.168.0.177,50-29-4D-20-12-02,2.1,通道2名称,通道2绑定设备,通道3名称,通道3绑定设备
|
||||
192.168.0.174,50-29-4D-20-12-03,3.1,通道3名称,通道3绑定设备,通道4名称,通道4绑定设备
|
||||
192.168.0.185,50-29-4D-20-12-04,4.1,通道4名称,通道4绑定设备,通道5名称,通道5绑定设备
|
||||
192.168.0.168,50-29-4D-20-12-05,5.1,通道5名称,通道5绑定设备,通道6名称,通道6绑定设备
|
||||
192.168.0.161,50-29-4D-20-12-01,1.1,通道1名称,通道1绑定设备,通道2名称,通道2绑定设备
|
||||
192.168.0.177,50-29-4D-20-12-02,2.1,通道2名称,通道2绑定设备,通道3名称,通道3绑定设备
|
||||
192.168.0.174,50-29-4D-20-12-03,3.1,通道3名称,通道3绑定设备,通道4名称,通道4绑定设备
|
||||
192.168.0.185,50-29-4D-20-12-04,4.1,通道4名称,通道4绑定设备,通道5名称,通道5绑定设备
|
||||
192.168.0.168,50-29-4D-20-12-05,5.61,通道5名称,通道5绑定设备,通道6名称,通道6绑定设备
|
||||
192.168.0.161,50-29-4D-20-12-01,1.1,通道1名称,通道1绑定设备,通道2名称,通道2绑定设备
|
||||
192.168.0.177,50-29-4D-20-12-02,2.1,通道2名称,通道2绑定设备,通道3名称,通道3绑定设备
|
||||
192.168.0.174,50-29-4D-20-12-03,3.1,通道3名称,通道3绑定设备,通道4名称,通道4绑定设备
|
||||
192.168.0.185,50-29-4D-20-12-04,4.1,通道4名称,通道4绑定设备,通道5名称,通道5绑定设备
|
||||
192.168.0.168,50-29-4D-20-12-05,5.1,通道5名称,通道5绑定设备,通道6名称,通道6绑定设备
|
||||
192.168.0.161,50-29-4D-20-12-01,1.1,通道1名称,通道1绑定设备,通道2名称,通道2绑定设备
|
||||
192.168.0.177,50-29-4D-20-12-02,2.1,通道2名称,通道2绑定设备,通道3名称,通道3绑定设备
|
||||
192.168.0.174,50-29-4D-20-12-03,3.1,通道3名称,通道3绑定设备,通道4名称,通道4绑定设备
|
||||
192.168.0.185,50-29-4D-20-12-04,4.1,通道4名称,通道4绑定设备,通道5名称,通道5绑定设备
|
||||
192.168.0.168,50-29-4D-20-12-05,5.1,通道5名称,通道5绑定设备,通道6名称,通道6绑定设备
|
||||
192.168.0.161,50-29-4D-20-12-01,1.1,通道1名称,通道1绑定设备,通道2名称,通道2绑定设备
|
||||
192.168.0.177,50-29-4D-20-12-02,2.1,通道2名称,通道2绑定设备,通道3名称,通道3绑定设备
|
||||
192.168.0.174,50-29-4D-20-12-03,3.1,通道3名称,通道3绑定设备,通道4名称,通道4绑定设备
|
||||
192.168.0.185,50-29-4D-20-12-04,4.1,通道4名称,通道4绑定设备,通道5名称,通道5绑定设备
|
||||
192.168.0.168,50-29-4D-20-12-05,5.1,通道5名称,通道5绑定设备,通道6名称,通道6绑定设备
|
||||
192.168.0.161,50-29-4D-20-12-01,1.1,通道1名称,通道1绑定设备,通道2名称,通道2绑定设备
|
||||
192.168.0.177,50-29-4D-20-12-02,2.1,通道2名称,通道2绑定设备,通道3名称,通道3绑定设备
|
||||
192.168.0.174,50-29-4D-20-12-03,3.1,通道3名称,通道3绑定设备,通道4名称,通道4绑定设备
|
||||
192.168.0.185,50-29-4D-20-12-04,4.1,通道4名称,通道4绑定设备,通道5名称,通道5绑定设备
|
||||
192.168.0.168,50-29-4D-20-12-05,5.81,通道5名称,通道5绑定设备,通道6名称,通道6绑定设备
|
||||
192.168.0.161,50-29-4D-20-12-01,1.1,通道1名称,通道1绑定设备,通道2名称,通道2绑定设备
|
||||
192.168.0.177,50-29-4D-20-12-02,2.1,通道2名称,通道2绑定设备,通道3名称,通道3绑定设备
|
||||
192.168.0.174,50-29-4D-20-12-03,3.1,通道3名称,通道3绑定设备,通道4名称,通道4绑定设备
|
||||
192.168.0.185,50-29-4D-20-12-04,4.1,通道4名称,通道4绑定设备,通道5名称,通道5绑定设备
|
||||
192.168.0.168,50-29-4D-20-12-05,5.1,通道5名称,通道5绑定设备,通道6名称,通道6绑定设备
|
||||
192.168.0.161,50-29-4D-20-12-01,1.1,通道1名称,通道1绑定设备,通道2名称,通道2绑定设备
|
||||
192.168.0.177,50-29-4D-20-12-02,2.1,通道2名称,通道2绑定设备,通道3名称,通道3绑定设备
|
||||
192.168.0.174,50-29-4D-20-12-03,3.1,通道3名称,通道3绑定设备,通道4名称,通道4绑定设备
|
||||
192.168.0.185,50-29-4D-20-12-04,4.1,通道4名称,通道4绑定设备,通道5名称,通道5绑定设备
|
||||
192.168.0.168,50-29-4D-20-12-05,5.1,通道5名称,通道5绑定设备,通道6名称,通道6绑定设备
|
||||
192.168.0.161,50-29-4D-20-12-01,1.1,通道1名称,通道1绑定设备,通道2名称,通道2绑定设备
|
||||
192.168.0.177,50-29-4D-20-12-02,2.1,通道2名称,通道2绑定设备,通道3名称,通道3绑定设备
|
||||
192.168.0.174,50-29-4D-20-12-03,3.1,通道3名称,通道3绑定设备,通道4名称,通道4绑定设备
|
||||
192.168.0.185,50-29-4D-20-12-04,4.1,通道4名称,通道4绑定设备,通道5名称,通道5绑定设备
|
||||
192.168.0.168,50-29-4D-20-12-05,5.1,通道5名称,通道5绑定设备,通道6名称,通道6绑定设备
|
||||
192.168.0.161,50-29-4D-20-12-01,1.1,通道1名称,通道1绑定设备,通道2名称,通道2绑定设备
|
||||
192.168.0.177,50-29-4D-20-12-02,2.1,通道2名称,通道2绑定设备,通道3名称,通道3绑定设备
|
||||
192.168.0.174,50-29-4D-20-12-03,3.1,通道3名称,通道3绑定设备,通道4名称,通道4绑定设备
|
||||
192.168.0.185,50-29-4D-20-12-04,4.1,通道4名称,通道4绑定设备,通道5名称,通道5绑定设备
|
||||
192.168.0.168,50-29-4D-20-12-05,5.101,通道5名称,通道5绑定设备,通道6名称,通道6绑定设备
|
|
@ -11,6 +11,13 @@ class BatchOperationDialog(QDialog):
|
||||
self.setWindowTitle("批量操作节点")
|
||||
self.setGeometry(100, 100, 800, 400)
|
||||
|
||||
# 初始化分页
|
||||
self.current_page = 0
|
||||
self.rows_per_page = 20
|
||||
|
||||
# 初始化数据
|
||||
self.data = []
|
||||
|
||||
# 初始化UI
|
||||
self.init_ui()
|
||||
|
||||
@ -18,8 +25,8 @@ class BatchOperationDialog(QDialog):
|
||||
# 主布局
|
||||
main_layout = QVBoxLayout()
|
||||
|
||||
# 创建表格(8列,初始行数可以设置为10)
|
||||
self.table_widget = QTableWidget(10, 8) # 10行8列
|
||||
# 创建表格(8列,初始行数可以设置为20)
|
||||
self.table_widget = QTableWidget(self.rows_per_page, 8) # 默认显示20行
|
||||
self.table_widget.setHorizontalHeaderLabels(
|
||||
["选择", "IP地址", "MAC地址", "版本号", "通道1名称", "通道1绑定设备", "通道2名称", "通道2绑定设备"]
|
||||
)
|
||||
@ -49,6 +56,8 @@ class BatchOperationDialog(QDialog):
|
||||
self.load_ips_button = QPushButton("加载IP列表")
|
||||
self.load_all_button = QPushButton("加载完整信息列表")
|
||||
self.save_button = QPushButton("保存表数据")
|
||||
self.prev_page_button = QPushButton("上一页")
|
||||
self.next_page_button = QPushButton("下一页")
|
||||
|
||||
# 按钮连接
|
||||
self.select_all_button.clicked.connect(self.select_all)
|
||||
@ -59,6 +68,8 @@ class BatchOperationDialog(QDialog):
|
||||
self.save_button.clicked.connect(self.save_data)
|
||||
self.load_ips_button.clicked.connect(self.load_ips)
|
||||
self.load_all_button.clicked.connect(self.load_all_info)
|
||||
self.prev_page_button.clicked.connect(self.prev_page)
|
||||
self.next_page_button.clicked.connect(self.next_page)
|
||||
|
||||
# 将按钮加入布局
|
||||
button_layout.addWidget(self.select_all_button)
|
||||
@ -69,6 +80,8 @@ class BatchOperationDialog(QDialog):
|
||||
button_layout.addWidget(self.load_ips_button)
|
||||
button_layout.addWidget(self.load_all_button)
|
||||
button_layout.addWidget(self.save_button)
|
||||
button_layout.addWidget(self.prev_page_button)
|
||||
button_layout.addWidget(self.next_page_button)
|
||||
|
||||
# 将表格和按钮布局添加到主布局
|
||||
main_layout.addWidget(self.table_widget)
|
||||
@ -109,11 +122,14 @@ class BatchOperationDialog(QDialog):
|
||||
writer = csv.writer(file)
|
||||
# 写入表头
|
||||
headers = [self.table_widget.horizontalHeaderItem(i).text() for i in range(self.table_widget.columnCount())]
|
||||
writer.writerow(headers)
|
||||
writer.writerow(headers[1:])
|
||||
# 写入表格内容
|
||||
for row in range(self.table_widget.rowCount()):
|
||||
row_data = [self.table_widget.item(row, col).text() if self.table_widget.item(row, col) else "" for col in range(self.table_widget.columnCount())]
|
||||
row_data = [self.table_widget.item(row, col).text() if self.table_widget.item(row, col) else ""
|
||||
for col in
|
||||
range(1, self.table_widget.columnCount())] # Start from col=1 to skip the first column
|
||||
writer.writerow(row_data)
|
||||
|
||||
print(f"数据已保存到 {file_path}")
|
||||
|
||||
def load_ips(self):
|
||||
@ -137,6 +153,7 @@ class BatchOperationDialog(QDialog):
|
||||
QMessageBox.warning(self, "错误", f"以下行的IP地址无效:{', '.join(map(str, invalid_ips))}")
|
||||
else:
|
||||
# 将IP地址加载到表格
|
||||
self.table_widget.setRowCount(len(lines))
|
||||
for i, line in enumerate(lines):
|
||||
ip = line.strip()
|
||||
if i < self.table_widget.rowCount():
|
||||
@ -152,17 +169,44 @@ class BatchOperationDialog(QDialog):
|
||||
def load_all_info(self):
|
||||
# 打开CSV文件选择对话框
|
||||
options = QFileDialog.Options()
|
||||
file_path, _ = QFileDialog.getOpenFileName(self, "选择CSV文件", "", "CSV Files (*.csv);;All Files (*)", options=options)
|
||||
file_path, _ = QFileDialog.getOpenFileName(self, "选择CSV文件", "", "CSV Files (*.csv);;All Files (*)",
|
||||
options=options)
|
||||
if file_path:
|
||||
# 读取CSV文件
|
||||
with open(file_path, mode='r', encoding='utf-8') as file:
|
||||
reader = csv.reader(file)
|
||||
headers = next(reader) # 跳过表头
|
||||
for row_num, row_data in enumerate(reader):
|
||||
if row_num < self.table_widget.rowCount():
|
||||
for col_num, cell_data in enumerate(row_data):
|
||||
self.table_widget.setItem(row_num, col_num+1, QTableWidgetItem(cell_data))
|
||||
print(f"加载了CSV文件中的内容:{file_path}")
|
||||
self.data = [row for row in reader]
|
||||
if len(self.data) <= 20:
|
||||
self.table_widget.setRowCount(len(self.data))
|
||||
# 确保加载数据后更新分页
|
||||
self.current_page = 0 # 每次加载新数据,默认回到第一页
|
||||
self.update_table()
|
||||
|
||||
def update_table(self):
|
||||
# 获取当前页的数据
|
||||
start_row = self.current_page * self.rows_per_page
|
||||
end_row = start_row + self.rows_per_page
|
||||
rows_to_display = self.data[start_row:end_row]
|
||||
|
||||
# 更新表格内容
|
||||
for row_num, row_data in enumerate(rows_to_display):
|
||||
for col_num, cell_data in enumerate(row_data):
|
||||
self.table_widget.setItem(row_num, col_num + 1, QTableWidgetItem(cell_data)) # +1跳过“选择”列
|
||||
|
||||
# 根据数据量调整上一页和下一页按钮的状态
|
||||
self.prev_page_button.setEnabled(self.current_page > 0)
|
||||
self.next_page_button.setEnabled((self.current_page + 1) * self.rows_per_page < len(self.data))
|
||||
|
||||
def prev_page(self):
|
||||
if self.current_page > 0:
|
||||
self.current_page -= 1
|
||||
self.update_table()
|
||||
|
||||
def next_page(self):
|
||||
if (self.current_page + 1) * self.rows_per_page < len(self.data):
|
||||
self.current_page += 1
|
||||
self.update_table()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
21
hell2.csv
Normal file
21
hell2.csv
Normal file
@ -0,0 +1,21 @@
|
||||
IP地址,MAC地址,版本号,通道1名称,通道1绑定设备,通道2名称,通道2绑定设备
|
||||
192.168.0.161,50-29-4D-20-12-01,1.1,通道1名称,通道1绑定设备,通道2名称,通道2绑定设备
|
||||
192.168.0.177,50-29-4D-20-12-02,2.1,通道2名称,通道2绑定设备,通道3名称,通道3绑定设备
|
||||
192.168.0.174,50-29-4D-20-12-03,3.1,通道3名称,通道3绑定设备,通道4名称,通道4绑定设备
|
||||
192.168.0.185,50-29-4D-20-12-04,4.1,通道4名称,通道4绑定设备,通道5名称,通道5绑定设备
|
||||
192.168.0.168,50-29-4D-20-12-05,5.1,通道5名称,通道5绑定设备,通道6名称,通道6绑定设备
|
||||
,,,,,,
|
||||
,,,,,,
|
||||
,,,,,,
|
||||
,,,,,,
|
||||
,,,,,,
|
||||
,,,,,,
|
||||
,,,,,,
|
||||
,,,,,,
|
||||
,,,,,,
|
||||
,,,,,,
|
||||
,,,,,,
|
||||
,,,,,,
|
||||
,,,,,,
|
||||
,,,,,,
|
||||
,,,,,,
|
|
21
hello.csv
Normal file
21
hello.csv
Normal file
@ -0,0 +1,21 @@
|
||||
选择,IP地址,MAC地址,版本号,通道1名称,通道1绑定设备,通道2名称,通道2绑定设备
|
||||
,192.168.0.161,50-29-4D-20-12-01,1.1,通道1名称,通道1绑定设备,通道2名称,通道2绑定设备
|
||||
,192.168.0.177,50-29-4D-20-12-02,2.1,通道2名称,通道2绑定设备,通道3名称,通道3绑定设备
|
||||
,192.168.0.174,50-29-4D-20-12-03,3.1,通道3名称,通道3绑定设备,通道4名称,通道4绑定设备
|
||||
,192.168.0.185,50-29-4D-20-12-04,4.1,通道4名称,通道4绑定设备,通道5名称,通道5绑定设备
|
||||
,192.168.0.168,50-29-4D-20-12-05,5.1,通道5名称,通道5绑定设备,通道6名称,通道6绑定设备
|
||||
,,,,,,,
|
||||
,,,,,,,
|
||||
,,,,,,,
|
||||
,,,,,,,
|
||||
,,,,,,,
|
||||
,,,,,,,
|
||||
,,,,,,,
|
||||
,,,,,,,
|
||||
,,,,,,,
|
||||
,,,,,,,
|
||||
,,,,,,,
|
||||
,,,,,,,
|
||||
,,,,,,,
|
||||
,,,,,,,
|
||||
,,,,,,,
|
|
Loading…
x
Reference in New Issue
Block a user