1
##############################################################################
3
# Copyright (c) 2004 TINY SPRL. (http://tiny.be) All Rights Reserved.
4
# Fabien Pinckaers <fp@tiny.Be>
6
# WARNING: This program as such is intended to be used by professional
7
# programmers who take the whole responsability of assessing all potential
8
# consequences resulting from its eventual inadequacies and bugs
9
# End users who are looking for a ready-to-use solution with commercial
10
# garantees and support are strongly adviced to contract a Free Software
13
# This program is Free Software; you can redistribute it and/or
14
# modify it under the terms of the GNU General Public License
15
# as published by the Free Software Foundation; either version 2
16
# of the License, or (at your option) any later version.
18
# This program is distributed in the hope that it will be useful,
19
# but WITHOUT ANY WARRANTY; without even the implied warranty of
20
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
# GNU General Public License for more details.
23
# You should have received a copy of the GNU General Public License
24
# along with this program; if not, write to the Free Software
25
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27
##############################################################################
36
class spinint(wid_int.wid_int):
37
def __init__(self, name, parent, attrs={}):
38
wid_int.wid_int.__init__(self, name, attrs)
40
self.widget = gtk.HBox(spacing=3)
42
adj1 = gtk.Adjustment(0.0, 0.0, 1000000000, 1.0, 5.0, 5.0)
43
self.spin1 = gtk.SpinButton(adj1, 1, digits=0)
44
self.spin1.set_numeric(True)
45
self.spin1.set_activates_default(True)
46
self.widget.pack_start(self.spin1, expand=False, fill=True)
48
self.widget.pack_start(gtk.Label('-'), expand=False, fill=False)
50
adj2 = gtk.Adjustment(0.0, 0.0, 1000000000, 1.0, 5.0, 5.0)
51
self.spin2 = gtk.SpinButton(adj2, 1, digits=0)
52
self.spin2.set_numeric(True)
53
self.spin2.set_activates_default(True)
54
self.widget.pack_start(self.spin2, expand=False, fill=True)
60
if self.spin1.get_value_as_int() > self.spin2.get_value_as_int():
61
if self.spin2.get_value_as_int() != 0:
62
res.append((self.name, '>=', self.spin2.get_value_as_int()))
63
res.append((self.name, '<=', self.spin1.get_value_as_int()))
65
res.append((self.name, '>=', self.spin1.get_value_as_int()))
66
elif self.spin2.get_value_as_int() > self.spin1.get_value_as_int():
67
res.append((self.name, '<=', self.spin2.get_value_as_int()))
68
res.append((self.name, '>=', self.spin1.get_value_as_int()))
69
elif (self.spin2.get_value_as_int() == self.spin1.get_value_as_int()) and (self.spin1.get_value_as_int() != 0):
70
res.append((self.name, '=', self.spin1.get_value_as_int()))
73
def _value_set(self, value):
74
self.spin1.set_value(value)
75
self.spin2.set_value(value)
77
value = property(_value_get, _value_set, None, _('The content of the widget or ValueError if not valid'))
82
def sig_activate(self, fct):
83
self.spin1.connect_after('activate', fct)
84
self.spin2.connect_after('activate', fct)