frame scroll problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • idriss

    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,wid th=400, height=420, bg='gray50',rel ief=RIDGE)
    mainFrame.pack( fill=BOTH,expan d=1)

    scroll = Scrollbar(mainF rame)
    scroll.pack(sid e=RIGHT,expand= 1,fill=BOTH)

    mainFrame.confi gure(xscrollcom mand=scroll.set )


    subFrame = Frame(mainFrame ,width=200,heig ht=300)
    subFrame.pack(e xpand=1,fill=BO TH)

    picNo =0
    img = []

    # two picture placed side by side
    imgfile = 'c:\untitled.bm p'
    lbl = Label(subFrame, bd=0)
    lbl.place(ancho r=NW)
    masterImg = Image.open(imgf ile)
    masterImg.thumb nail((500, 500))
    img.append(Imag eTk.PhotoImage( masterImg))
    lbl['image'] = img[picNo]
    picNo = picNo + 1
    lbl.pack(side=L EFT)

    imgfile = 'c:\untitled.bm p'
    lbl = Label(subFrame, bd=0)
    lbl.place(ancho r=NW)
    masterImg = Image.open(imgf ile)
    masterImg.thumb nail((500, 500))
    img.append(Imag eTk.PhotoImage( masterImg))
    lbl['image'] = img[picNo]
    picNo = picNo + 1
    lbl.pack(side=L EFT)
    root.mainloop()

    --
    Posted via http://dbforums.com
  • Peter Abel

    #2
    Re: frame scroll problem

    idriss <member31704@db forums.com> wrote in message news:<3035405.1 056406699@dbfor ums.com>...[color=blue]
    > 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,wid th=400, height=420, bg='gray50',rel ief=RIDGE)
    > mainFrame.pack( fill=BOTH,expan d=1)
    >
    > scroll = Scrollbar(mainF rame)
    > scroll.pack(sid e=RIGHT,expand= 1,fill=BOTH)
    >
    > mainFrame.confi gure(xscrollcom mand=scroll.set )
    >
    >
    > subFrame = Frame(mainFrame ,width=200,heig ht=300)
    > subFrame.pack(e xpand=1,fill=BO TH)
    >
    > picNo =0
    > img = []
    >
    > # two picture placed side by side
    > imgfile = 'c:\untitled.bm p'
    > lbl = Label(subFrame, bd=0)
    > lbl.place(ancho r=NW)
    > masterImg = Image.open(imgf ile)
    > masterImg.thumb nail((500, 500))
    > img.append(Imag eTk.PhotoImage( masterImg))
    > lbl['image'] = img[picNo]
    > picNo = picNo + 1
    > lbl.pack(side=L EFT)
    >
    > imgfile = 'c:\untitled.bm p'
    > lbl = Label(subFrame, bd=0)
    > lbl.place(ancho r=NW)
    > masterImg = Image.open(imgf ile)
    > masterImg.thumb nail((500, 500))
    > img.append(Imag eTk.PhotoImage( masterImg))
    > lbl['image'] = img[picNo]
    > picNo = picNo + 1
    > lbl.pack(side=L EFT)
    > root.mainloop()[/color]

    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

    Comment

    Working...