Re: pygtk button right/middle click

2016-03-30 Thread Wildman via Python-list
On Wed, 30 Mar 2016 19:23:35 +, Grant Edwards wrote:

> On 2016-03-30, Grant Edwards  wrote:
>> On 2016-03-30, Wildman  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=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("", 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.

-- 
 GNU/Linux user #557453
"The Constitution only gives people the right to
pursue happiness. You have to catch it yourself."
  -Benjamin Franklin
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pygtk button right/middle click

2016-03-30 Thread Grant Edwards
On 2016-03-30, Grant Edwards  wrote:
> On 2016-03-30, Wildman  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=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.edwardsYow! I want to mail a
  at   bronzed artichoke to
  gmail.comNicaragua!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pygtk button right/middle click

2016-03-30 Thread Grant Edwards
On 2016-03-30, Wildman  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=faq05.004.htp

Yep, I found that.  I'm just missing the clues required to use those
two pieces.

-- 
Grant Edwards   grant.b.edwardsYow! My face is new, my
  at   license is expired, and I'm
  gmail.comunder a doctor's care
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pygtk button right/middle click

2016-03-30 Thread Wildman via Python-list
On Wed, 30 Mar 2016 15:36:12 +, 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=faq05.004.htp

-- 
 GNU/Linux user #557453
May the Source be with you.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pygtk button right/middle click

2016-03-30 Thread Grant Edwards
On 2016-03-30, Chris Angelico  wrote:
> On Thu, Mar 31, 2016 at 2:36 AM, 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.
>
> 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.edwardsYow! Hmmm ... A hash-singer
  at   and a cross-eyed guy were
  gmail.comSLEEPING on a deserted
   island, when ...
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pygtk button right/middle click

2016-03-30 Thread Chris Angelico
On Thu, Mar 31, 2016 at 2:36 AM, 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.

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
-- 
https://mail.python.org/mailman/listinfo/python-list


pygtk button right/middle click

2016-03-30 Thread Grant Edwards
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.edwardsYow! CHUBBY CHECKER just
  at   had a CHICKEN SANDWICH in
  gmail.comdowntown DULUTH!
-- 
https://mail.python.org/mailman/listinfo/python-list