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


Groups > comp.lang.python > #106085 > unrolled thread

pygtk button right/middle click

Started byGrant Edwards <invalid@invalid.invalid>
First post2016-03-30 15:36 +0000
Last post2016-03-30 16:37 -0500
Articles 7 — 3 participants

Back to article view | Back to comp.lang.python


Contents

  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

#106085 — pygtk button right/middle click

FromGrant Edwards <invalid@invalid.invalid>
Date2016-03-30 15:36 +0000
Subjectpygtk button right/middle click
Message-ID<ndgrpc$6kh$1@reader1.panix.com>
I'm trying to figure out how to get a pygtk button respond to
somehting other than just a simple "left click".  With a standard
3-button mouse, X11 provides at least 9 different "click" types, but
the pygtk button only seems to support one of them.

[Yes, I know there are left-handled mouse configurations -- by "left"
click I'm using the common term to mean the primary mouse button.]

After googling for some time, I haven't found any good answers.  Some
people just say things like "use the button_release_event signal of
the button widget".

But, that signal is depricated (and AFAICT still doesn't make the
button actually respond to the left/middle click by "depressing" the
way it should).

Other answers are things like "you'll have to write you own button
class in C, not C++".

Is the gtk button widget really incapable of handling left or middle
mouse buttons or shift/ctrl/alt modifiers?

-- 
Grant Edwards               grant.b.edwards        Yow! CHUBBY CHECKER just
                                  at               had a CHICKEN SANDWICH in
                              gmail.com            downtown DULUTH!

[toc] | [next] | [standalone]


#106089

FromChris Angelico <rosuav@gmail.com>
Date2016-03-31 02:58 +1100
Message-ID<mailman.214.1459353494.28225.python-list@python.org>
In reply to#106085
On Thu, Mar 31, 2016 at 2:36 AM, Grant Edwards <invalid@invalid.invalid> wrote:
> I'm trying to figure out how to get a pygtk button respond to
> somehting other than just a simple "left click".  With a standard
> 3-button mouse, X11 provides at least 9 different "click" types, but
> the pygtk button only seems to support one of them.

You're looking at a couple of different, but related, things. The
clicked() event means "the button was activated", which might have
been caused by a mouse event, or possibly a keyboard or other
activation.

What you want is to react to other forms of mouse event. For that, you
should be able to hook the generic widget handling...

> After googling for some time, I haven't found any good answers.  Some
> people just say things like "use the button_release_event signal of
> the button widget".

... which is what this is talking about. What you'll get is button
press and release events, and it'll be up to you to figure out if they
represent clicks or not. But you'll get events for every mouse button
that way.

ChrisA

[toc] | [prev] | [next] | [standalone]


#106100

FromGrant Edwards <invalid@invalid.invalid>
Date2016-03-30 17:44 +0000
Message-ID<ndh39a$dt5$1@reader1.panix.com>
In reply to#106089
On 2016-03-30, Chris Angelico <rosuav@gmail.com> wrote:
> On Thu, Mar 31, 2016 at 2:36 AM, Grant Edwards <invalid@invalid.invalid> wrote:
>> I'm trying to figure out how to get a pygtk button respond to
>> somehting other than just a simple "left click".  With a standard
>> 3-button mouse, X11 provides at least 9 different "click" types, but
>> the pygtk button only seems to support one of them.
>
> You're looking at a couple of different, but related, things. The
> clicked() event means "the button was activated", which might have
> been caused by a mouse event, or possibly a keyboard or other
> activation.

Right.

> What you want is to react to other forms of mouse event. For that,
> you should be able to hook the generic widget handling...

So I've got to re-implement all the low-level stuff that the button
already does for the "left" button (changing appearance on
button-press and restoring it on button-release), calling the handler,
etc.  I sure seems like the batteries are missing...

-- 
Grant Edwards               grant.b.edwards        Yow! Hmmm ... A hash-singer
                                  at               and a cross-eyed guy were
                              gmail.com            SLEEPING on a deserted
                                                   island, when ...

[toc] | [prev] | [next] | [standalone]


#106105

FromWildman <best_lay@yahoo.com>
Date2016-03-30 14:16 -0500
Message-ID<U8GdnQBnn4yPu2HLnZ2dnUU7-fednZ2d@giganews.com>
In reply to#106085
On Wed, 30 Mar 2016 15:36:12 +0000, Grant Edwards wrote:

> I'm trying to figure out how to get a pygtk button respond to
> somehting other than just a simple "left click".  With a standard
> 3-button mouse, X11 provides at least 9 different "click" types, but
> the pygtk button only seems to support one of them.
> 
> [Yes, I know there are left-handled mouse configurations -- by "left"
> click I'm using the common term to mean the primary mouse button.]
> 
> After googling for some time, I haven't found any good answers.  Some
> people just say things like "use the button_release_event signal of
> the button widget".
> 
> But, that signal is depricated (and AFAICT still doesn't make the
> button actually respond to the left/middle click by "depressing" the
> way it should).
> 
> Other answers are things like "you'll have to write you own button
> class in C, not C++".
> 
> 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

-- 
<Wildman> GNU/Linux user #557453
May the Source be with you.

[toc] | [prev] | [next] | [standalone]


#106107

FromGrant Edwards <invalid@invalid.invalid>
Date2016-03-30 19:21 +0000
Message-ID<ndh8vs$5kd$1@reader1.panix.com>
In reply to#106105
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.

-- 
Grant Edwards               grant.b.edwards        Yow! My face is new, my
                                  at               license is expired, and I'm
                              gmail.com            under a doctor's care!!!!

[toc] | [prev] | [next] | [standalone]


#106108

FromGrant Edwards <invalid@invalid.invalid>
Date2016-03-30 19:23 +0000
Message-ID<ndh93n$d6c$1@reader1.panix.com>
In reply to#106107
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.

-- 
Grant Edwards               grant.b.edwards        Yow! I want to mail a
                                  at               bronzed artichoke to
                              gmail.com            Nicaragua!

[toc] | [prev] | [next] | [standalone]


#106115

FromWildman <best_lay@yahoo.com>
Date2016-03-30 16:37 -0500
Message-ID<zfCdnbL_nPth22HLnZ2dnUU7-XWdnZ2d@giganews.com>
In reply to#106108
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

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web