By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,610 Members | 2,110 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,610 IT Pros & Developers. It's quick & easy.

frame scroll problem

P: n/a

i want to scroll one frame's or canvas 's whole content (it will contain
other subframes and subframes will contain bitmaps) I couldn't find
where is my fault. if you can find my fault or have some example codes
like this please help me thanks from now.....

from Tkinter import *
import Image, ImageTk
root = Tk()

mainFrame = Canvas(root,width=400, height=420, bg='gray50',relief=RIDGE)
mainFrame.pack(fill=BOTH,expand=1)

scroll = Scrollbar(mainFrame)
scroll.pack(side=RIGHT,expand=1,fill=BOTH)

mainFrame.configure(xscrollcommand=scroll.set)
subFrame = Frame(mainFrame,width=200,height=300)
subFrame.pack(expand=1,fill=BOTH)

picNo =0
img = []

# two picture placed side by side
imgfile = 'c:\untitled.bmp'
lbl = Label(subFrame, bd=0)
lbl.place(anchor=NW)
masterImg = Image.open(imgfile)
masterImg.thumbnail((500, 500))
img.append(ImageTk.PhotoImage(masterImg))
lbl['image'] = img[picNo]
picNo = picNo + 1
lbl.pack(side=LEFT)

imgfile = 'c:\untitled.bmp'
lbl = Label(subFrame, bd=0)
lbl.place(anchor=NW)
masterImg = Image.open(imgfile)
masterImg.thumbnail((500, 500))
img.append(ImageTk.PhotoImage(masterImg))
lbl['image'] = img[picNo]
picNo = picNo + 1
lbl.pack(side=LEFT)
root.mainloop()

--
Posted via http://dbforums.com
Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
idriss <me*********@dbforums.com> wrote in message news:<30****************@dbforums.com>...
i want to scroll one frame's or canvas 's whole content (it will contain
other subframes and subframes will contain bitmaps) I couldn't find
where is my fault. if you can find my fault or have some example codes
like this please help me thanks from now.....

from Tkinter import *
import Image, ImageTk
root = Tk()

mainFrame = Canvas(root,width=400, height=420, bg='gray50',relief=RIDGE)
mainFrame.pack(fill=BOTH,expand=1)

scroll = Scrollbar(mainFrame)
scroll.pack(side=RIGHT,expand=1,fill=BOTH)

mainFrame.configure(xscrollcommand=scroll.set)
subFrame = Frame(mainFrame,width=200,height=300)
subFrame.pack(expand=1,fill=BOTH)

picNo =0
img = []

# two picture placed side by side
imgfile = 'c:\untitled.bmp'
lbl = Label(subFrame, bd=0)
lbl.place(anchor=NW)
masterImg = Image.open(imgfile)
masterImg.thumbnail((500, 500))
img.append(ImageTk.PhotoImage(masterImg))
lbl['image'] = img[picNo]
picNo = picNo + 1
lbl.pack(side=LEFT)

imgfile = 'c:\untitled.bmp'
lbl = Label(subFrame, bd=0)
lbl.place(anchor=NW)
masterImg = Image.open(imgfile)
masterImg.thumbnail((500, 500))
img.append(ImageTk.PhotoImage(masterImg))
lbl['image'] = img[picNo]
picNo = picNo + 1
lbl.pack(side=LEFT)
root.mainloop()


See http://effbot.org/zone/tkinter-autoscrollbar.htm .
There's an example of automatic Scrollbars, which are removed when
not needed. Further more there's described how to scroll a Canvas
widget with subwidgets on it.
Regards
Peter
Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.