main_window_XmSgj.py 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. from PyQt5.QtCore import QSize, QTimer, Qt
  2. from PyQt5.QtGui import QFont, QBrush, QColor, QPixmap
  3. from PyQt5.QtWidgets import QApplication, QMainWindow, QListWidgetItem, QListWidget, QLabel
  4. from ui.ui import Ui_MainWindow
  5. class MainWindow(QMainWindow, Ui_MainWindow):
  6. def __init__(self, db, display_number,unit,task_type):
  7. super().__init__()
  8. self.setupUi(self)
  9. self.label.setText("上古街智能立体停车库流程信息")
  10. self.task_type = task_type
  11. self.image_label.setPixmap(QPixmap('./image/log.jpg'))
  12. self.image_label.setScaledContents(True)
  13. self.image_label.setMaximumHeight(140)
  14. self.image_label.setMaximumWidth(600)
  15. self.db = db
  16. self.display_number = display_number
  17. unit_dict = {'A':[11,12,13,14],'B':[21,22,23,24,25],'C':[31,32]}
  18. self.unit_list = unit_dict[unit]
  19. self.list_widget_dict = {}
  20. self.label_dict = {}
  21. self.command_dict = {}
  22. # 创建listwidget与label 配置多少个单元生成多少对
  23. for i in self.unit_list:
  24. self.list_widget_dict[i] = QListWidget(self)
  25. self.list_widget_dict[i].setStyleSheet("border:5px solid #014F84;")
  26. self.list_widget_dict[i].setObjectName(('list_widget_%d'%(i+1)))
  27. self.process_horizontalLayout.addWidget(self.list_widget_dict[i])
  28. self.label_dict[i] = QLabel(self)
  29. self.label_dict[i].setText(unit+"-"+str((i%10)))
  30. self.label_dict[i].setAlignment(Qt.AlignCenter)
  31. self.label_dict[i].setFont(QFont("华文楷体", 60, QFont.Bold))
  32. self.command_dict[i] = []
  33. self.unit_horizontalLayout.addWidget(self.label_dict[i])
  34. self.timer = QTimer()
  35. self.timer.timeout.connect(self.Switch)
  36. self.timer.start(200)
  37. def closeEvent(self, event):
  38. event.accept() # 接受关闭事件
  39. def get_listWidget_item(self, dict):
  40. item = QListWidgetItem()
  41. item.setFont(QFont('微软雅黑', 15, QFont.Bold))
  42. show_str = ""
  43. if dict['type'] == 1:#存车指令
  44. item.setBackground(QColor(185,240,240))
  45. if (dict['statu'] == 0): # 排队
  46. item.setForeground(QColor(80, 80, 80))
  47. show_str = dict['car_number'] + " 排队中,请稍等片刻"
  48. elif (dict['statu'] == 1): # 工作
  49. item.setForeground(QColor('blue'))
  50. show_str = dict['car_number'] + " 存车中,等待存车结束"
  51. elif (dict['statu'] == 2): # 已完成
  52. item.setForeground(QColor('green'))
  53. show_str = dict['car_number'] + " 存车已完成"
  54. elif (dict['statu'] == 3): # 已完成
  55. item.setForeground(QColor('red'))
  56. show_str = dict['car_number'] + " 故障,请联系管理员!"
  57. show_str = "存 "+show_str
  58. elif dict['type'] == 2:#取车指令
  59. item.setBackground(QColor(250,240,200))
  60. if (dict['statu'] == 0): # 排队
  61. item.setForeground(QColor(80, 80, 80))
  62. show_str = dict['car_number'] + " 排队中,请稍等片刻"
  63. elif (dict['statu'] == 1): # 工作
  64. item.setForeground(QColor('blue'))
  65. show_str = dict['car_number'] + " 取车中,等待取车结束"
  66. elif (dict['statu'] == 2): # 已完成
  67. item.setForeground(QColor('green'))
  68. show_str = dict['car_number'] + " 已完成,请到 %d 号出口取车" % (dict["export_id"])
  69. elif (dict['statu'] == 3): # 已完成
  70. item.setForeground(QColor('red'))
  71. show_str = dict['car_number'] + " 故障,请联系管理员!"
  72. show_str = "取 "+show_str
  73. item.setText(show_str)
  74. return item
  75. def Switch(self):
  76. for i in self.unit_list:
  77. if self.task_type != 0:
  78. t_command_dict = self.db.query_command_all_in_unit_type_and_sort(i,self.task_type)
  79. else:
  80. t_command_dict = self.db.query_command_all_in_unit_and_sort(i)
  81. if self.command_dict[i] != t_command_dict:
  82. self.command_dict[i] = t_command_dict
  83. self.list_widget_dict[i].clear()
  84. for dict in self.command_dict[i]:
  85. self.list_widget_dict[i].addItem(self.get_listWidget_item(dict))