~openerp-dev/openobject-client/trunk-bug-885581-rga

« back to all changes in this revision

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

  • Committer: Naresh(OpenERP)
  • Date: 2011-11-14 06:25:49 UTC
  • mfrom: (1985.1.2 client)
  • Revision ID: nch@tinyerp.com-20111114062549-y8arx381sb7t146j
[MERGE]

Show diffs side-by-side

added added

removed removed

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