maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   Hildon TouchSelector Signal problem ? (https://talk.maemo.org/showthread.php?t=62798)

Tetsuo6995 2010-09-23 14:38

Hildon TouchSelector Signal problem ?
 
Hi !

I'am currently developping a Python App for the N900.
The interface is based on PyGTK and Hildon (some parts are made in Glade).

I'am having some trouble with the Hildon Widget TouchSelector.

This widget has two signals:
(Quoting from Hildon Reference manual)
Quote:

"changed" : The “changed” signal is emitted when the active item on any column is changed. This can be due to the user selecting a different item from the list, or due to a call to select_iter() on one of the columns.

“columns-changed” signal is emitted when the number of columns in the TouchSelector change.
When i try to use the "changed" signal, he is everytime emited 3 times in a row. Is this a bug ? (searched through the reported bugs and found nothing related) Or it's only me who got something wrong in my code ?

Anyway here is a sample of my code so you can give me your opinion :)

Code:

        # All the code below, comes from a class named "inventory" which is the "main" class of the app.

        # Creating the picker button
        self.dep_button = hildon.PickerButton(gtk.HILDON_SIZE_AUTO,
                                        hildon.BUTTON_ARRANGEMENT_VERTICAL)
        self.dep_button.set_title("Département")
       
        # Creating the actual TouchSelector widget and connecting the "changed"               
        self.selector = hildon.TouchSelectorEntry(text=True)
        self.selector.connect("changed", self.selection_changed)
       
 
     
        # Reading a CSV file containing somes informations....
        cr = csv.reader(open("/usr/share/inventaire/departements.csv","rb"))
        for row in cr:
            #print row[1]+row[0]
            self.selector.append_text(row[2]+" - "+row[1])
       
     
        # Attach the touch selector to the picker button
        self.bottom_bar = self.interface.get_object("bottom_bar")
        self.bottom_bar.add(self.dep_button)
        self.dep_button.set_selector(self.selector)


    def selection_changed(self, column, user_data):
       
        # Deactivated the append_text because i thought it could be the cause of the self "self-replicating" signal
        #self.selector.append_text("LOOOOOOOOOOOOOOOOOOOOOOL")
        #print user_data
        # Begining of the signal event       
        print "a"
        print "b"
        # End of the signal event

Everytime i tap on an item of the TouchSelector and select it, i get the following output in the terminal:

Code:

a
b
a
b
a
b

I really can't find any reason why this signal is emited 3 times for a single unique selection...

Here is the documentation i used as reference:
Hildon Reference Manual
UI Tutorial : Data Selection

Thanks for your help :)

TeT

bruno.araujo 2010-09-24 00:48

Re: Hildon TouchSelector Signal problem ?
 
Hi,

Can you provide a small test program which exibits the problem stated? This will make debugging much easier. Also, have you tried to reproduce the problem in C?

If you believe this problem is a bug in PyGTK/python-hildon, you can file a bug here [1].

[1] https://bugs.maemo.org/enter_bug.cgi?product=PyMaemo

Tetsuo6995 2010-09-24 14:41

Re: Hildon TouchSelector Signal problem ?
 
Hi !
I made a simple test file to reproduce the ""bug"".

Just copy/paste it to your phone, and launch it:
Code:

python bug.py
I'am filling a bug report just in case.

This clean simple test file makes me even more confident that it's not my mistake here.

Thanks :)

PS: Couldn't upload the python source file so here is the code straight in the post :

Code:

#!/usr/bin/python
# -*- coding: utf-8 -*-

import gtk

import pygtk

import hildon


class inventory:
    def __init__(self):
       
        self.main_window = hildon.StackableWindow()
        self.dep_button = hildon.PickerButton(gtk.HILDON_SIZE_AUTO,
                                        hildon.BUTTON_ARRANGEMENT_VERTICAL)
        self.dep_button.set_title("test")
        self.selector = hildon.TouchSelectorEntry(text=True)
        self.selector.connect("changed", self.selection_changed)
       
        for i in range(5):
            self.selector.append_text(str(i))
       
        self.main_window.add(self.dep_button)
        self.dep_button.set_selector(self.selector)

        self.main_window.show_all()

    def selection_changed(self, column, user_data):
        print "Begining the signal event"
        print "End of the signal event"
       
       
if __name__ == "__main__":
    inventory()
    gtk.main()


rambo 2010-09-24 17:43

Re: Hildon TouchSelector Signal problem ?
 
it might be that the current selection is deactivated, then new selection activated but that would account for two signals only. (now in train so cvant do proper checking

Tetsuo6995 2010-09-27 08:21

Re: Hildon TouchSelector Signal problem ?
 
Corresponding bug report.

Tetsuo6995 2010-09-28 09:20

Re: Hildon TouchSelector Signal problem ?
 
Up !

Can anyone just try my small testing program and confirm me there is something strange going on ?


All times are GMT. The time now is 03:17.

vBulletin® Version 3.8.8