Hi,
would someone tell me how to make scrollbar work under grid?
I think I'm missing something to connect scrollbar with the grid.
following is some sample code. it shows the scrollbar, but it do not work.
Thanks a lot for the help!
Ray
#####code begin########
from Tkinter import *
def mygrid(text,M = []):
while M:
x = M.pop()
x.destroy()
rows = []
count=int(text)
yscroll = Scrollbar(frame_grid, orient='vertical')
yscroll.grid(rowspan=count, column=5, sticky=NS)
M.append(yscroll)
for i in range(count):
cols = []
for j in range(4):
e = Entry(frame_grid, relief=RIDGE)
M.append(e)
e.grid(row=i, column=j, sticky=NSEW)
e.insert(END, '%d.%d' % (i, j))
cols.append(e)
rows.append(cols)
root=Tk()
frame_entry=Frame(root, width=550, height=100)
frame_entry.pack()
text=Entry(frame_entry)
text.pack(side=LEFT)
button=Button(frame_entry, text='generate grid',
command=(lambda:mygrid(text.get())))
button.pack()
frame_space=Frame(root, width=550, height=100)
frame_space.pack()
frame_grid=Frame(root, width=550, height=300, relief=GROOVE)
frame_grid.pack()
frame_exit=Frame(root, width=550, height=100)
frame_exit.pack()
button2=Button(frame_exit, text='exit', command=root.quit)
button2.pack()
root.mainloop() 2 2801
Ray wrote:
Hi,
would someone tell me how to make scrollbar work under grid?
I think I'm missing something to connect scrollbar with the grid.
following is some sample code. it shows the scrollbar, but it do not work.
Thanks a lot for the help!
Ray
#####code begin########
from Tkinter import *
def mygrid(text,M = []):
while M:
x = M.pop()
x.destroy()
rows = []
count=int(text)
yscroll = Scrollbar(frame_grid, orient='vertical')
yscroll.grid(rowspan=count, column=5, sticky=NS)
M.append(yscroll)
for i in range(count):
cols = []
for j in range(4):
e = Entry(frame_grid, relief=RIDGE)
M.append(e)
e.grid(row=i, column=j, sticky=NSEW)
e.insert(END, '%d.%d' % (i, j))
cols.append(e)
rows.append(cols)
root=Tk()
frame_entry=Frame(root, width=550, height=100)
frame_entry.pack()
text=Entry(frame_entry)
text.pack(side=LEFT)
button=Button(frame_entry, text='generate grid',
command=(lambda:mygrid(text.get())))
button.pack()
frame_space=Frame(root, width=550, height=100)
frame_space.pack()
frame_grid=Frame(root, width=550, height=300, relief=GROOVE)
frame_grid.pack()
frame_exit=Frame(root, width=550, height=100)
frame_exit.pack()
button2=Button(frame_exit, text='exit', command=root.quit)
button2.pack()
root.mainloop()
You are not binding to the Scrollbar.set() method nor are you assigning
the Scrollbar a command. You should try to emulate this: http://www.pythonware.com/library/tk...3-patterns.htm
You need to also determine exactly what it is you want to scroll. You
probably don't want to scroll frame_grid as that contains your
scrollbar. Google "tkinter scrolled frame". Here is an example: http://mail.python.org/pipermail/pyt...ry/427886.html
So, a suggestion would be to create a new frame to hold frame_grid and
yscroll and then use yscroll to scroll frame_grid.
James
James Stroud wrote:
>
You are not binding to the Scrollbar.set() method nor are you assigning
the Scrollbar a command. You should try to emulate this:
http://www.pythonware.com/library/tk...3-patterns.htm
You need to also determine exactly what it is you want to scroll. You
probably don't want to scroll frame_grid as that contains your
scrollbar. Google "tkinter scrolled frame". Here is an example:
http://mail.python.org/pipermail/pyt...ry/427886.html
So, a suggestion would be to create a new frame to hold frame_grid and
yscroll and then use yscroll to scroll frame_grid.
James
entry do not have .yview and yscrollcommand.
I will try to scroll frame_grid with a new frame.
thanks
Ray This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Gary Richardson |
last post by:
I've just switched to Python 2.3.2 and have encountered a problem that
causes a program to crash. The program was working with Python 2.2. The code
below will illustrate the problem. A listbox is...
|
by: Toph |
last post by:
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 :
#...
|
by: Toph |
last post by:
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 :
#...
|
by: Maboroshi |
last post by:
Hi I am building a simple chat program but I am running into problems
interacting with more than one client I can send a message to a server
and it can recieve it no problem but how do I get more...
|
by: Barbara de Zoete |
last post by:
On one of my pages
http://home.wanadoo.nl/b.de.zoete/html/tekeningen.html
I have a div containing thumbnails (who ever came up with that word?) to
select a larger view of a picture. The div is...
|
by: Paul_Madden via DotNetMonster.com |
last post by:
I am handling the Listbox DrawItem event to enable the listbox strings to be
displayed in different colours for easy reading.
Have set ScrollAlwaysVisible and HorizontalScrollbar to true.
I...
|
by: nicky77 |
last post by:
Hi, before you say it i know frames are bad practice - but i'm developing dynamic content on a site which has already been designed, so alas there's no option but to use them. Anyway, I just want to...
|
by: Tom |
last post by:
First, I posted a similar request for help in another group and now
don't find the posting. Problem with my newsreader perhaps ... but
apologies if this appears as a cross posting.
My code is...
|
by: Sayanan Sivaraman |
last post by:
Hey all,
So I've written a simple video player using directshow/COM in VC++,
and I'm in the process of translating it to python. For example, when
the avi starts playing, I have a call...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |