Пример #1
0
    def _stepBy(self, steps):
        """try to figure out which digit the cursor is at, and step by one in
        that digit."""

        text = str(self.text())
        cursor = len(text) - self.cursorPosition()

        if '.' not in self.text():
            decimal = 0
        else:
            decimal = len(text) - text.find('.') - 1

        if cursor == decimal:
            return
        if cursor == len(text):
            return

        exp = cursor - decimal
        if cursor > decimal:
            exp -= 1

        delta = 10**exp

        TaurusValueLineEdit._stepBy(self, steps * delta)
        self.setCursorPosition(len(self.text()) - cursor)
        if self._autoApply:
            self.writeValue()  # this seems a but risky...
Пример #2
0
 def throttledWrite(self, delta):
     """Intead of writing to Tango every time the value changes, we start a
     timer. Writes during the timer will be accumulated and when the timer
     runs out, the last value is written.
     """
     TaurusValueLineEdit._stepBy(self, delta)
     if not self._throttle_timer.isActive():
         self._throttle_timer.start()