473,659 Members | 2,685 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Tkinter Scrollbar not working

I'm trying to get a scrollbar bound with a Frame, and I keep on getting
a scrollbar, but it doesn't actually scroll. Some help, please?

Jan 2 '06 #1
8 11971
BTW, experience tells me it is necessary for me to explicitly state
that I'm a newbie (otherwise I get rude people saying I should already
know such-and-such).

Jan 2 '06 #2
Dustan wrote:
I'm trying to get a scrollbar bound with a Frame, and I keep on getting
a scrollbar, but it doesn't actually scroll. Some help, please?


It can be tricky getting an empty frame to scroll, can you post your
example code so that we might be more helpful. Here is an example of
binding a scroll bar to a Text widget (not exactly the same thing)
## import all names from Tkinter
## bit naughty but I don't mind
from Tkinter import *
# root window
root=Tk()
# text area
text=Text()
text.pack(side= "left", expand="yes", fill="both")

# scrolbar for above textarea
sb = Scrollbar(root)
sb.pack(side="r ight", fill="y")

## bind them both together...

# this line binds the yscrollcommand
# of the text area to the scrollbar set method
text['yscrollcommand '] = sb.set

# this line binds the scrollbars command to
# the yview method of the text area
sb['command'] = text.yview

# mainloop entry
root.mainloop()
Jan 3 '06 #3

Martin Franklin wrote:
Dustan wrote:
I'm trying to get a scrollbar bound with a Frame, and I keep on getting
a scrollbar, but it doesn't actually scroll. Some help, please?

It can be tricky getting an empty frame to scroll, can you post your
example code so that we might be more helpful. Here is an example of
binding a scroll bar to a Text widget (not exactly the same thing)


It's not an empty frame. It has a label. I was trying to do it with
just the label, but it didn't work, and I figured it might be a better
idea to try doing it with a frame instead.

## import all names from Tkinter
## bit naughty but I don't mind
from Tkinter import *
# root window
root=Tk()
# text area
text=Text()
text.pack(side= "left", expand="yes", fill="both")

# scrolbar for above textarea
sb = Scrollbar(root)
sb.pack(side="r ight", fill="y")

## bind them both together...

# this line binds the yscrollcommand
# of the text area to the scrollbar set method
text['yscrollcommand '] = sb.set

# this line binds the scrollbars command to
# the yview method of the text area
sb['command'] = text.yview

# mainloop entry
root.mainloop()


That doesn't help. I need to be able to do it either with a frame (has
content!) or a Text widget.

Jan 3 '06 #4
Label Widget, sorry

Jan 3 '06 #5
Dustan wrote:
Martin Franklin wrote:
Dustan wrote:
I'm trying to get a scrollbar bound with a Frame, and I keep on getting
a scrollbar, but it doesn't actually scroll. Some help, please?

It can be tricky getting an empty frame to scroll, can you post your
example code so that we might be more helpful. Here is an example of
binding a scroll bar to a Text widget (not exactly the same thing)

It's not an empty frame. It has a label. I was trying to do it with
just the label, but it didn't work, and I figured it might be a better
idea to try doing it with a frame instead.

## import all names from Tkinter
## bit naughty but I don't mind
from Tkinter import *
# root window
root=Tk()
# text area
text=Text()
text.pack(sid e="left", expand="yes", fill="both")

# scrolbar for above textarea
sb = Scrollbar(root)
sb.pack(side= "right", fill="y")

## bind them both together...

# this line binds the yscrollcommand
# of the text area to the scrollbar set method
text['yscrollcommand '] = sb.set

# this line binds the scrollbars command to
# the yview method of the text area
sb['command'] = text.yview

# mainloop entry
root.mainloop ()

That doesn't help. I need to be able to do it either with a frame (has
content!) or a Text widget.


Perhaps I am not understanding something... can you please show me an
example of what is not working. I consider the above a good recipe that
can be applied to any scrollable widget in Tkinter.

hmm, a single change to my example (Text to Frame) produces this
traceback:-

C:/python24/python -u "quicksb.py " Traceback (most recent call last):
File "quicksb.py ", line 17, in ?
text['yscrollcommand '] = sb.set
File "C:\python24\li b\lib-tk\Tkinter.py", line 1146, in __setitem__
self.configure( {key: value})
File "C:\python24\li b\lib-tk\Tkinter.py", line 1139, in configure
return self._configure ('configure', cnf, kw)
File "C:\python24\li b\lib-tk\Tkinter.py", line 1130, in _configure
self.tk.call(_f latten((self._w , cmd)) + self._options(c nf))
_tkinter.TclErr or: unknown option "-yscrollcommand"Exit code: 1
and another change (Frame to Label) produces this traceback:-

