473,396 Members | 1,884 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,396 software developers and data experts.

Tkinter text widget

I thought the "DISABLED" made it so I could not edit it. But it also
makes it so I can not scroll down. If you make the window smaller than
the content then try to put a cursor in there to use up/down arrow you
can't.

What I want is not to be able to change text content, but no other
action is disabled. Is this complicated to do?

Thanks.
from Tkinter import *
root = Tk()
text = Text(root, font=("Courier"))
text.pack()
i='123456789abcdefghijklmnopqrstuvwxyz\n'
for x in range(30):
text.insert(END, i)
text.config(state=DISABLED)
mainloop()

Oct 7 '07 #1
5 5214
ezd
On Oct 6, 11:18 pm, goldtech <goldt...@worldpost.comwrote:
I thought the "DISABLED" made it so I could not edit it. But it also
makes it so I can not scroll down. If you make the window smaller than
the content then try to put a cursor in there to use up/down arrow you
can't.

What I want is not to be able to change text content, but no other
action is disabled. Is this complicated to do?

Thanks.

from Tkinter import *
root = Tk()
text = Text(root, font=("Courier"))
text.pack()
i='123456789abcdefghijklmnopqrstuvwxyz\n'
for x in range(30):
text.insert(END, i)
text.config(state=DISABLED)
mainloop()
You can scroll, but you can't see the cursor. Use

for x in range(30):
text.insert(END, "%3d " % x + i)

to check.

ED

Oct 7 '07 #2
You can scroll, but you can't see the cursor. Use

for x in range(30):
text.insert(END, "%3d " % x + i)

to check.

ED
I tried it w/the line numbers. On my system I see 0-23.

But there is no way to scroll. Still the same result.

Oct 7 '07 #3
On Oct 6, 11:18 pm, goldtech <goldt...@worldpost.comwrote:
I thought the "DISABLED" made it so I could not edit it. But it also
makes it so I can not scroll down. If you make the window smaller than
the content then try to put a cursor in there to use up/down arrow you
can't.

What I want is not to be able to change text content, but no other
action is disabled. Is this complicated to do?

Thanks.

from Tkinter import *
root = Tk()
text = Text(root, font=("Courier"))
text.pack()
i='123456789abcdefghijklmnopqrstuvwxyz\n'
for x in range(30):
text.insert(END, i)
text.config(state=DISABLED)
mainloop()

I just tried this script. You can select text and if you drap the
selection outside the window then scrolling occurs, also Tk's default
behavior of scrolling with the middle button still works (i.e. click-
and-drag with the middle button to scroll.)

The arrow keys don't scroll the window, but that's because either A.
the Text widget won't take 'focus' while disabled -or- B. the arrow
keys et. al. work through the cursor which isn't there in disabled
mode. I'm guessing and I'm not sure which is right, or if it's
something else entirely.
Try adding a scrollbar widget and tying it to the Text (there are
webpages out there that describe how to do this), I think this widget
would still get focus (since it's NOT disabled) and therefore be able
to scroll the Text. Or try explicitly binding the arrow keys to
scroll commands.
~Simon

Oct 7 '07 #4
On Oct 7, 11:00 am, Simon Forman <sajmik...@gmail.comwrote:
On Oct 6, 11:18 pm, goldtech <goldt...@worldpost.comwrote:
I thought the "DISABLED" made it so I could not edit it. But it also
makes it so I can not scroll down. If you make the window smaller than
the content then try to put a cursor in there to use up/down arrow you
can't.
What I want is not to be able to change text content, but no other
action is disabled. Is this complicated to do?
Thanks.
from Tkinter import *
root = Tk()
text = Text(root, font=("Courier"))
text.pack()
i='123456789abcdefghijklmnopqrstuvwxyz\n'
for x in range(30):
text.insert(END, i)
text.config(state=DISABLED)
mainloop()

I just tried this script. You can select text and if you drap the
selection outside the window then scrolling occurs, also Tk's default
behavior of scrolling with the middle button still works (i.e. click-
and-drag with the middle button to scroll.)
Yes, if I depress the mouse's scroll wheel (the middle button) I can
drag the content up/down. Interesting...I didn't know that. But I
can't select, XP Python 2.1.

I'll try adding scroll bars. Thanks.

....snip...

Oct 8 '07 #5
After some Google searching I found "ScrolledText", this does what I
want :^)
from Tkinter import *
from ScrolledText import ScrolledText
root = Tk()
text = ScrolledText(root, font=("Courier"))
ScrolledText
text.pack()
i='123456789abcdefghijklmnopqrstuvwxyz\n'
for x in range(30):
text.insert(END, "%3d " % x + i)
text.config(state=DISABLED)
mainloop()

Oct 8 '07 #6

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

Similar topics

1
by: Pekka Niiranen | last post by:
Hi there, after reading TkInter/thread -recipe: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/82965 I wondered if it was possible to avoid using threads for the following problem: ...
2
by: Tonino | last post by:
Hi, I have a small Tkinter app that gets data from a socket connection to a "server". The app has a Text() widget to display the info that it gets from the socket connection. I have the...
7
by: Harlin Seritt | last post by:
I was looking at the Tcl/Tk sourceforge page and found that there were a couple of new widgets being produced for Tcl 8.5. Does anyone know if there are any Tkinter wrappers somewhere? thanks, ...
2
by: Grooooops | last post by:
I've been hacking around this for a few days and have gotten close to what I want... but not quite... The TKinter Docs provide this example: # configure text tag text.tag_config("a",...
8
by: Dustan | last post by:
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?
0
by: Stewart Midwinter | last post by:
I have a Tkinter app running on cygwin. It includes a Test menu item that does nothing more than fetch a directory listing and display it in a Toplevel window (I'd use a tkMessageBox showinfo...
1
by: vijayca | last post by:
my python installation is:Active python 2.5.1 i am using Red Hat Linux i have the Tkinter module installed but any simple script produces an error.... script: from Tkinter import Label widget...
0
by: lee.walczak | last post by:
I actually post a topic relating to my problem here: (http://groups.google.co.uk/group/comp.lang.python/browse_thread/ thread/a073d532c4481bfe?hl=en# ) But I thought it could be useful to...
3
by: J-Burns | last post by:
Hello. Im a bit new to using Tkinter and im not a real pro in programming itself... :P. Need some help here. Problem 1: How do I make something appear on 2 separate windows using Tkinter? By...
4
by: Mudcat | last post by:
I've tried quite a few things to get this correct but have hit a couple of sticking points that I can't figure out. I need to ge the Text box to function like the 'wraplength' option in a Label. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
0
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
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,...

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.