Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #106115

Re: pygtk button right/middle click

From Wildman <best_lay@yahoo.com>
Subject Re: pygtk button right/middle click
Newsgroups comp.lang.python
References <ndgrpc$6kh$1@reader1.panix.com> <U8GdnQBnn4yPu2HLnZ2dnUU7-fednZ2d@giganews.com> <ndh8vs$5kd$1@reader1.panix.com> <ndh93n$d6c$1@reader1.panix.com>
Organization Wildman Productions
Message-ID <zfCdnbL_nPth22HLnZ2dnUU7-XWdnZ2d@giganews.com> (permalink)
Date 2016-03-30 16:37 -0500

Show all headers | View raw


On Wed, 30 Mar 2016 19:23:35 +0000, Grant Edwards wrote:

> On 2016-03-30, Grant Edwards <invalid@invalid.invalid> wrote:
>> On 2016-03-30, Wildman <best_lay@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

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

pygtk button right/middle click Grant Edwards <invalid@invalid.invalid> - 2016-03-30 15:36 +0000
  Re: pygtk button right/middle click Chris Angelico <rosuav@gmail.com> - 2016-03-31 02:58 +1100
    Re: pygtk button right/middle click Grant Edwards <invalid@invalid.invalid> - 2016-03-30 17:44 +0000
  Re: pygtk button right/middle click Wildman <best_lay@yahoo.com> - 2016-03-30 14:16 -0500
    Re: pygtk button right/middle click Grant Edwards <invalid@invalid.invalid> - 2016-03-30 19:21 +0000
      Re: pygtk button right/middle click Grant Edwards <invalid@invalid.invalid> - 2016-03-30 19:23 +0000
        Re: pygtk button right/middle click Wildman <best_lay@yahoo.com> - 2016-03-30 16:37 -0500

csiph-web