Esempio n. 1
0
 def _key_press(self, widget, gevent):
     kval = gevent.keyval
     kname = gdk.keyval_name(kval).lower()
     size = len(self.field)
     sep = self.field.sep
     step_inc, page_inc = self.get_increments()
     if kname in ('up', 'down', 'page_up', 'page_down', 'left', 'right'):
         if not self.get_editable():
             return True
         if kname in ('left', 'right'):
             return False
             #if not self.arrow_select:
             #	return False
             #shift = {
             #	'left': -1,
             #	'right': 1
             #}[kname]
             #FIXME
         else:
             p = {
                 'up': step_inc,
                 'down': -step_inc,
                 'page_up': page_inc,
                 'page_down': -page_inc,
             }[kname]
             self.entry_plus(p)
         #from scal2.utils import strFindNth
         #if fieldIndex==0:
         #	i1 = 0
         #else:
         #	i1 = strFindNth(text, sep, fieldIndex) + len(sep)
         #i2 = strFindNth(text, sep, fieldIndex+1)
         ##self.grab_focus()
         #self.select_region(i1, i2)
         return True
     #elif kname=='return':## Enter
     #	self.update()
     #	##self.emit('activate')
     #	return True
     elif ord('0') <= kval <= ord('9'):
         self.insertText(self.digs[kval - ord('0')])
         return True
     elif 'kp_0' <= kname <= 'kp_9':
         self.insertText(self.digs[int(kname[-1])])
         return True
     elif kname in (
             'period',
             'kp_decimal',
     ):
         self.insertText(locale_man.getNumSep())
         return True
     else:
         #print(kname, kval)
         return False
Esempio n. 2
0
 def _key_press(self, widget, gevent):
     kval = gevent.keyval
     kname = gdk.keyval_name(kval).lower()
     size = len(self.field)
     sep = self.field.sep
     step_inc, page_inc = self.get_increments()
     if kname in ('up', 'down', 'page_up', 'page_down', 'left', 'right'):
         if not self.get_editable():
             return True
         if kname in ('left', 'right'):
             return False
             #if not self.arrow_select:
             #    return False
             #shift = {
             #    'left': -1,
             #    'right': 1
             #}[kname]
             #FIXME
         else:
             p = {
                 'up': step_inc,
                 'down': -step_inc,
                 'page_up': page_inc,
                 'page_down': -page_inc,
             }[kname]
             self.entry_plus(p)
         #if fieldIndex==0:
         #    i1 = 0
         #else:
         #    i1 = strFindNth(text, sep, fieldIndex) + len(sep)
         #i2 = strFindNth(text, sep, fieldIndex+1)
         ##self.grab_focus()
         #self.select_region(i1, i2)
         return True
     #elif kname=='return':## Enter
     #    self.update()
     #    ##self.emit('activate')
     #    return True
     elif ord('0') <= kval <= ord('9'):
         self.insertText(self.digs[kval-ord('0')])
         return True
     elif 'kp_0' <= kname <= 'kp_9':
         self.insertText(self.digs[int(kname[-1])])
         return True
     elif kname in (
         'period', 'kp_decimal',
         'slash', 'kp_divide',## FIXME
     ):
         self.insertText(locale_man.getNumSep())
         return True
     else:
         #print kname, kval
         return False
Esempio n. 3
0
 def __init__(self, _min, _max, digNum, **kwargs):
     if digNum < 1:
         raise ValueError('FloatSpinButton: invalid digNum=%r'%digNum)
     self.digNum = digNum
     self.digDec = 10**digNum
     self._min = _min
     self._max = _max
     MultiSpinButton.__init__(
         self,
         locale_man.getNumSep(),
         (
             IntField(int(_min), int(_max)),
             IntField(0, self.digDec-1, digNum),
         ),
         **kwargs
     )