def __init__(self, parent=None): super(displayDataPannel, self).__init__( parent) # __init__(parent)가 아니면 메인에서 본 위젯의 시그널을 받을 수 없음 # 화면 구성 self.ui = Ui_displayPannel() self.ui.setupUi(self)
class displayDataPannel(QtGui.QWidget): def __init__(self, parent=None): super(displayDataPannel, self).__init__( parent) # __init__(parent)가 아니면 메인에서 본 위젯의 시그널을 받을 수 없음 # 화면 구성 self.ui = Ui_displayPannel() self.ui.setupUi(self) def slot_clear_display(self): self.ui.te_recvAscii.setText('') self.ui.te_sendAscii.setText('') self.ui.te_recvHex.setText('') self.ui.te_sendHex.setText('') def showData(self, text, destination): dataLen = '' timeStamp = '' text = (str(text.toUtf8()).decode("utf-8")).encode( 'latin-1') # QString을 str 타입으로 변환 # 옵션 검사 if self.ui.chkb_timeStamp.isChecked() is True: # 타임 스탬프가 Checked 상태라면, timeStamp = '' + time.strftime('%Y-%m-%d %H:%M:%S') if self.ui.chkb_dataLength.isChecked() is True: # 데이터 길이가 Checked 상태라면, dataLen = '' + str(len(text)) + ' Byte(s) ' # Hex 값 표출 창 buf = '<a style="background-color:#e6e6e6;color:black">' + dataLen + timeStamp + '</a><br>' + \ text.encode('hex') + '<br>' if destination == 0: # 송신 self.ui.te_recvHex.moveCursor(QtGui.QTextCursor.End) self.ui.te_recvHex.insertHtml(buf) self.ui.te_recvHex.moveCursor(QtGui.QTextCursor.End) else: # 수신 self.ui.te_sendHex.moveCursor(QtGui.QTextCursor.End) self.ui.te_sendHex.insertHtml(buf) self.ui.te_sendHex.moveCursor(QtGui.QTextCursor.End) # Ascii 값 표출 창 buf = '<a style="background-color:#e6e6e6;color:black">' + dataLen + timeStamp + '</a><br>' + \ text + '<br>' if destination == 0: self.ui.te_recvAscii.moveCursor(QtGui.QTextCursor.End) self.ui.te_recvAscii.insertHtml(buf) self.ui.te_recvAscii.moveCursor(QtGui.QTextCursor.End) else: self.ui.te_sendAscii.moveCursor(QtGui.QTextCursor.End) self.ui.te_sendAscii.insertHtml(buf) self.ui.te_sendAscii.moveCursor(QtGui.QTextCursor.End)
class displayDataPannel(QtGui.QWidget): def __init__(self, parent = None): super(displayDataPannel, self).__init__(parent) # __init__(parent)가 아니면 메인에서 본 위젯의 시그널을 받을 수 없음 # 화면 구성 self.ui = Ui_displayPannel() self.ui.setupUi(self) def slot_clear_display(self): self.ui.te_recvAscii.setText('') self.ui.te_sendAscii.setText('') self.ui.te_recvHex.setText('') self.ui.te_sendHex.setText('') def showData(self, text, destination): dataLen = '' timeStamp = '' text = (str(text.toUtf8()).decode("utf-8")).encode('latin-1') # QString을 str 타입으로 변환 # 옵션 검사 if self.ui.chkb_timeStamp.isChecked() is True: # 타임 스탬프가 Checked 상태라면, timeStamp = '' + time.strftime('%Y-%m-%d %H:%M:%S') if self.ui.chkb_dataLength.isChecked() is True: # 데이터 길이가 Checked 상태라면, dataLen = '' + str(len(text)) + ' Byte(s) ' # Hex 값 표출 창 buf = '<a style="background-color:#e6e6e6;color:black">' + dataLen + timeStamp + '</a><br>' + \ text.encode('hex') + '<br>' if destination == 0: # 송신 self.ui.te_recvHex.moveCursor(QtGui.QTextCursor.End) self.ui.te_recvHex.insertHtml(buf) self.ui.te_recvHex.moveCursor(QtGui.QTextCursor.End) else: # 수신 self.ui.te_sendHex.moveCursor(QtGui.QTextCursor.End) self.ui.te_sendHex.insertHtml(buf) self.ui.te_sendHex.moveCursor(QtGui.QTextCursor.End) # Ascii 값 표출 창 buf = '<a style="background-color:#e6e6e6;color:black">' + dataLen + timeStamp + '</a><br>' + \ text + '<br>' if destination == 0: self.ui.te_recvAscii.moveCursor(QtGui.QTextCursor.End) self.ui.te_recvAscii.insertHtml(buf) self.ui.te_recvAscii.moveCursor(QtGui.QTextCursor.End) else: self.ui.te_sendAscii.moveCursor(QtGui.QTextCursor.End) self.ui.te_sendAscii.insertHtml(buf) self.ui.te_sendAscii.moveCursor(QtGui.QTextCursor.End)
def __init__(self, parent = None): super(displayDataPannel, self).__init__(parent) # __init__(parent)가 아니면 메인에서 본 위젯의 시그널을 받을 수 없음 # 화면 구성 self.ui = Ui_displayPannel() self.ui.setupUi(self)