[ python-list ] scrolling a frame

T

Toph

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)
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top