node.py 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import sys
  2. from PyQt5.QtCore import QSize, QTimer
  3. from PyQt5.QtGui import QFont, QBrush, QColor, QPixmap
  4. from PyQt5.QtWidgets import QApplication, QMainWindow, QListWidgetItem
  5. from ui.ui import Ui_MainWindow
  6. import db_operation
  7. class MainWindow(QMainWindow, Ui_MainWindow):
  8. def __init__(self, parent=None):
  9. super(MainWindow, self).__init__(parent)
  10. self.setupUi(self)
  11. self.A_listWidget.setGridSize(QSize(335, 60))
  12. self.A_listWidget.setStyleSheet("border:5px solid #014F84;")
  13. self.B_listWidget.setGridSize(QSize(335, 60))
  14. self.B_listWidget.setStyleSheet("border:5px solid #014F84;")
  15. self.C_listWidget.setGridSize(QSize(335, 60))
  16. self.C_listWidget.setStyleSheet("border:5px solid #014F84;")
  17. self.image_label.setPixmap(QPixmap('log.jpg'))
  18. self.image_label.setScaledContents(True)
  19. self.image_label.setMaximumHeight(140)
  20. self.image_label.setMaximumWidth(600)
  21. self.timer = QTimer()
  22. self.timer.timeout.connect(self.Switch)
  23. self.timer.start(200)
  24. self.pick_command_dict = {1: [], 2: [], 3: []}
  25. def closeEvent(self, event):
  26. db_query.close()
  27. event.accept() # 接受关闭事件
  28. def getListWidgetItem(self, dict):
  29. item = QListWidgetItem()
  30. item.setFont(QFont('微软雅黑', 20, QFont.Bold))
  31. show_str = ""
  32. if (dict["statu"] == 0): # 排队
  33. item.setForeground(QColor(80, 80, 80))
  34. show_str = dict["car_number"] + " 排队中,请稍等片刻"
  35. elif (dict["statu"] == 1): # 工作
  36. item.setForeground(QColor('blue'))
  37. show_str = dict["car_number"] + " 取车中,等待取车结束"
  38. elif (dict["statu"] == 2): # 已完成
  39. item.setForeground(QColor('green'))
  40. show_str = dict["car_number"] + " 已完成,请到 %d 号出口取车" % (dict["export_id"])
  41. item.setText(show_str)
  42. return item
  43. def Switch(self):
  44. pick_command_dict = {1:[],2:[],3:[]}
  45. for key in pick_command_dict:
  46. pick_command_dict[key] = db_query.query_command_in_unit_and_type(key,2)
  47. for key in self.pick_command_dict.keys():
  48. if self.pick_command_dict[key] != pick_command_dict[key]:
  49. self.pick_command_dict[key] = pick_command_dict[key]
  50. if key == 1:
  51. self.A_listWidget.clear()
  52. for dict in self.pick_command_dict[key]:
  53. self.A_listWidget.addItem(self.getListWidgetItem(dict))
  54. elif key == 2:
  55. self.B_listWidget.clear()
  56. for dict in self.pick_command_dict[key]:
  57. self.B_listWidget.addItem(self.getListWidgetItem(dict))
  58. elif key == 3:
  59. self.C_listWidget.clear()
  60. for dict in self.pick_command_dict[key]:
  61. self.C_listWidget.addItem(self.getListWidgetItem(dict))
  62. if __name__ == '__main__':
  63. app = QApplication(sys.argv)
  64. window = MainWindow()
  65. db_query = db_operation.DBOperation()
  66. db_query.start()
  67. window.showMaximized()
  68. sys.exit(app.exec_())