main_window.py 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. class MainWindow(QMainWindow):
  2. # 定义一个信号,用于传递日志信息
  3. log_added = pyqtSignal(str, str, str, str, str, str, str, str)
  4. def __init__(self):
  5. super().__init__()
  6. # 设置一个选品停止的flag
  7. self.stop_selecting_flag = False
  8. # 设置一个扫货停止的flag
  9. self.stop_shopping_flag = False
  10. # 向BUFF选品日志列表中写内容的槽函数
  11. self.log_added.connect(self._add_select_log) # 连接信号到槽函数
  12. def show_add_select_log_dialog(self):
  13. dialog = SelectLogDialog(self, "添加选品日志")
  14. if dialog.exec():
  15. item_id = dialog.item_id_edit.text()
  16. item_name = dialog.item_name_edit.text()
  17. min_wear = dialog.min_wear_edit.text()
  18. max_wear = dialog.max_wear_edit.text()
  19. min_full_wear_price = dialog.min_full_wear_price_edit.text()
  20. sweep_price = dialog.sweep_price_edit.text()
  21. judge_price = dialog.judge_price_edit.text()
  22. timestamp = dialog.timestamp_edit.text()
  23. # 确保调用的是MainWindow类中的_add_select_log方法
  24. self._add_select_log(item_id, item_name, min_wear, max_wear, min_full_wear_price, sweep_price, judge_price, timestamp)
  25. # 向BUFF选品日志标签页的列表中写数据的槽函数
  26. @pyqtSlot(str, str, str, str, str, str, str, str)
  27. def _add_select_log(self, item_id, item_name, min_wear, max_wear, min_full_wear_price, sweep_price, judge_price, timestamp):
  28. # 创建一个字典来存储记录的详细信息
  29. record = {
  30. '商品ID': item_id,
  31. '商品名称': item_name,
  32. '磨损最低值': min_wear,
  33. '磨损最高值': max_wear,
  34. '全磨损区间最低价': min_full_wear_price,
  35. '扫货价': sweep_price,
  36. '判断价': judge_price,
  37. '时间': timestamp
  38. }
  39. # 将新记录添加到树形控件中
  40. item = QTreeWidgetItem(self.select_log_tree_widget)
  41. item.setText(0, "") # 选择列为空
  42. item.setText(1, record['商品ID'])
  43. item.setText(2, record['商品名称'])
  44. item.setText(3, str(record['磨损最低值']))
  45. item.setText(4, str(record['磨损最高值']))
  46. item.setText(5, str(record['全磨损区间最低价']))
  47. item.setText(6, str(record['扫货价']))
  48. item.setText(7, str(record['判断价']))
  49. item.setText(8, record['时间'])
  50. # 创建复选框
  51. checkbox = QCheckBox()
  52. checkbox.setChecked(False)
  53. self.select_log_tree_widget.setItemWidget(item, 0, checkbox)