Problem with Tkinter scrollbar callback

Ivan Van Laningham ivanlan9 at gmail.com
Thu Jan 24 23:49:58 CET 2008


Hi All--
I'm having two problems with the scrollbar callback on linux systems
(Fedora 7, Suse 10.1,2 and 3 all exhibit the issues).

Problem one:  on Windows, the callback is called with the arguments as
specified in the doc:  "scroll", "1" or "-1", "units".  When I run the
identical code on linux, the callback is invoked with only one
argument, "1" or "-1".  Here's a small program which demos the
problem:

========begin============
#!/usr/bin/env python

from Tkinter import *
import sys

def die(event):
    sys.exit(0)
def sDoit(*args):
  for i in args:
    print "scrollbar:",i, type(i)
root=Tk()
f=Frame(root)
f.pack(expand=1,fill=BOTH)
button=Button(f,width=25)
button["text"]="Quit"
button.bind("<Button>",die)
button.pack()
xb=Scrollbar(f,orient=HORIZONTAL,command=sDoit)
xb.pack()
root.mainloop()
=============end===========

On Windows, it produces the correct output

scrollbar: scroll <type 'str'>
scrollbar: 1 <type 'str'>
scrollbar: units <type 'str'>

but on linux, it produces

scrollbar: 1 <type 'str'>

I can't believe that this is a bug that has not already been fixed, so
I must be doing something wrong.  But what?  I'm surely overlooking
something dead obvious. ...

Note that I don't want to use this as a scrollbar, all I need is the direction.

The second problem is more pernicious, in that I can work around the
first problem, and I don't really have a clue on the second.  On
Windows, clicking one of the arrow buttons produces one callback.  On
Linux, in the real application, if I click an arrow button once, the
callback continues to be called until I kill the app.  That doesn't
happen in the small program I've provided above, so I'm at a bit of a
loss where to start looking.  Any hints?

Metta,
Ivan
-- 
Ivan Van Laningham
God N Locomotive Works
http://www.pauahtun.org/
http://www.python.org/workshops/1998-11/proceedings/papers/laningham/laningham.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours



More information about the Python-list mailing list