Quantcast

Python 3.2 and binding Mousewheel on Mac

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Python 3.2 and binding Mousewheel on Mac

Michael O'Donnell
Hi All,

  I am on Macosx Lion running Python 3.2.3 and Tkinter 8.5

The following  code breaks on my machine, and given
search on the web, has been breaking in different forms since
2005.

#========
from tkinter import *
def _onMouseWheel(event):
    print(event)

root = Tk()
root.bind('<MouseWheel>',_onMouseWheel)
root.mainloop()
#=======

On my machine works under python 2.7.2.

I thought this would be fixed by now. Does anyone know
anything about it?

Mick
_______________________________________________
Tkinter-discuss mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/tkinter-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Python 3.2 and binding Mousewheel on Mac

Kevin Walzer-5
On 4/20/12 8:05 AM, Michael O'Donnell wrote:
> Hi All,
>
>    I am on Macosx Lion running Python 3.2.3 and Tkinter 8.5
>
> The following  code breaks on my machine, and given
> search on the web, has been breaking in different forms since
> 2005.
>
Using the similar code on 10.7.3 with Python 2.7.1, here's the output I get:

<Tkinter.Event instance at 0x10178cab8>
<Tkinter.Event instance at 0x10178cab8>
<Tkinter.Event instance at 0x10178cab8>
<Tkinter.Event instance at 0x10178cab8>
<Tkinter.Event instance at 0x10178cab8>
<Tkinter.Event instance at 0x10178cab8>
<Tkinter.Event instance at 0x10178cab8>
<Tkinter.Event instance at 0x10178cab8>
<Tkinter.Event instance at 0x10178cab8>

Seems fine to me. What are you seeing with 3.2?

--Kevin

--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
_______________________________________________
Tkinter-discuss mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/tkinter-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Python 3.2 and binding Mousewheel on Mac

Lion Kimbro-2
In reply to this post by Michael O'Donnell

  Not the answer but a data point:

  Windows 7  Python 3.2.2  -- worked fine


_______________________________________________
Tkinter-discuss mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/tkinter-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Python 3.2 and binding Mousewheel on Mac

Michael O'Donnell
In reply to this post by Kevin Walzer-5
Hi Kevin,

   As I mentioned in my email, the code worked fine for me too
under 2.7.3. This matches diagnoses of the problem in 2011.

I just thought, a year later, the problem would be fixed.

Mick

On Fri, Apr 20, 2012 at 10:39 PM, Kevin Walzer <[hidden email]> wrote:

> On 4/20/12 8:05 AM, Michael O'Donnell wrote:
>>
>> Hi All,
>>
>>   I am on Macosx Lion running Python 3.2.3 and Tkinter 8.5
>>
>> The following  code breaks on my machine, and given
>> search on the web, has been breaking in different forms since
>> 2005.
>>
> Using the similar code on 10.7.3 with Python 2.7.1, here's the output I get:
>
> <Tkinter.Event instance at 0x10178cab8>
> <Tkinter.Event instance at 0x10178cab8>
> <Tkinter.Event instance at 0x10178cab8>
> <Tkinter.Event instance at 0x10178cab8>
> <Tkinter.Event instance at 0x10178cab8>
> <Tkinter.Event instance at 0x10178cab8>
> <Tkinter.Event instance at 0x10178cab8>
> <Tkinter.Event instance at 0x10178cab8>
> <Tkinter.Event instance at 0x10178cab8>
>
> Seems fine to me. What are you seeing with 3.2?
>
> --Kevin
>
> --
> Kevin Walzer
> Code by Kevin
> http://www.codebykevin.com
> _______________________________________________
> Tkinter-discuss mailing list
> [hidden email]
> http://mail.python.org/mailman/listinfo/tkinter-discuss
_______________________________________________
Tkinter-discuss mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/tkinter-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Python 3.2 and binding Mousewheel on Mac

Ned Deily
In article
<[hidden email]>,
 "Michael O'Donnell" <[hidden email]> wrote:

