[ python-list ] scrolling a frame

Discussion in 'Python' started by Toph, Dec 2, 2003.

  1. Toph

    Toph Guest

    Bonjour a tous,
    Hi,

    I am developing a software in Python using Tkinter. The choice of my team is not to use pyton MegaWidgets.
    I would like to scroll a frame.

    This is a peace of my code :
    # -----------------------------------------------------------------------------
    #!/bin/env python
    from Tkinter import *

    root = Tk()
    global_frame = Frame(root, relief = GROOVE, borderwidth=4)
    canvas = Canvas(global_frame)

    # scrollbars:
    vscroll = Scrollbar(global_frame, command=canvas.yview)
    hscroll = Scrollbar(global_frame, command=canvas.xview, orient=HORIZONTAL)

    # The frame i want to scroll :
    frame = Frame(canvas, relief = GROOVE, borderwidth=2)
    cw = canvas.create_window(0,0, window = frame)

    global_frame.grid(row = 0, column = 0, sticky=NS)

    #put the widgets in global_frame
    canvas.grid(row = 0, column = 0)
    vscroll.grid(row = 0, column = 1, sticky=NS)
    hscroll.grid(row = 1, column = 0, sticky=EW)

    # fill the frame :
    for item in range(30):
    Label(frame, text = 'item %d'%item).grid(row = item,
    column = 0)
    Entry(frame, text = 'default text %d'%item).grid(row = item,
    column = 1, sticky=EW)

    # configure the scollbars to scroll the canvas :
    hauteur = frame.winfo_height()
    largeur = frame.winfo_width()
    canvas.configure(yscrollcommand = vscroll.set, xscrollcommand = hscroll.set,
    scrollregion = (0,0, largeur, hauteur)) #canvas.coords(cw))

    # My problem is that i would like the scrollregion to scroll only the space taken by
    # the frame but my program does not do it well...

    root.mainloop()
    #------------------------------------------------------------------------------

    I thank you in advance.

    Christophe

    Accédez au courrier électronique de La Poste : www.laposte.net ;
    3615 LAPOSTENET (0,34€/mn) ; tél : 08 92 68 13 50 (0,34€/mn)
     
    Toph, Dec 2, 2003
    #1
    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. Replies:
    0
    Views:
    1,967
  2. Toph
    Replies:
    1
    Views:
    381
    David Boddie
    Dec 4, 2003
  3. Fokke Nauta
    Replies:
    2
    Views:
    117
    Fokke Nauta
    May 30, 2004
  4. Christopher Benson-Manica

    Changing scrolling property for a frame

    Christopher Benson-Manica, May 19, 2005, in forum: Javascript
    Replies:
    2
    Views:
    97
    BootNic
    May 20, 2005
  5. enimatrix

    frame scrolling down

    enimatrix, Dec 7, 2008, in forum: Javascript
    Replies:
    3
    Views:
    155
Loading...

Share This Page