Made numpad locale aware
This commit is contained in:
1 parent
0998086668
commit
c8cf74f88e
3 files changed
+25
-2
No files matched your search
@@ -1,3 +1,4 @@
|
||||
* Made numpad locale aware
|
||||
* Add open button on binary and image widgets
|
||||
* Hide buttons on image widget if readonly
|
||||
* Added a connection manager à la gajim
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
#This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
#this repository contains the full copyright notices and license terms.
|
||||
import gtk
|
||||
import gobject
|
||||
from cellrendererinteger import CellRendererInteger
|
||||
import locale
|
||||
from cellrendererinteger import CellRendererInteger
|
||||
|
||||
|
||||
class CellRendererFloat(CellRendererInteger):
|
||||
@@ -11,6 +12,19 @@ class CellRendererFloat(CellRendererInteger):
|
||||
super(CellRendererFloat, self).__init__()
|
||||
self.digits = (16, 2)
|
||||
|
||||
def on_start_editing(self, event, widget, path, background_area,
|
||||
cell_area, flags):
|
||||
editable = super(CellRendererInteger, self).on_start_editing(event,
|
||||
widget, path, background_area, cell_area, flags)
|
||||
editable.connect('key-press-event', self.key_press_event)
|
||||
return editable
|
||||
|
||||
def key_press_event(self, widget, event):
|
||||
for name in ('KP_Decimal', 'KP_Separator'):
|
||||
if event.keyval == gtk.gdk.keyval_from_name(name):
|
||||
event.keyval = int(gtk.gdk.unicode_to_keyval(
|
||||
ord(locale.localeconv()['decimal_point'])))
|
||||
|
||||
def sig_insert_text(self, entry, new_text, new_text_length, position):
|
||||
value = entry.get_text()
|
||||
position = entry.get_position()
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
#this repository contains the full copyright notices and license terms.
|
||||
from integer import Integer
|
||||
import gtk
|
||||
import locale
|
||||
from integer import Integer
|
||||
|
||||
|
||||
class Float(Integer):
|
||||
@@ -11,6 +12,7 @@ class Float(Integer):
|
||||
super(Float, self).__init__(field_name, model_name, window,
|
||||
attrs=attrs)
|
||||
self.digits = (16, 2)
|
||||
self.entry.connect('key-press-event', self.key_press_event)
|
||||
|
||||
def set_value(self, record, field):
|
||||
try:
|
||||
@@ -32,6 +34,12 @@ class Float(Integer):
|
||||
self.entry.set_text(locale.format('%.' + str(digits[1]) + 'f',
|
||||
field.get(record) or 0.0, True))
|
||||
|
||||
def key_press_event(self, widget, event):
|
||||
for name in ('KP_Decimal', 'KP_Separator'):
|
||||
if event.keyval == gtk.gdk.keyval_from_name(name):
|
||||
event.keyval = int(gtk.gdk.unicode_to_keyval(
|
||||
ord(locale.localeconv()['decimal_point'])))
|
||||
|
||||
def sig_insert_text(self, entry, new_text, new_text_length, position):
|
||||
value = entry.get_text()
|
||||
position = entry.get_position()
|
||||
|
||||
Reference in new issue
Block a user