Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   frame scroll problem (http://www.velocityreviews.com/forums/t318764-frame-scroll-problem.html)

idriss 06-23-2003 10:18 PM

frame scroll problem
 

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

Peter Abel 06-24-2003 05:22 AM

Re: frame scroll problem
 
idriss <member31704@dbforums.com> wrote in message news:<3035405.1056406699@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


All times are GMT. The time now is 02:34 PM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57