tkinter urgent help request
idriss
member31704 at dbforums.com
Tue Jun 24 10:24:18 EDT 2003
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 :)
Originally posted by Eric Brunel
> 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 -
PragmaDev : Real Time Software Development Tools -
http://www.pragmadev.com/http://www.pragmadev.com
--
Posted via http://dbforums.com
More information about the Python-list
mailing list