~openerp-commiter/openobject-client/6.0-opw-381574-nch

« back to all changes in this revision

Viewing changes to bin/widget/view/form_gtk/spinbutton.py

  • Committer: olt at tinyerp
  • Date: 2011-12-20 12:45:48 UTC
  • mfrom: (1908.1.2 client)
  • Revision ID: olt@tinyerp.com-20111220124548-isv5jkokqfdsjeh9
[MERGE] opw 879119

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
        self.widget.connect('activate', self.sig_activate)
41
41
        self.widget.connect('input', self.format_input)
42
42
        self.widget.connect('output', self.format_output)
 
43
        self.widget.connect('insert-text', self._on_insert_text)
 
44
    
 
45
    def _on_insert_text(self, editable, value, length, position):
 
46
        text = self.widget.get_text()
 
47
        if value:
 
48
            current_pos = self.widget.get_position()
 
49
            new_text = text[:current_pos] + value + text[current_pos:]
 
50
            digits = self.widget.get_digits()
 
51
            try:
 
52
                spin_value = user_locale_format.str2float(new_text)
 
53
                new_spin_value = user_locale_format.format('%.' + str(digits) + 'f', spin_value)
 
54
            except:
 
55
                self.widget.set_text(text)
 
56
                self.widget.stop_emission('insert-text')
 
57
                self.widget.show()
 
58
        return
43
59
 
44
60
    def format_output(self, spin):
45
61
        digits = spin.get_digits()