Re: tkinter urgent help request

Discussion in 'Python' started by Eric Brunel, Jun 24, 2003.

  1. Eric Brunel

    Eric Brunel Guest

    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
    Eric Brunel, Jun 24, 2003
    #1
    1. Advertising

  2. Eric Brunel

    Eric Brunel Guest

    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 <> -
    PragmaDev : Real Time Software Development Tools - http://www.pragmadev.com
    Eric Brunel, 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. Brian Birtle
    Replies:
    2
    Views:
    1,998
    John Saunders
    Oct 16, 2003
  2. Martin Franklin

    Re: tkinter urgent help request

    Martin Franklin, Jun 24, 2003, in forum: Python
    Replies:
    1
    Views:
    685
    Lonnie Princehouse
    Jun 24, 2003
  3. Jeff Epler
    Replies:
    0
    Views:
    497
    Jeff Epler
    Aug 20, 2004
  4. Jeff Epler
    Replies:
    0
    Views:
    444
    Jeff Epler
    Aug 23, 2004
  5. Daku
    Replies:
    3
    Views:
    338
    kopik
    Dec 31, 2009
Loading...

Share This Page