> Hi Kevin,
>
>    As I mentioned in my email, the code worked fine for me too
> under 2.7.3. This matches diagnoses of the problem in 2011.
>
> I just thought, a year later, the problem would be fixed.

Is this the problem you are seeing?

http://bugs.python.org/issue10731

--
 Ned Deily,
 [hidden email]

_______________________________________________
Tkinter-discuss mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/tkinter-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Python 3.2 and binding Mousewheel on Mac

Michael O'Donnell
Hi Ned,

> Is this the problem you are seeing?
> http://bugs.python.org/issue10731

Yes, I was basically asking if in the year since that was reported,
has any progress been made towards a proper fix.

Mick
_______________________________________________
Tkinter-discuss mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/tkinter-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Python 3.2 and binding Mousewheel on Mac

Ned Deily
In article
<CABaQFFEGEUPy2=[hidden email]>,
 "Michael O'Donnell" <[hidden email]> wrote:
> > Is this the problem you are seeing?
> > http://bugs.python.org/issue10731
> Yes, I was basically asking if in the year since that was reported,
> has any progress been made towards a proper fix.

It's best to ask on the bug tracker.  If there have been no updates to
an issue, chances are not that no one is working on it.

But I've looked into it and it does appear to be a bug in the Cocoa
Tcl/Tk 8.5.x implementation as suspected.  See the updates to Issue10731
for details.  I've opened Tk Toolkit bug 3520202 to report the problem.  
If someone takes an interest in it there, a fix could appear in a future
release of the ActiveState Tcl/Tk 8.5 for OS X.

https://sourceforge.net/tracker/?func=detail&aid=3520202&group_id=12997&a
tid=112997

--
 Ned Deily,
 [hidden email]

_______________________________________________
Tkinter-discuss mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/tkinter-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Python 3.2 and binding Mousewheel on Mac

Michael O'Donnell
Thanks Ned,

Mick

On Sun, Apr 22, 2012 at 3:05 PM, Ned Deily <[hidden email]> wrote:

> In article
> <CABaQFFEGEUPy2=[hidden email]>,
>  "Michael O'Donnell" <[hidden email]> wrote:
>> > Is this the problem you are seeing?
>> > http://bugs.python.org/issue10731
>> Yes, I was basically asking if in the year since that was reported,
>> has any progress been made towards a proper fix.
>
> It's best to ask on the bug tracker.  If there have been no updates to
> an issue, chances are not that no one is working on it.
>
> But I've looked into it and it does appear to be a bug in the Cocoa
> Tcl/Tk 8.5.x implementation as suspected.  See the updates to Issue10731
> for details.  I've opened Tk Toolkit bug 3520202 to report the problem.
> If someone takes an interest in it there, a fix could appear in a future
> release of the ActiveState Tcl/Tk 8.5 for OS X.
>
> https://sourceforge.net/tracker/?func=detail&aid=3520202&group_id=12997&a
> tid=112997
>
> --
>  Ned Deily,
>  [hidden email]
>
> _______________________________________________
> Tkinter-discuss mailing list
> [hidden email]
> http://mail.python.org/mailman/listinfo/tkinter-discuss
_______________________________________________
Tkinter-discuss mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/tkinter-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Python 3.2 and binding Mousewheel on Mac

Kevin Walzer-5
In reply to this post by Ned Deily

> But I've looked into it and it does appear to be a bug in the Cocoa
> Tcl/Tk 8.5.x implementation as suspected.  See the updates to Issue10731
> for details.  I've opened Tk Toolkit bug 3520202 to report the problem.
> If someone takes an interest in it there, a fix could appear in a future
> release of the ActiveState Tcl/Tk 8.5 for OS X.
>
> https://sourceforge.net/tracker/?func=detail&aid=3520202&group_id=12997&a
> tid=112997
>

Hi Neil,

