Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   Re: tkinter urgent help request (http://www.velocityreviews.com/forums/t318777-re-tkinter-urgent-help-request.html)

Eric Brunel 06-24-2003 07:43 AM

Re: tkinter urgent help request
 
idriss wrote:
> 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
>
>
> root = Tk()
>
> mainFrame = Canvas(root,width=400, height=420, bg='gray50',relief=RIDGE)
> mainFrame.pack(fill=BOTH,expand=1)
>
> scroll = Scrollbar(mainFrame)


You need to link the scrollbar to the canvas here. You link the canvas to the
scrollbar below, but it needs to be done in both ways:

scroll = Scrollbar(mainFrame, command=mainFrame.xview)

> 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()


I couldn't test the script since I didn't have the Image module installed, but
it should work now.

HTH
--
- Eric Brunel <eric.brunel@pragmadev.com> -
PragmaDev : Real Time Software Development Tools - http://www.pragmadev.com


Eric Brunel 06-24-2003 02:57 PM

Re: tkinter urgent help request
 
idriss wrote:
> thanks for your consideration eric, but it doesn't work again, i used
> grid instead of frames the code in the below makes a scroll but it is
> only a decoration :)


Did you configure the scroll region for your canvas via a:

mainFrame.configure(scrollregion=(xMin, yMin, xMax, yMax))

anywhere? If you didn't, the canvas won't scroll at all...

HTH
--
- Eric Brunel <eric.brunel@pragmadev.com> -
PragmaDev : Real Time Software Development Tools - http://www.pragmadev.com



All times are GMT. The time now is 07:59 AM.

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