Movatterモバイル変換


[0]ホーム

URL:


Tkinter scrolling canvas nightmare

dsavitskdsavitsk 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 canoffer 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, butthe canvas just sits there.also, PMW (scrolledframe in particular) would be a better solution, but itdoesn't seem to give me control over the scroll bars programatically orallow me to tie one of the scrollbars to 2 scrolled frames. if anyone canhelp with that it would be great too (even helping me to modify thescrolledframe class).here is some sample code. this version is copied almost verbatim from johnshipman's tutorial.  i have other non-working versions if anyone isinterested 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-listmailing list

[8]ページ先頭

©2009-2025 Movatter.jp