I've been following this thread and have taken a look at the bug report
you entered. However, I can't reproduce the issue in Python 2.7 (I don't
have 3.x on my system) nor can I reproduce it when run directly from Tk.
The equivalent Tk code:

pack [text .t]
bind all <MouseWheel> {puts "Mouse wheel event"}

produces a string of "Mouse wheel events" statements to standard output,
even when using two-fingered scrolling on the trackpad.

Given that the Tk-Cocoa 8.5 code behaves as expected when run directly
from Tcl/Tk I'm not clear on what bug I'm supposed to be fixing here. If
the bug exists solely on the Tkinter side, then that needs to be
addressed by the Tkinter developers.

If I'm missing something, please clarify, but otherwise I am going to
close the bug report as "works for me."

--Kevin

--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
_______________________________________________
Tkinter-discuss mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/tkinter-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Python 3.2 and binding Mousewheel on Mac

Michael O'Donnell
Hi Kevin,

Kevin:  I can't reproduce the issue in Python 2.7 (I don't have 3.x on
my system) nor can I reproduce it when run directly from Tk. The
equivalent Tk code:

Mick:    On my own Mac, the code works on 2.7.3 but not 3.2.
This was also reported by someone back in 2011.

Ned's comments on bugs.python explain why this is
the case:  (http://bugs.python.org/issue10731)

To quote Ned:

It looks like the problem is that the current Cocoa Tcl/Tk 8.5.x
returns an incorrect MouseWheel event.  Using the supplied test
program and breakpointing in PythonCmd (around Modules/_tkinter.c:2027
in default), I found that it is being called from Tcl for MouseWheel
events with an "argc" of 20, which looks suspiciously like the length
of argv[1], "4302153816mouse_wheel", rather than the number of
arguments which should be more like 3.  It may also be an issue that
affects Python because _tkinter still uses the older Tcl_CreateCommand
interface rather than the newer Tcl_CreateObjCommand.  The same Tcl
behavior is observed with Python 2.7 _tkinter.c but there the bogus
arguments are translated using PyString_FromString which is unaffected
by the garbage arguments.  It might be possible to workaround this
problem in _tkinter but the next step is to open a Tcl/Tk issue
against the Cocoa implementation and push for a proper fix there.

Mick
_______________________________________________
Tkinter-discuss mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/tkinter-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Python 3.2 and binding Mousewheel on Mac

Kevin Walzer-5
Hi Mick,

On 4/22/12 8:51 AM, Michael O'Donnell wrote:
> It may also be an issue that
> affects Python because _tkinter still uses the older Tcl_CreateCommand
> interface rather than the newer Tcl_CreateObjCommand.  The same Tcl
> behavior is observed with Python 2.7 _tkinter.c but there the bogus
> arguments are translated using PyString_FromString which is unaffected
> by the garbage arguments.  It might be possible to workaround this
> problem in _tkinter but the next step is to open a Tcl/Tk issue
> against the Cocoa implementation and push for a proper fix there.

I did read all the notes that were on the various bug reports, including
the portions above that you quote, and I also attempted to reproduce the
bug with all the installations at my disposal.

To reiterate:

1. According to all available reports, the bug is only visible in a
specific combination of Python and Tk: specifically, Python 3.x (with
its new under-the-hood Unicode support everywhere) and Tk-Cocoa.

2. Ned's debugging isolated the specific point in tkinter.c where the
bug appears.

3. Neil identified a possible fix for the bug on the Python side on the
bridge.

4. The bug is not visible when accessed from Tcl/Tk. The two-finger
scrolling works as expected.

I'm able to fix Tkinter bugs when they are also accessible from Tcl/Tk;
the fix on the Tk side is automatically picked up by Tkinter. The recent
text input bug patch I committed is an example of this. Adrian Robert,
who identified the bug in a Tcl/Tk application he develops, authored the
patch, which I then committed, and which then fixed several related bug
reports from the Python community.

This case, however, is different. I fully accept Tk is returning some
sort of output that Python 3.x has difficulty handling, but because that
output produces no user-visible errors on the Tcl side of the bridge
(and Tcl, remember, is Tk's native language), I am very uncomfortable
with diving into to Tk's internals to make changes. Because there are no
reproducible errors from Tcl itself, it is not even clear to me what
changes should be made.

In order to call this a bug in Tk itself rather than a bug in Tkinter, I
need someone to put together a Tcl script that reproduces the issue.
Then I can proceed with investigating how to fix it. That's how we
proceeded with the text input bug. In this case, however, all evidence
suggests that the bug occurs at the level of Tkinter/Tk interaction, and
all evidence also suggests that a workaround or fix can--and, most
likely should--be implemented on the Python side of the bridge.

Thanks,
Kevin

--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
_______________________________________________
Tkinter-discuss mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/tkinter-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Python 3.2 and binding Mousewheel on Mac

Ned Deily
In article <[hidden email]>,
 Kevin Walzer <[hidden email]> wrote:
> In order to call this a bug in Tk itself rather than a bug in Tkinter, I
> need someone to put together a Tcl script that reproduces the issue.
> Then I can proceed with investigating how to fix it. That's how we
> proceeded with the text input bug. In this case, however, all evidence
> suggests that the bug occurs at the level of Tkinter/Tk interaction, and
> all evidence also suggests that a workaround or fix can--and, most
> likely should--be implemented on the Python side of the bridge.

As I understand it, Tkinter uses the Tcl C API to add a new command
which is bound to all events of interest; that's how Tkinter gets called
back from Tcl.  There are two different interfaces for externaI C
programs to register as commands; Tkinter still uses the older
Tcl_CreateCommand interface.  I believe the bug is in how the event
callback is being set up for the mouse_wheel event.  It might not be
visible from a Tcl script.  One way to attempt to reproduce it would be
to write a simple C program that calls Tcl_CreateCommand to create a new
command and then define a Tcl script that binds mouse_wheel events to it.

http://www.tcl.tk/man/tcl8.5/TclLib/CrtCommand.htm

--
 Ned Deily,
 [hidden email]

_______________________________________________
Tkinter-discuss mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/tkinter-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Python 3.2 and binding Mousewheel on Mac

Ned Deily
In article <[hidden email]>,
 Ned Deily <[hidden email]> wrote:
> In article <[hidden email]>,
>  Kevin Walzer <[hidden email]> wrote:
[...]

BTW, there has been further discussion on this at the open Tk issue in
the Tk bug tracker.  It's probably better to keep the discussion in one
place there.

https://sourceforge.net/tracker/?func=detail&aid=3520202&group_id=12997&a
tid=112997

--
 Ned Deily,
 [hidden email]

_______________________________________________
Tkinter-discuss mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/tkinter-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Python 3.2 and binding Mousewheel on Mac

Michael O'Donnell
Thanks a lot Ned for pursuing this bug for us.

According to Donald Fellows, it is now fixed:

http://sourceforge.net/tracker/?func=detail&aid=3520202&group_id=12997&atid=112997

I look forward to the next maintenance release of Tcl/Tk to verify it.

Mick

On Mon, Apr 23, 2012 at 2:55 AM, Ned Deily <[hidden email]> wrote:

> In article <[hidden email]>,
>  Ned Deily <[hidden email]> wrote:
>> In article <[hidden email]>,
>>  Kevin Walzer <[hidden email]> wrote:
> [...]
>
> BTW, there has been further discussion on this at the open Tk issue in
> the Tk bug tracker.  It's probably better to keep the discussion in one
> place there.
>
> https://sourceforge.net/tracker/?func=detail&aid=3520202&group_id=12997&a
> tid=112997
>
> --
>  Ned Deily,
>  [hidden email]
>
> _______________________________________________
> Tkinter-discuss mailing list
> [hidden email]
> http://mail.python.org/mailman/listinfo/tkinter-discuss
_______________________________________________
Tkinter-discuss mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/tkinter-discuss
Loading...