pygtk button right/middle click
Wildman
best_lay at yahoo.com
Wed Mar 30 17:37:00 EDT 2016
On Wed, 30 Mar 2016 19:23:35 +0000, Grant Edwards wrote:
> On 2016-03-30, Grant Edwards <invalid at invalid.invalid> wrote:
>> On 2016-03-30, Wildman <best_lay at yahoo.com> wrote:
>>
>>>> Is the gtk button widget really incapable of handling left or middle
>>>> mouse buttons or shift/ctrl/alt modifiers?
>>>
>>> This might help...
>>>
>>> http://faq.pygtk.org/index.py?req=show&file=faq05.004.htp
>>
>> Yep, I found that. I'm just missing the clues required to use those
>> two pieces.
>
> FWIW, I've decided to give up on this. Since it took only a few lines
> of code to handle the "left" click, I assumed that like some other
> toolkits, it would be similarly easy to handle "right" and "middle".
>
> I don't have the time to re-invent the wheel at the moment, so this
> project will have to be postponed.
I'm sorry to say I have no experience using pygtk. My only gui
experience is with Tkinter. In Tk you would do something like
this to trap a right-click.
# create the popup menu and add commands as needed
self.menu = tk.Menu(self, tearoff=0)
self.menu.add_command(label="Whatever",
command=self.do_whatever)
# bind the button with mouse right-click
self.button.bind("<Button-3>", self.popup)
# define the handler for the menu
def do_whatever(self):
# do whatever
# define the popup handler, this displays the menu
def popup(self, event):
self.menu.post(event.x_root, event.y_root)
I posted this on the off chance there might be a way to translate
this to gtk code.
--
<Wildman> GNU/Linux user #557453
"The Constitution only gives people the right to
pursue happiness. You have to catch it yourself."
-Benjamin Franklin
More information about the Python-list
mailing list