473,657 Members | 2,776 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

tkinter - label widget text selection

Hi,
I guess this is a very trivial question --
I am using a label widget to display text (black font in a white
background color). I am trying to use my mouse to scroll over the
displayed text to select it, but tkinter does not allow me to do it.
Is there a method/option to do this.
Thanks
Rahul

May 6 '07 #1
2 8252
ra********@yaho o.com writes:
Hi,
I guess this is a very trivial question --
I am using a label widget to display text (black font in a white
background color). I am trying to use my mouse to scroll over the
displayed text to select it, but tkinter does not allow me to do it.
Is there a method/option to do this.
Try to use an entry widget in read-only state:

<code>
import Tkinter as Tk
root = Tk.Tk()

ent = Tk.Entry(root, state='readonly ', readonlybackgro und='white', fg='black')
var = Tk.StringVar()
var.set('Some text')
ent.config(text variable=var, relief='flat')
ent.pack()
root.mainloop()
</code>

--
HTH,
Rob
May 6 '07 #2
On May 6, 2:24 pm, Rob Wolfe <r...@smsnet.pl wrote:
rahulna...@yaho o.com writes:
Hi,
I guess this is a very trivial question --
I am using a label widget to display text (black font in a white
background color). I am trying to use my mouse to scroll over the
displayed text to select it, buttkinterdoes not allow me to do it.
Is there a method/option to do this.

Try to use an entry widget in read-only state:

<code>
importTkinteras Tk
root = Tk.Tk()

ent = Tk.Entry(root, state='readonly ', readonlybackgro und='white', fg='black')
var = Tk.StringVar()
var.set('Some text')
ent.config(text variable=var, relief='flat')
ent.pack()
root.mainloop()
</code>

--
HTH,
Rob
Thanks Rob I will try it out...Rahul

May 8 '07 #3

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

Similar topics

3
2145
by: Matt Hammond | last post by:
Here's a strange one in Tkinter that has me stumped: (I'm running python 2.4 on Suse Linux 9.3 64bit) I'm trying to make a set of Entry widgets with Label widgets to the left of each one, using the grid layout. If I make and grid the Label *before* the Entry then the Entry widget doesn't seem to work - it lets me put the cursor in it, but I can't type! See example code below. Is this just me doing something really really silly, or is...
8
11964
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
2348
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 widget, but for some reason the text is invisible on cygwin). After I close the Toplevel widget, all of the menus in my app behave as though they have no contents to them, i..e I can press on the File menu button, and see it depress, but the Exit...
3
2575
by: vedran_dekovic | last post by:
Hi, I need help about Tkinter listbox widget.I want,when somebody click on any item(file) in Listbox,then in new Label widget text must be selected item from server. my program (wrong example): import ftputil import Tkinter root=Tkinter.Tk()
0
1419
by: Svenn Bjerkem | last post by:
Hi, Armed with Programming Python 3rd Edition and Learning Python 2nd edition I try to write an application which I at first thought was simple, at least until I was finished with the GUI and then wanted to start putting some data into it. As you will see, the program is not yet finished but I post what I have so far.
1
2354
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 = Label(None, text='Hello GUI world!') widget.pack() widget.mainloop()
1
3659
by: Kevin Walzer | last post by:
I'm trying to toggle the visibility of a Tkinter widget using pack_forget(), and I'm running into unexpected behavior. The widget "hides" correctly, but does not become visible again. My sample code is below: ---- from Tkinter import * root = Tk()
4
2159
by: MartinRinehart | last post by:
Everything I've read about Tkinter says you create your window and then call its mainloop() method. But that's not really true. This is enough to launch a default window from the console: Google's great, but it has no truth meter. Do I inherit from Frame? Or is that a big mistake. (Both positions repeated frequently.) Do I use Tk() or toplevel()? (Support for both and if a cogent explanation of the differences exists, I didn't find it.)
4
5581
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. I've been able to adjust the height of the text by calculating the number of lines needed to display the text. That's fairly simple. I know the number of characters in the text and width of the box (which is static). From that point I can...
0
8403
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
8316
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
8833
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
7345
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...
0
5636
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4168
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
4327
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2735
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1967
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.