A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2001-April/067210.html below:

Tkinter scrolling canvas nightmare

Tkinter scrolling canvas nightmaredsavitsk dsavitsk at e-coli.net
Tue Apr 3 19:44:49 EDT 2001
i have been trying to scroll a canvas widget for weeks now.  if anybody can
offer some suggestions i would be very happy to hear them.

i can get all of the stuff i want to appear, and the scrollbars move, but
the canvas just sits there.

also, PMW (scrolledframe in particular) would be a better solution, but it
doesn't seem to give me control over the scroll bars programatically or
allow me to tie one of the scrollbars to 2 scrolled frames. if anyone can
help with that it would be great too (even helping me to modify the
scrolledframe class).

here is some sample code. this version is copied almost verbatim from john
shipman's tutorial.  i have other non-working versions if anyone is
interested in them too ;-)

thanks,
doug

-------------------------------------------
from Tkinter import *
class contain:
    def __init__(self, parent):
        self.f = Frame(parent, bg='#ff0000', border=0)
        self.f.pack(expand=NO, anchor=NW)
        self.c = Canvas(self.f, bg='#00ff00', width=600, height=400,
scrollregion=(0,0,1200,800))
        self.c.grid(row=0, column=0)
        self.sy = Scrollbar(self.f, orient='vertical', command=self.c.yview)
        self.sy.grid(row=0, column=1, sticky=N+S)
        self.sx = Scrollbar(self.f, orient='horizontal',
command=self.c.xview)
        self.sx.grid(row=1, column=0, sticky=E+W)
        self.c['xscrollcommand'] = self.sx.set
        self.c['yscrollcommand'] = self.sy.set
        for i in range(50):
            Label(self.c, text='label # ' + str(i),
relief=RIDGE).pack(side=LEFT, padx=5, pady=5, expand=NO)

if __name__ == '__main__':
    root = Tk()
    x = contain(root)
    mainloop()



More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4