diff --git a/src/apim.py b/src/apim.py index 4cf6a8a..21a86cf 100644 --- a/src/apim.py +++ b/src/apim.py @@ -210,7 +210,7 @@ def launch_qt(self): self.button_open = QPushButton("Open File ...") self.button_open.clicked.connect(self.open_file) self.button_exit = QPushButton("Exit") - self.button_exit.clicked.connect(exit) + self.button_exit.clicked.connect(sys.exit) self.main_layout.addWidget(self.button_open) self.main_layout.addWidget(self.button_exit) diff --git a/src/encoder.py b/src/encoder.py index e86018e..3580a01 100644 --- a/src/encoder.py +++ b/src/encoder.py @@ -384,40 +384,27 @@ def format(self, ab1, ab2=None): def combo_change(box, item, bitfieldblock, *args, **kwargs): value = box.currentIndex() - print("changed to %d" % (value)) - print(args) - print(kwargs) - print(bitfieldblock.text()) data = int(bitfieldblock.text(), 16) bitdata = '{0:08b}'.format(data) bitdata = bitdata[:item['bit']] + ("{0:0%db}" % (item['size'])).format(value) + bitdata[item['bit']+item['size']:] data = int(bitdata, 2) - print(bitdata) - print(data) + bitfieldblock.setText("%02X" % (data)) def value_change(box, item, bitfieldblock, *args, **kwargs): value = float(box.text()) - print("changed to %d" % (value)) - print(args) - print(kwargs) - print(bitfieldblock[0].text()) - if len(bitfieldblock) > 1: - print(bitfieldblock[1].text()) + if value > item['max']: value = item['max'] elif value < item['min']: value = item['min'] v = ((value - item['offset']) / item['multiplier']) - print(v) box.setText("%.2f" % value) data = int(bitfieldblock[0].text(), 16) if len(bitfieldblock) == 1 else int(bitfieldblock[0].text() + bitfieldblock[1].text(), 16) bitdata = ('{0:0%db}' % (item['size'])).format(data) bitdata = bitdata[:item['bit']] + ("{0:0%db}" % (item['size'])).format(int(v)) + bitdata[item['bit']+item['size']:] data = int(bitdata, 2) - print(bitdata) - print(data) string = "%04X" % (data) if item['size'] > 8: bitfieldblock[0].setText(string[:2]) @@ -427,7 +414,9 @@ def value_change(box, item, bitfieldblock, *args, **kwargs): def ascii_change(box, item, bitfieldblock, *args, **kwargs): - pass + value = box.text() + #bitdata = bitdata[:item['bit']] + ("{0:0%db}" % (item['size'])).format(value) + bitdata[item['bit']+item['size']:] + bitfieldblock.setText("%02X" % (ord(value[0]))) class ItemEncoder(object): items = []