Problem with Tkinter scrollbar callback

Discussion in 'Python' started by Ivan Van Laningham, Jan 24, 2008.

  1. 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
     
    Ivan Van Laningham, Jan 24, 2008
    #1
    1. Advertising

  2. In article <>,
    "Ivan Van Laningham" <> wrote:

    > 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 see the same bad thing on our RedHat Enteprise unix system which has
    the default tcl/tk 8.4.6. However I found that if you send the scrollbar
    the "set" command first then it behaves normally. I think it just starts
    out in a funny state where it has no idea how to display itself.

    -- Russell

    (P.s. it works fine on my MacOS X 10.4.11 system with default tcl 8.4.7
    or with add-on 8.4.14).
     
    Russell E. Owen, Jan 24, 2008
    #2
    1. Advertising

  3. Hi All--
    That helps. Doing a get() on the scrollbar before a set(0.0,0.0)
    returns a 4-tuple: (0.0, 0.0, 0.0, 0.0) ! I did the set(0.0,0.0)
    and now the callback gets the correct number of arguments.

    However, I'm still getting the weird behaviour when clicking the
    arrowheads--and the heads are all I want. They act like they've been
    set to a keybounce timeout of about a millisecond. ... The arrow
    click increments the number of cells in a table row (effectively), and
    it shoots up from 5 to 26 columns almost instantly (that's the
    internal max I set).

    Metta,
    Ivan

    On Jan 24, 2008 4:27 PM, Russell E. Owen <> wrote:
    > In article <>,
    >
    > "Ivan Van Laningham" <> wrote:
    >
    > > 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 see the same bad thing on our RedHat Enteprise unix system which has
    > the default tcl/tk 8.4.6. However I found that if you send the scrollbar
    > the "set" command first then it behaves normally. I think it just starts
    > out in a funny state where it has no idea how to display itself.
    >
    > -- Russell
    >
    > (P.s. it works fine on my MacOS X 10.4.11 system with default tcl 8.4.7
    > or with add-on 8.4.14).
    > --
    > http://mail.python.org/mailman/listinfo/python-list
    >




    --
    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
     
    Ivan Van Laningham, Jan 24, 2008
    #3
  4. In article <>,
    "Ivan Van Laningham" <> wrote:

    > Hi All--
    > That helps. Doing a get() on the scrollbar before a set(0.0,0.0)
    > returns a 4-tuple: (0.0, 0.0, 0.0, 0.0) ! I did the set(0.0,0.0)
    > and now the callback gets the correct number of arguments.
    >
    > However, I'm still getting the weird behaviour when clicking the
    > arrowheads--and the heads are all I want. They act like they've been
    > set to a keybounce timeout of about a millisecond. ... The arrow
    > click increments the number of cells in a table row (effectively), and
    > it shoots up from 5 to 26 columns almost instantly (that's the
    > internal max I set).


    Is the scroll bar's repeatinterval set to a reasonable value?

    -- Russell
     
    Russell E. Owen, Jan 26, 2008
    #4
  5. Nope:

    'repeatdelay': ('repeatdelay', 'repeatDelay', 'RepeatDelay', '300', '300'),

    And even after I set it, it looks funny:

    'repeatdelay': ('repeatdelay', 'repeatDelay', 'RepeatDelay', '300', '1000'),

    And when I try it with the new repeatdelay (1000), the only thing that
    has changed is that it waits 1000 milliseconds before exhibiting the
    same uncontrolled growth as before.

    Metta,
    Ivan

    On Jan 25, 2008 5:49 PM, Russell E. Owen <> wrote:
    > In article <>,
    > "Ivan Van Laningham" <> wrote:
    >
    > > Hi All--
    > > That helps. Doing a get() on the scrollbar before a set(0.0,0.0)
    > > returns a 4-tuple: (0.0, 0.0, 0.0, 0.0) ! I did the set(0.0,0.0)
    > > and now the callback gets the correct number of arguments.
    > >
    > > However, I'm still getting the weird behaviour when clicking the
    > > arrowheads--and the heads are all I want. They act like they've been
    > > set to a keybounce timeout of about a millisecond. ... The arrow
    > > click increments the number of cells in a table row (effectively), and
    > > it shoots up from 5 to 26 columns almost instantly (that's the
    > > internal max I set).

    >
    > Is the scroll bar's repeatinterval set to a reasonable value?
    >
    > -- Russell
    >
    > --
    > http://mail.python.org/mailman/listinfo/python-list
    >




    --
    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
     
    Ivan Van Laningham, Jan 29, 2008
    #5
  6. No Joy.

    Waits the 1 second, then clicks the button once per second until the
    limit's reached.

    Sigh.

    Metta,
    Ivan

    On Jan 29, 2008 10:20 AM, Russell E Owen <> wrote:
    > >Nope:
    > >
    > >'repeatdelay': ('repeatdelay', 'repeatDelay', 'RepeatDelay', '300', '300'),
    > >
    > >And even after I set it, it looks funny:
    > >
    > >'repeatdelay': ('repeatdelay', 'repeatDelay', 'RepeatDelay', '300', '1000'),
    > >
    > >And when I try it with the new repeatdelay (1000), the only thing that
    > >has changed is that it waits 1000 milliseconds before exhibiting the
    > >same uncontrolled growth as before.

    >
    > You need to change repeatinterval, not repeatdelay.
    >
    > As to "looking funny": that is the standard output format for
    > configure(). I think can get a more reasonable value using
    > "cget(repeatdelay)".
    >
    > -- Russell
    >
    >
    > >
    > >Metta,
    > >Ivan
    > >
    > >On Jan 25, 2008 5:49 PM, Russell E. Owen <> wrote:
    > >> In article <>,
    > >> "Ivan Van Laningham" <> wrote:
    > >>
    > >> > Hi All--
    > >> > That helps. Doing a get() on the scrollbar before a set(0.0,0.0)
    > >> > returns a 4-tuple: (0.0, 0.0, 0.0, 0.0) ! I did the set(0.0,0.0)
    > >> > and now the callback gets the correct number of arguments.
    > >> >
    > >> > However, I'm still getting the weird behaviour when clicking the
    > >> > arrowheads--and the heads are all I want. They act like they've been
    > >> > set to a keybounce timeout of about a millisecond. ... The arrow
    > >> > click increments the number of cells in a table row (effectively), and
    > >> > it shoots up from 5 to 26 columns almost instantly (that's the
    > >> > internal max I set).
    > >>
    > >> Is the scroll bar's repeatinterval set to a reasonable value?
    > >>
    > >> -- Russell
    > >>
    > >> --
    > >> http://mail.python.org/mailman/listinfo/python-list
    > >>

    > >
    > >
    > >
    > >--
    > >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

    >
    >




    --
    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
     
    Ivan Van Laningham, Jan 29, 2008
    #6
  7. HI All--
    We've decided that this represents a bug in the tcl/tk library, and
    there's no workaround. I switched to + and - buttons, which are not
    as nice aesthetically but work correctly on both Windows & Linux.

    Thanks to everyone for their help.

    Metta,
    Ivan

    On Jan 29, 2008 11:03 AM, Ivan Van Laningham <> wrote:
    > No Joy.
    >
    > Waits the 1 second, then clicks the button once per second until the
    > limit's reached.
    >
    > Sigh.
    >
    > Metta,
    > Ivan
    >
    >
    > On Jan 29, 2008 10:20 AM, Russell E Owen <> wrote:
    > > >Nope:
    > > >
    > > >'repeatdelay': ('repeatdelay', 'repeatDelay', 'RepeatDelay', '300', '300'),
    > > >
    > > >And even after I set it, it looks funny:
    > > >
    > > >'repeatdelay': ('repeatdelay', 'repeatDelay', 'RepeatDelay', '300', '1000'),
    > > >
    > > >And when I try it with the new repeatdelay (1000), the only thing that
    > > >has changed is that it waits 1000 milliseconds before exhibiting the
    > > >same uncontrolled growth as before.

    > >
    > > You need to change repeatinterval, not repeatdelay.
    > >
    > > As to "looking funny": that is the standard output format for
    > > configure(). I think can get a more reasonable value using
    > > "cget(repeatdelay)".
    > >
    > > -- Russell
    > >
    > >
    > > >
    > > >Metta,
    > > >Ivan
    > > >
    > > >On Jan 25, 2008 5:49 PM, Russell E. Owen <> wrote:
    > > >> In article <>,
    > > >> "Ivan Van Laningham" <> wrote:
    > > >>
    > > >> > Hi All--
    > > >> > That helps. Doing a get() on the scrollbar before a set(0.0,0.0)
    > > >> > returns a 4-tuple: (0.0, 0.0, 0.0, 0.0) ! I did the set(0.0,0.0)
    > > >> > and now the callback gets the correct number of arguments.
    > > >> >
    > > >> > However, I'm still getting the weird behaviour when clicking the
    > > >> > arrowheads--and the heads are all I want. They act like they've been
    > > >> > set to a keybounce timeout of about a millisecond. ... The arrow
    > > >> > click increments the number of cells in a table row (effectively), and
    > > >> > it shoots up from 5 to 26 columns almost instantly (that's the
    > > >> > internal max I set).
    > > >>
    > > >> Is the scroll bar's repeatinterval set to a reasonable value?
    > > >>
    > > >> -- Russell
    > > >>
    > > >> --
    > > >> http://mail.python.org/mailman/listinfo/python-list
    > > >>
    > > >
    > > >
    > > >
    > > >--
    > > >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

    > >
    > >

    >
    >
    >
    > --
    >
    > 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
    >




    --
    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
     
    Ivan Van Laningham, Jan 30, 2008
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. codecraig

    Tkinter and Scrollbar

    codecraig, Apr 19, 2005, in forum: Python
    Replies:
    0
    Views:
    356
    codecraig
    Apr 19, 2005
  2. Replies:
    1
    Views:
    962
  3. Dustan

    Tkinter Scrollbar not working

    Dustan, Jan 2, 2006, in forum: Python
    Replies:
    8
    Views:
    566
    Dustan
    Jan 3, 2006
  4. spohle
    Replies:
    1
    Views:
    321
    Simon Forman
    Jun 24, 2006
  5. Alex

    ScrollBar? Does it exist just WEB ScrollBar Control?

    Alex, Apr 1, 2004, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    279
    Alvin Bruney [MVP]
    Apr 4, 2004
Loading...

Share This Page