- self.setMarkedPos(self.currPos)
- self.setText(self.text)
- #self.setText(self.text[0:self.currPos] + "_" + self.text[self.currPos] + "_" + self.text[self.currPos + 1:])
+ if self.visible_width:
+ if self.currPos < self.offset:
+ self.offset = self.currPos
+ if self.currPos >= self.offset + self.visible_width:
+ if self.currPos == len(self.Text):
+ self.offset = self.currPos - self.visible_width
+ else:
+ self.offset = self.currPos - self.visible_width + 1
+ if self.offset > 0 and self.offset + self.visible_width > len(self.Text):
+ self.offset = max(0, len(self.Text) - self.visible_width)
+ if self.allmarked:
+ self.setMarkedPos(-2)
+ else:
+ self.setMarkedPos(self.currPos-self.offset)
+ if self.visible_width:
+ if self.type == self.PIN:
+ self.text = ""
+ for x in self.Text[self.offset:self.offset+self.visible_width]:
+ self.text += (x==" " and " " or "*")
+ else:
+ self.text = self.Text[self.offset:self.offset+self.visible_width].encode("utf-8") + " "
+ else:
+ if self.type == self.PIN:
+ self.text = ""
+ for x in self.Text:
+ self.text += (x==" " and " " or "*")
+ else:
+ self.text = self.Text.encode("utf-8") + " "
+
+ def setText(self, text):
+ if not len(text):
+ self.currPos = 0
+ self.Text = u""
+ else:
+ try:
+ self.Text = text.decode("utf-8")
+ except UnicodeDecodeError:
+ print "utf8 kaputt!"
+ self.Text = text
+ self.update()
+
+ def getText(self):
+ return self.Text.encode("utf-8")