A scrollable Frame or Canvas widget

bowman bowman at montana.com
Sat Aug 28 05:36:59 CEST 1999

Justin Muir wrote:
> Could anyone out there also clear up the mechanics of the different
> callbacks/commands invoked by the arrows and the scrollbar?

Quick and dirty Text widget with two attached scrollbars. There probably
are cleaner and better ways to do the job, but this may help.

from Tkinter import *

def main():
	root = Tk()

	f = Frame(root)
	text = Text(f, width=40, height=10, setgrid='True', wrap='none')

	xscroll = Scrollbar(f, orient=HORIZONTAL, command=text.xview)
	yscroll = Scrollbar(f, orient=VERTICAL, command=text.yview)
	xscroll.pack(side=BOTTOM, fill=X)
	yscroll.pack(side=RIGHT, fill=Y)
	text['xscrollcommand'] = xscroll.set
	text['yscrollcommand'] = yscroll.set

	text.pack(side=LEFT, fill=BOTH, expand='True')
	f.pack(side=TOP, fill=BOTH, expand='True')


if __name__ == '__main__' :

Bear Technology  Making Montana safe for Grizzlies


More information about the Python-list mailing list