[maemo-developers] Help with hildon.NumberEditor: IN PYTHON
From: Darren Enns darethehair at gmail.comDate: Wed Apr 2 22:28:39 EEST 2008
- Previous message: packet storing sequence on the device..
- Next message: Help with hildon.NumberEditor: IN PYTHON
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Help please!
I am slowly learning OOP-style PyGTK code, and have recently discovered
how 'nasty' gtk.Spinbutton looks on Maemo :(
OK, so I was just going to make some quick changed to my Python code to
use 'hildon.NumberEditor' instead, but it is not as much a
'drop-in-replacement' as a newbie like me requires...
""" subclass the gtk.Digalog() class to create a new dialog window """
class spin_window(gtk.Dialog) :
value = [0] * SPIN_BUTTON_COUNT
def hildon_set_value(self,widget,index):
self.value[index] = widget.get_value()
return
# a callback to remember the values of the spin buttons.
# the 'index' is setup when connecting the callback
def set_value(self,widget,index):
self.value[index] = widget.get_value_as_int()
return
def __init__(self,window):
# init the parent class to create the dialog
super(spin_window, self).__init__("set spin values", window,
gtk.DIALOG_DESTROY_WITH_PARENT |
gtk.DIALOG_MODAL,
(gtk.STOCK_OK, gtk.RESPONSE_OK))
number_editor = hildon.NumberEditor(-90,90)
#number_editor.connect("changed",self.set_value, 0)
#number_editor.connect("notify::value",self.set_value, 0)
number_editor.connect("notify::value",self.hildon_set_value,0)
number_editor.set_value(0)
self.vbox.pack_start(number_editor)
self.value[0] = 0
number_editor.show()
label = gtk.Label('Latitude Degrees:')
self.vbox.pack_start(label)
#label.modify_font(pango.FontDescription("sans 30"))
label.show()
adjustment = gtk.Adjustment(0, -90, 90, 1, 1, 1)
spinbutton = gtk.SpinButton(adjustment,0,0)
spinbutton.connect("changed",self.set_value, 1)
self.vbox.pack_start(spinbutton)
self.value[1] = 0
spinbutton.show()
...
Notice my feeble attempts to add 'special' code for the numbereditor --
but the code above does not work:
"TypeError: hildon_set_value() takes exactly 3 arguments (4 given)"
So I am getting all confused! It *looks* like I am using the correct
signal value, and passing three parameters...
There are very few Python examples out on Google for me to learn the
solution with.
Thanks
Dare
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maemo.org/pipermail/maemo-developers/attachments/20080402/4ee72aaa/attachment.htm
- Previous message: packet storing sequence on the device..
- Next message: Help with hildon.NumberEditor: IN PYTHON
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
