473,378 Members | 1,470 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

[ python-l ] scrolling a frame

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 Tkinterimport *

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)
Jul 18 '05 #1
1 3135
"Toph" <to**@laposte.net> wrote in message news:<ma*************************************@pyth on.org>...
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.
First of all, I recommend that you look at the following example. I found it
to be very useful when addressing a similar problem:

http://mail.python.org/pipermail/pyt...er/013255.html

Cutting and editing from now on...
This is a peace of my code :
[...]
canvas = Canvas(global frame)
Is that valid syntax? I'm not able to successfully use the "global" keyword in
similar circumstances.
# 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...


Sorry not to address your exact problem. I haven't used Tkinter seriously
for quite a while. Still, I hope that the above reference is of some use.

David
Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.