'str' object has no attribute 'chop'
Solved
Mobile and Embedded
-
Hi,
I'm working on a pin tab which has a key to undo the last entered digit, my on click function looks something like:def on_click(self,val): if val == DEL: pin = self.pinlab.text() self.pinlab.setText(pin.chop(1)) else: self.pinlab.setText(self.pinlab.text() + str (val))
but it somehow doesn't like the usage of
chop(1)
, I keep getting:AttributeError: 'str' object has no attribute 'chop'
What am I doing wrong, could anyone here point out my mistake?
-
Hi,
You write your code as if you where using QString objects. With either PySide2 or PyQt5 you'll have Python str objects. You need to translate these bits.
-
@SGaist said in 'str' object has no attribute 'chop':
Hi,
You write your code as if you where using QString objects. With either PySide2 or PyQt5 you'll have Python str objects. You need to translate these bits.
rrrrrrright, Duh!
I'm still kind of new to writing Qt in Python...
changing my code to usingpin[:-1]
works as expected! Thanks!