From: jmrober1 at ingr.com (Joseph Robertson)
Date: Thu, 08 Apr 1999 13:51:52 -0500
Subject: Q on Tkinter Scrollbar
Message-ID: <370CFAC8.32EB0B29@ingr.com>
Content-Length: 1421
X-UID: 1178                                                  

Hi everyone,

I want to manually control the scrollbar in a tkinter app, i.e. I don't
want to tie it to another widget as a child.  Below is what I have so
far.  I can't figure how to make the 'thumb' stay at the returned
position, or the point where the user drags it.  Right now it always
pops back to the top.

I want it to behave like a Scale, but look like a scrollbar.  Think of a
virtual window on a dataset, where I don't want to load the contents of
the data set into a listbox (not enough memory).

Anyone do this before, know of any similar examples, or give me a clue
where to look next.  I don't want to use extensions or another GUI, it
needs to be Tkinter.

Thanks in advance,
Joe Robertson
jmrober1 at ingr.com


>----begin code
# a manual scrollbar
#
# Joe Robertson, jmrober1 at ingr.com
#
from Tkinter import *

class Manual(Frame):

    def __init__(self, master, **kw):
        apply(Frame.__init__, (self, master), kw)
        vscrollbar = Scrollbar(self, orient=VERTICAL)
        self.canvas = Canvas(self)
        vscrollbar.config(command=self._vscroll)
        vscrollbar.pack(fill=Y, side=RIGHT)
        self.canvas.pack(expand=1, fill=BOTH, side=LEFT)

    def _vscroll(self, type, *arg):
        print type
        if type == 'moveto':
            for each in arg:
                print each

# doit
root = Tk()
f = Manual(root)
f.pack(expand=1, fill=BOTH)
root.mainloop()

>----end code





