[POS-commit] r230 - in Kiwi2: Kiwi2/Widgets gazpacho-plugin/pixmaps tests

Gustavo Matheus Rahal gustavo at async.com.br
Tue Mar 29 16:24:14 BRT 2005


Author: gustavo
Date: 2005-03-29 16:24:14 -0300 (Tue, 29 Mar 2005)
New Revision: 230

Added:
   Kiwi2/Kiwi2/Widgets/SpinButton.py
   Kiwi2/gazpacho-plugin/pixmaps/kiwispinbutton.png
   Kiwi2/tests/test_SpinButton.py
Log:
forgotten files of revision 229 commit

Added: Kiwi2/Kiwi2/Widgets/SpinButton.py
===================================================================
--- Kiwi2/Kiwi2/Widgets/SpinButton.py	2005-03-29 19:22:26 UTC (rev 229)
+++ Kiwi2/Kiwi2/Widgets/SpinButton.py	2005-03-29 19:24:14 UTC (rev 230)
@@ -0,0 +1,58 @@
+#!/usr/bin/env python
+#
+# Kiwi: a Framework and Enhanced Widgets for Python
+#
+# Copyright (C) 2003-2004 Async Open Source
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+# 
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+# 
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
+# USA
+# 
+# Author(s): Christian Reis <kiko at async.com.br>
+#
+
+from Kiwi2.initgtk import gtk, gobject
+from Kiwi2.Widgets.WidgetProxy import WidgetProxyMixin, implementsIProxy
+from Kiwi2.utils import gsignal, gproperty
+
+
+class SpinButton(gtk.SpinButton, WidgetProxyMixin):
+    implementsIProxy()
+    gsignal('value-changed', 'override')
+
+    def __init__(self):
+        # since the default data_type is str we need to set it to int or float for spinbuttons
+        WidgetProxyMixin.__init__(self, data_type=int)
+        gtk.SpinButton.__init__(self)
+        self._data_value = ''
+    
+    def set_data_type(self, data_type):
+        if data_type == int or data_type == float:
+            WidgetProxyMixin.set_data_type(self, data_type)
+        else:
+            raise TypeError, "SpinButtons only accept integer or float values"
+        
+    def do_value_changed(self):
+        self.emit('content-changed')
+        self.chain()
+
+    def read(self):
+        self.get_value()
+
+    def update(self, data):
+        # first, trigger some basic validation
+        WidgetProxyMixin.update(self, data)
+        self.set_value(data)
+
+gobject.type_register(SpinButton)

Added: Kiwi2/gazpacho-plugin/pixmaps/kiwispinbutton.png
===================================================================
(Binary files differ)


Property changes on: Kiwi2/gazpacho-plugin/pixmaps/kiwispinbutton.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: Kiwi2/tests/test_SpinButton.py
===================================================================
--- Kiwi2/tests/test_SpinButton.py	2005-03-29 19:22:26 UTC (rev 229)
+++ Kiwi2/tests/test_SpinButton.py	2005-03-29 19:24:14 UTC (rev 230)
@@ -0,0 +1,17 @@
+#!/usr/bin/env python
+from utils import refresh_gui
+
+from Kiwi2.Widgets import SpinButton
+
+import unittest
+
+class SpinButtonTest(unittest.TestCase):
+    def testForIntFloat(self):
+        mySpinBtn = SpinButton()
+        self.assertEqual(mySpinBtn.get_property("data-type"), int)
+
+        # this test doens't work... maybe be a pygtk bug
+        #self.assertRaises(TypeError, mySpinBtn.set_property, 'data-type', int)
+        
+if __name__ == '__main__':
+    unittest.main()



More information about the POS-commit mailing list