C:/python24/python -u "quicksb.py " Traceback (most recent call last):
File "quicksb.py ", line 17, in ?
text['yscrollcommand '] = sb.set
File "C:\python24\li b\lib-tk\Tkinter.py", line 1146, in __setitem__
self.configure( {key: value})
File "C:\python24\li b\lib-tk\Tkinter.py", line 1139, in configure
return self._configure ('configure', cnf, kw)
File "C:\python24\li b\lib-tk\Tkinter.py", line 1130, in _configure
self.tk.call(_f latten((self._w , cmd)) + self._options(c nf))
_tkinter.TclErr or: unknown option "-yscrollcommand"Exit code: 1

This would suggest that the Frame and Label widgets are not scrollable
(at least not in the 'y' direction)
Cheers
Martin

Jan 3 '06 #6
In article <11************ *********@g14g2 000cwa.googlegr oups.com>,
Dustan <Du**********@g mail.com> wrote:
BTW, experience tells me it is necessary for me to explicitly state
that I'm a newbie (otherwise I get rude people saying I should already
know such-and-such).


That experience generalize poorly to comp.lang.pytho n.
Jan 3 '06 #7

Dustan a écrit :
I'm trying to get a scrollbar bound with a Frame, and I keep on getting
a scrollbar, but it doesn't actually scroll. Some help, please?


Frames are NOT scrollable objects for scrollbars in Tkinter: Listbox,
Canvas and Text widget are.

I f you want/need to scroll something else, I think you are going to
have to do it yourself, meaning you can use the scrollbars to get user
input by binding an event to it, and then moving things around your
Frame to give the scrolling appearance.

OR you can take a look at a third-party such as PythonMegaWidge ts (PMW)
who have them I believe...

Happy New Year anyhow...

Jean-Marc

Jan 3 '06 #8
Yes, I know PMW has scrolled Text, but the module has to be installed
seperately; this is something I'm releasing to a number of people.

I'll try doing it with a canvas.

Jan 3 '06 #9

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

Similar topics

1
2241
by: Thomas Buschhardt | last post by:
Hallo, I have a problem with Tkinter and the module socket. In a console-window everything works fine, but in a Tkinter-window I can no more use the widgets. I found some other mails with this problem, but no solution (I understand really :-) Here is my code: ----------------------------------------------- import win32ui, dde, string, time, os, sys, shutil
4
5294
by: Patrick L. Nolan | last post by:
Our Tkinter application has a big ScrolledText widget which is a log of everything that happens. In order to prevent people from making changes, we have it in DISABLED mode except when the program wants to write a new entry. This works OK, except that sometimes we want to copy out of piece of the contents and paste it in another window. When it's DISABLED, it appears that we can't even select a portion of the text. Is this an...
1
2966
by: syed_saqib_ali | last post by:
Please take a look at and run the code snippet shown below. It creates a canvas with vertical & Horizontal scroll-bars. If you shrink the window to smaller than the area of the canvas, the scroll-bars work as advertised. That's great. However, if you click the Left Mouse button, it calls code which expands the width of the canvas by 100 pixels. The area being viewed expands correspondingly..... BUT I DON'T WANT IT TO!!
0
3578
by: syed_saqib_ali | last post by:
Below is a simple code snippet showing a Tkinter Window bearing a canvas and 2 connected scrollbars (Vertical & Horizontal). Works fine. When you shrink/resize the window the scrollbars adjust accordingly. However, what I really want to happen is that the area of the canvas that the scrollbars show (the Scrollregion) should expand as the window grows. It doesn't currently do this. although, if the window shrinks smaller than the...
1
2656
by: C D Wood | last post by:
To whom this may concern, Below is the source code, which demonstrates a problem I am having making a GUI for my python project work. 'table.txt' is a file that is read from the same folder. My code writes to a text file 'table.txt', and 'table.txt' is displayed in
1
3595
by: Michael Yanowitz | last post by:
Hello: Below I have included a stripped down version of the GUI I am working on. It contains 2 dialog boxes - one main and one settings. It has the following problems, probably all related, that I am hoping someone knows what I am doing wrong: 1) Pressing the Settings.. Button multiple times, brings up many instances of the Settings Panel. I just want it to bring up one. Is there an easy way to do that?
2
2322
by: jim-on-linux | last post by:
py help, The file below will run as a stand alone file. It works fine as it is. But, when I call it from another module it locks my computer, The off switch is the only salvation. This module when run as a stand alone, it will
3
4958
by: Nebulism | last post by:
Hi everyone, I am working on a module for my GUI that shows one image with an index value below and would use a scrollbar to control which of the images are displayed. The images are stored in a successive folder in the format Pic#, i,e. Pic1, Pic2 etc. What I want to do is make a slider that is attached to a label which would output the slide number that is being looked at. I would use that number then to return the image of the slide...
2
9315
by: goldtech | last post by:
Hi, I'm stumped on how to have a scrollbar with a long list of checkboxes. Given code like: from Tkinter import * root = Tk() states = for i in range(150): var = IntVar()
0
8427
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8330
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8850
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8746
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8626
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7355
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6178
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4334
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.