[pygtk] Rewrite behaviour on signal 'button_press_event' in treeview

philopensource at hotmail.com philopensource at hotmail.com
Mon Sep 12 16:14:32 WST 2005


Nikos Kouremenos wrote:

> On 9/9/05, philopensource at hotmail.com <philopensource at hotmail.com> wrote:
>  
>
>> Hi list,
>>
>> I need to select multiple rows from a treeview, drag and drop them to
>> another treeview.
>> The problem is when i click on a selected row, the other rows previously
>> selected are deselected.
>> But i want to keep them selected for the drag & drop !
>>
>> 1. Is there a way to do it without rewriting callback for
>> 'button_press_event_signal'?
>>   
>
>
> google and/or looking at API would have gave you a faster answer:
> http://pygtk.org/pygtk2reference/class-gtktreeselection.html#method-gtktreeselection--set-mode 
>
>
> so you before everything
> treeview.get_selection().set_mode()
>  
>
Thanks for your answer.
Nevertheless, of course i looked first in the pygtk2reference and i 
already use treeview.get_selection().set_mode().
       self.treeSelection = self.get_selection()
       self.treeSelection.set_mode(gtk.SELECTION_MULTIPLE)
This works only for selecting rows in a treeview. It has no effects on 
drag&drop behaviour.

>> When i try to rewrite the callback, i need to know the iter or the path
>> of the row i clicked on with the stuff given by the 'button-press_event'
>> signal (treeview, event)
>> 2. How can i do this?
>> I try to use event.x and event.y but it's only the position of the click
>> in the treeview area. No link with data inside.
>> So i must know what are the rows actually displayed in the treeview (due
>> to the use of a scrollbar), which position have each row.
>> It's not very obvious.
>>   
>
>
> why do u use button_press_event and not sth better?
>
> renderer_text.connect('edited',
>
> and you get to have cell, path, text in the CB
>
> read the tutorial/api on treeview
>
>  
>
I use button_press_event because my problem is due to drag & drop which 
happen only with button press_event.
Have you ever tryied drag and drop several rows from a treeview?
I think you should be surprised on the result even if you use 
set_mode(gtk.SELECTION_MULTIPLE) or

connect('edited',....

I read the tutorial api before contacting list but found no answers.
Is there any solution?

>> Thanks a lot,
>> Philippe Collet
>>   
>
> have fun
>
Cheers,
Philippe Collet



More information about the pygtk mailing list