frame scroll problem

Discussion in 'Python' started by idriss, Jun 23, 2003.

  1. idriss

    idriss Guest

    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
    idriss, Jun 23, 2003
    #1
    1. Advertising

  2. idriss

    Peter Abel Guest

    idriss <> wrote in message news:<>...
    > 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
    Peter Abel, Jun 24, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. nicholas
    Replies:
    0
    Views:
    440
    nicholas
    Dec 7, 2004
  2. Kevin
    Replies:
    1
    Views:
    9,525
    Roland
    Feb 5, 2005
  3. Sathiamoorthy

    Enable Scroll up and scroll down in CR-report

    Sathiamoorthy, Nov 9, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    895
    zobalee
    Nov 28, 2006
  4. UJ
    Replies:
    1
    Views:
    568
    John Timney \(MVP\)
    Nov 1, 2006
  5. =?Utf-8?B?Ui5OaWprYW1w?=

    Listbox disabled - cant scroll in IE - can scroll in Firefox

    =?Utf-8?B?Ui5OaWprYW1w?=, Nov 22, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    1,231
    =?Utf-8?B?Ui5OaWprYW1w?=
    Nov 22, 2006
Loading...

Share This Page