def encodingChanged(self, idx):
encoding = str(self.mode_combo.currentText())
validator = None
if encoding == 'hex':
# only clear the box if there are non-hex chars
# before setting the validator.
txt = str(self.data_edit.text())
if not all(c in string.hexdigits for c in txt):
self.data_edit.setText('')
regex = QtCore.QRegExp('^[0-9A-Fa-f]+$')
validator = QtWidgets.QRegExpValidator(regex)
self.data_edit.setValidator(validator)
txt = str(self.data_edit.text())
txt_encoded = self.encodeData(txt, encoding)
self.updateHexPreview(txt_encoded)
评论列表
文章目录