| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- class MainWindow(QMainWindow):
- # 定义一个信号,用于传递日志信息
- log_added = pyqtSignal(str, str, str, str, str, str, str, str)
- def __init__(self):
- super().__init__()
- # 设置一个选品停止的flag
- self.stop_selecting_flag = False
- # 设置一个扫货停止的flag
- self.stop_shopping_flag = False
- # 向BUFF选品日志列表中写内容的槽函数
- self.log_added.connect(self._add_select_log) # 连接信号到槽函数
- def show_add_select_log_dialog(self):
- dialog = SelectLogDialog(self, "添加选品日志")
- if dialog.exec():
- item_id = dialog.item_id_edit.text()
- item_name = dialog.item_name_edit.text()
- min_wear = dialog.min_wear_edit.text()
- max_wear = dialog.max_wear_edit.text()
- min_full_wear_price = dialog.min_full_wear_price_edit.text()
- sweep_price = dialog.sweep_price_edit.text()
- judge_price = dialog.judge_price_edit.text()
- timestamp = dialog.timestamp_edit.text()
- # 确保调用的是MainWindow类中的_add_select_log方法
- self._add_select_log(item_id, item_name, min_wear, max_wear, min_full_wear_price, sweep_price, judge_price, timestamp)
- # 向BUFF选品日志标签页的列表中写数据的槽函数
- @pyqtSlot(str, str, str, str, str, str, str, str)
- def _add_select_log(self, item_id, item_name, min_wear, max_wear, min_full_wear_price, sweep_price, judge_price, timestamp):
- # 创建一个字典来存储记录的详细信息
- record = {
- '商品ID': item_id,
- '商品名称': item_name,
- '磨损最低值': min_wear,
- '磨损最高值': max_wear,
- '全磨损区间最低价': min_full_wear_price,
- '扫货价': sweep_price,
- '判断价': judge_price,
- '时间': timestamp
- }
- # 将新记录添加到树形控件中
- item = QTreeWidgetItem(self.select_log_tree_widget)
- item.setText(0, "") # 选择列为空
- item.setText(1, record['商品ID'])
- item.setText(2, record['商品名称'])
- item.setText(3, str(record['磨损最低值']))
- item.setText(4, str(record['磨损最高值']))
- item.setText(5, str(record['全磨损区间最低价']))
- item.setText(6, str(record['扫货价']))
- item.setText(7, str(record['判断价']))
- item.setText(8, record['时间'])
- # 创建复选框
- checkbox = QCheckBox()
- checkbox.setChecked(False)
- self.select_log_tree_widget.setItemWidget(item, 0, checkbox)
|