[Python] PyQt5 Message Boxes

buttonReply = QMessageBox.question(self, 'Shutdown Server', "Shutdown Server VM, Continue?", QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
if buttonReply == QMessageBox.Yes:
operation_num = 2
self.operationsThread = Operations_Thread()
self.operationsThread.updateTextEditSignal.connect(self.updateText)
self.operationsThread.start()
self.updateText("[{}]Shutting down VM - Please wait...".format(time.strftime("%Y.%m.%d-%H:%M:%S")))

def showdialog(self,text):
global mon_config
if text != 'FAIL':
msg = QMessageBox()
msg.setIcon(QMessageBox.Information)

msg.setWindowTitle(f"MODBUS TCP Read from: {self.selectedDevice}")
msg.setText(f"Sensor serial no: {text}")
msg.setInformativeText("For more info. click 'Show Details'")

msg.setDetailedText(f"Serial no. from IP address : {self.selectedDevice} on port {mon_config['search_device']['modbus_port']} success. \r\n\r\nSerial no. of sensor: {text}")
msg.setStandardButtons(QMessageBox.Ok)

elif text == 'FAIL':
msg = QMessageBox()
msg.setIcon(QMessageBox.Critical)

msg.setWindowTitle(f"MODBUS TCP Read from: {self.selectedDevice}")
msg.setText(f"MODBUS TCP Read Failed...")
msg.setInformativeText("For more info. click 'Show Details'")

msg.setDetailedText(f"Reading sensor serial no from IP address : {self.selectedDevice} on port {mon_config['search_device']['modbus_port']} failed.\r\n\r\nPlease check whether the sensor is working or modbus port correct.")
msg.setStandardButtons(QMessageBox.Ok)

retval = msg.exec_()

Comments

Popular posts from this blog

[Linux] tcpdump - view TCP traffic on Linux

[Linux] Using grep command with pattern input from a file