f



replacing chars in text widget with an image

Oke, next problem:

I have a text widget which gets filled with strings of data read from a
socket.
Is there any way to replace certain characters in the line with an image,
after the string has been inserted into the text widget?

Thanx,
Pat.



0
7/25/2003 8:41:53 AM
comp.lang.tcl 23429 articles. 2 followers. Post Follow

2 Replies
447 Views

Similar Articles

[PageSpeed] 51

Pat wrote:
> Oke, next problem:
> 
> I have a text widget which gets filled with strings of data read from a
> socket.
> Is there any way to replace certain characters in the line with an image,
> after the string has been inserted into the text widget?

It is very straight-forward

use [.text search ...] to find the strings
use [.text delete ...] to remove them
use [.text image create ...] to insert images at the same spot

0
bryan1 (353)
7/25/2003 2:06:06 PM
"Pat" <patrick_mans@hotmail.com> wrote in message news:<3f20ed50$0$13799$4d4ebb8e@read.news.nl.uu.net>...
> Oke, next problem:
> 
> I have a text widget which gets filled with strings of data read from a
> socket.
> Is there any way to replace certain characters in the line with an image,
> after the string has been inserted into the text widget?
> 
> Thanx,
> Pat.

I have a package called "markup" that I wrote for my tkoutline
application.  It allows a callback function to be called whenever
certain strings or regexps get inserted into the text widget.  The
callback function gets the start and end index of the match passed in,
so you could replace the text with an image that way.  See
documentation for the API at http://tkoutline.sourceforge.net/wiki/41.
 I don't have a separate distribution for this package.  You can get
it by downloading the tkoutline application.

Brian
0
btheado (6)
7/25/2003 4:49:40 PM
Reply:

Similar Artilces:

Replace text with image in text widget
I'm trying to replace an emoticon with an actual image in a text widget. I know I'm not doing this correctly: the sample code below inserts two images randomly and seems to garble the text in other ways. The idea is to have two emoticons (one on each line) and replace them with an image, nothing more. Can anyone take a look and suggest how I might get this to work? Thanks. --- SPfHZvvOGvfQEvfGdvjQE/rNMfrOMfrNPfvQHfzQHfjQLfrNRvjQL/vRJfzRJvrOWvbMh/3VHPfM h/3WHPzVMP7XF/zVMfrPdv7YGP7YG/7YHPzWPPzWPfvUVP7ZHf7ZIPvWVf7aJv7aJ/7bJv7bM/7b NP7cLf7dMPvXeP7dNvrVlv7eOPrWlvvaevrYmP7gRP7gRf7gRv7iTf7iWf7jUf3hav7jVv7jV/7k YP7lYfzioPzjn/zjoP7ocvzkoP7oc/7pcf7pcvzlp/7pe/7pfP3mp/7si/7tjf/tkf/tkv7uj/3r tf3stf/voP/vo//woP/wof/wpf/wp/7xuf7xvP/zqv7xwf/zq/7yuf/zsP/zsf/zsv7yv//zs/7y xP/zuf/zu//1vP70zv/2vP/2wv/2w//3wv/20P/3zf/3zv/30P/4zv/5z//51P/51f/61f/61v/5 4v/63v/64v/73//85v/85//87f/87v/98v/+9v////////////////////////////////////// /////////////////////////////////////////////////////yH+GkNyZWF0ZWQgd2l0aCBH SU1QIG9uIGEgTWFjACH5BAEKAP8ALAAAAAAWABYAAAj+AP8JHEiwoMGDA3cUMfID4UEZVlBB+/YN miosNxwKHAIrXLlz6NCdMxduVhKHQXJVs7YN3Dhy4rhdw6bryMEYqYL9QiYtWzdv2qYtA2aMFQ6D YIg5s9Xr2DNq1KIl83WrGTM3BU9YEsYrFq0ID4YVczChlqxdyjaxIAhj0ahQplYZGIALl4ADrU6F GuWoBsEZcwRJ6kQKiA9Xr3oAKfVpEiE6OQi+4GLnz6NLnUCJEgXKUyZIge58oUEQRRU2FeAcekSp UiVKkRDJobDmiguCJJ6QgaKgySBGjRoxMtRkQZQxUkoQBEGECxshBBho4MGDQ4MCQth4QRKCYAYb U8JosNGDIUEAAAgw4GEThoqODQVFMMkiBg2bPYkU8XmDRkwXJyMclIIWaZhxRhlkkFHGGWa0scUK CEGgghqF9JFHHXXk0UchcbQggU...

text in a widget, text-widget
hello i have an application with a couple of text widgets but i would like to add some functionalities that at first and second sight are not directly supported by the plain text widget itself - ? for example i would like certain lines of text within the textwidget to take different background colors according to certain parameters also i would like to be able to detect certain sentences or words that would become 'links' and by clicking them i would open up different windows any suggestions to solutions and widgets for the above problems ? - i probably could...

Printing text, image, text, image, ...
I have bunch of text files (about 20 lines) and bunch of image files. Is there a clean way to print text, then image, then text, then image, ...., as though there are in single continuous document? -- William Park <opengeometry@yahoo.ca>, Toronto, Canada ThinFlash: Linux thin-client on USB key (flash) drive http://home.eol.ca/~parkw/thinflash.html BashDiff: Super Bash shell http://freshmeat.net/projects/bashdiff/ ["Followup-To:" header set to comp.os.linux.misc.] On Fri, 23 Jun 2006 20:01:01 -0400, William Park staggered into the Black Sun and said: > I have [a] bu...

RE: text in a widget, text-widget #2
Johan, Here this will give you an idea how to create a link in a text widget as well as some other tags. HTH Mike use strict; use Tk; use Tk::Dialog; my $mainWindow = MainWindow->new(-title => "Test Tags"); my $sc_width = 100; my $sc_height = 15; my $scrolled = $mainWindow->Scrolled( "Text", -scrollbars => 'se', -background => 'white', -wrap => &...

Re: text in a widget, text-widget @ 1146167556
Intrah onat Diria .. Tue, 25 Apr 2006 13:55:44 -0700 ,Van Nieuwenhuize, Mike wrote "Noalim y": > > Johan, > > Here this will give you an idea how to create a link in a text widget as > well as some other tags. > > HTH > > Mike > > use strict; > use Tk; > use Tk::Dialog; > > my $mainWindow = MainWindow->new(-title => "Test Tags"); > > my $sc_width = 100; > my $sc_height = 15; > > my $scrolled = $mainWindow->Scrolled( > ...

Re: text in a widget, text-widget @ 1145998849
Intrah onat Diria .. Tue, 25 Apr 2006 13:55:44 -0700 , ****** wrote "Revera y": > of "unsubscribe ptk" to majordomo@lists.stanford.edu > If you wish to unsubscribe from this mailing list, send the message body > This message was posted through the Stanford campus mailing list server. > ++**=3D=3D > -++**=3D=3D--++**=3D=3D--++**=3D=3D--++**=3D=3D--++**=3D=3D--++**=3D=3D--= > > > > > ,=20 > , _________________ > , |---| > , | > , lead > , ::::::opthe > , oo,loent,uaha > , }, > ,...

replacing chars in a text file
So I want to do the above, and I really, REALLY don't want to rewrite the entire file. I've been working on it for a while now, and can't for the life of me get it functioning. Basically, I want to replace the last text character of a certain line. So far all I've done has centered around trying to put the "put" pointer write before the character to write (ban pun, I know). But when I tried to use put(), nothing happened and a call to bad() afterward revealed the stream to be messed up. The spot I could get it to work was when I did no file reading from the start...

binding to images in a text widget
Hi, Is it possible to add bindings to an image that's inserted into a text widget? I'd like to do some action when the user clicks on the image. I originally had a button with the image on it but the button was too big and looked funny. Now I'd like just the image but I don't know how to set up the binding. Thanks, Keith keithv wrote: > Hi, > > Is it possible to add bindings to an image that's inserted > into a text widget? I'd like to do some action when the > user clicks on the image. > > I originally had a button with the image on it but the button > was too big and looked funny. Now I'd like just the image > but I don't know how to set up the binding. > > Thanks, > Keith > add the image to the text widget, add a tag at the position the image was inserted, then bind on that tag. For example: .text image create insert -image whatever .text tag add click insert-1c .text tag bind click <1> {puts "w00t!"} -- Bryan Oakley http://www.tclscripting.com Bryan Oakley wrote: > keithv wrote: > > Hi, > > > > Is it possible to add bindings to an image that's inserted > > into a text widget? I'd like to do some action when the > > user clicks on the image. > > > > I originally had a button with the image on it but the button > > was too big and looked funny. Now I'd like just the image > > but I don't know...

Text widget: show and hide images
Hi, Images in Text widgets are not tagable, so i wonder whether there is a more subtle way of showing and hiding (or resizing them) them besides the brute force strategy i could think of: if ($showFlag) { $textWidget->imageConfigure($imageId, -image => $image); } else { $textWidget->imageConfigure($imageId, -image => $small_DUMMY_IMAGE); } Any Ideas? Cheers, Stefan ...

Text widget scrolling with images/windows
I make heavy use of the Tk text widget's embedded windows and image feature in my applications. One item of feedback I've gotten from users is that scrolling is slower with images and embedded windows in the Tk text display, and the images (if they're large or numerous) don't scroll smoothly--they flicker and redraw. I don't see this "flickering" elsewhere, i.e. in the canvas with embedded windows. Is this a known limitation of the text widget, or are there some strategies I can use to reduce the redraw? -- Kevin Walzer Code by Kevin http://www.codebykevin.com On Sep 8, 8:09=A0am, Kevin Walzer <k...@codebykevin.com> wrote: > I make heavy use of the Tk text widget's embedded windows and image > feature in my applications. One item of feedback I've gotten from users > is that scrolling is slower with images and embedded windows in the Tk > text display, and the images (if they're large or numerous) don't scroll > smoothly--they flicker and redraw. I don't see this "flickering" > elsewhere, i.e. in the canvas with embedded windows. Is this a known > limitation of the text widget, or are there some strategies I can use to > reduce the redraw? Part of the trouble is that embedded windows and images are treated as characters, and so an image by itself is a "line" of text. That screws up the scrolling. My Notebook app has a hack for images: it splits the image into strips...

tcl text widget wrap around?
Hi, I am using a proc to detect the occurrence of certain string in a text widget. It works by periodically scan each line of the text widget (starting at the current line), check content, decrement line number if not matched, *repeats, until it reaches line 0. The problem is that it appears the text widget's line number will eventually wrap around after awhile, so it is possible that the current line index sits close to 0. Is there any easy way around this problem? How can I tell a text widget's buffer size? Thanks On 3/27/11 8:16 AM, py wrote: > Hi, &...

Stopping special chars from showing in a text widget
Hi All, I have a standard text widget in which I want to stop braces, brackets and other special chars from being entered by the user. Binding on KeyRelease doesn't get around receiving multiple keystrokes when holding a key down. Any pointers or ideas anyone ? TIA Don Cruickshank Don Cruickshank wrote: > Hi All, > I have a standard text widget in which I want to stop braces, brackets and > other special chars from being entered by the user. > Binding on KeyRelease doesn't get around receiving multiple keystrokes when > holding a key down. > Any pointers or ideas anyone ? Overload the 'insert' widget command. You should be able to get the general idea from http://wiki.tcl.tk/1917 - although that is more directed at keeping a variable in sync with the widget content, it shows how to overload the command to intercept requested changes. Note that this suggestion will also address the case where the user tries to cut-n-paste the characters in. -- 73 de ke9tv/2, Kevin ...

Text in images to a text file
Hello, Does anyone know of any software for Linux which converts text in images to a text file. I have loads of paper documents that I intend to scan. The contents of these documents needs to eventually end up on a web site but as text. Darren <bobblebob@gmail.com> wrote in message news:1151612491.407262.124690@75g2000cwc.googlegroups.com > Does anyone know of any software for Linux which converts text in > images to a text file. I have loads of paper documents that I intend > to scan. The contents of these documents needs to eventually end up > on a web site but as text....

aligning text and image-text
I use a program to make Email addresses harder for spammers to harvest. It converts them to slightly blurred images using http://mindprod.com/products1.html#MASKER When I embed them in text, I have figured out how to get them to align naturally with the surrounding text, but the browser inserts extra inter-line spacing above the line containing the image. You can see the effect at http://mindprod.com/book/books.html at the bottom of the page where it says: "Please email your feedback for publication, letters to the editor, errors, omissions, typos, formatting errors, ambig...

Setting image background colour in text widget?
Is it possible to set the background colour for an embedded image in a text widget? (The image has a "transparent" background). Many Thanks, =Adrian= Adrian Davis wrote: > Is it possible to set the background colour for an embedded image in a > text widget? (The image has a "transparent" background). I'm sorry, but I don't fully understand what you're asking for there. Images in text widgets (or elsewhere for that matter) which have transparent bits are supposed to show whatever is behind the image (the widget background in the case of text widgets) in the transparent bits. I even believe that that happens correctly now (things are a bit more complex with semi-transparent images; they're computationally much more expensive, require an extension to load into Tk, and were not displayed correctly until a few months ago.) So, the correct way to set the "background" for an embedded image is to set the background of the widget. But I suspect that you're after something else, yes? Where you're setting the background colour to something non-standard, perhaps? If you've got Tk 8.4, you can copy the image onto another one (I'd suggest filling the target of the copy with your preferred background colour first) with the "overlay" compositing rule. That should do the trick, and it ought to be relatively fast too. (I can't remember if that works in 8.3; I've tinkered with that code so much I...

Text IN an Image To Straight Text?
Hi. (I'm not sure where to ask this so I'm trying a few newsgroups) I have some .jpg's of text documents. Is there a utility which will work like OCR in a scanner, helping to convert the text WITHIN the image to straight text? I don't have a printer working at the moment, or I'd print the .jpg's and then scan them using OCR. (The format doesn't necessarily have to be .jpg) Thanks in advance for any help GP Yes, if the image is not to bad a pic (not much noise and all that). Try http://www.twocows.com/windows.html I know they have a couple of ocr programs s...

How to.. Large image and text over image?
L.S., (just started using LaTeX 4 months ago) I have written my thesis and it's almost ready to be printed, but I have two problems: For my titlepage I've made an image which covers 98% of an A4-paper (size used to print my thesis on). The first problem is about the size of the image: how do I get the image to be correctly centered on the title-page. I've tryed serveral things, but none seemed to help. The second problem is that over the image text will have to be displayed and printed. The image is a background-image, so to say. How can I do this? Thank for your help, Koos On Wed, 5 Jan 2005 05:50:09 -0500, Koos Hopeloos wrote (in article <4d826b82.0501050250.5e1445f6@posting.google.com>): > L.S., > > (just started using LaTeX 4 months ago) > I have written my thesis and it's almost ready to be printed, but I > have two problems: > For my titlepage I've made an image which covers 98% of an A4-paper > (size used to print my thesis on). > The first problem is about the size of the image: how do I get the > image to be correctly centered on the title-page. I've tryed serveral > things, but none seemed to help. > The second problem is that over the image text will have to be > displayed and printed. The image is a background-image, so to say. How > can I do this? > > Thank for your help, Koos Greetings Koos - I think the wallpaper package on CTAN (http://www.tug.org/tex-archive/macros/latex2e/co...

highlight text in text widget
Hi, I am trying to make widget that displays text. I also want a search keywords available. The way I have envisioned is something similar to emacs search, i.e. it highlights all the occurrences of the keyword that you are interested in. I am trying to find out if that kind of highlighting be done in widget_text or some other widgets. Can anyone help? Thanks neon writes: > I am trying to make widget that displays text. I also want a search > keywords available. The way I have envisioned is something similar to > emacs search, i.e. it highlights all the occurrences of the keyword &g...

Replacing text with a background image affects printing
I have seen lots of examples where some HTML text is replaced with a background image using CSS. For example, replacing the text of an <h1> with a graphical logo, like so: CSS: h1 span { display: none; } h1 { height: 100px; background: url("mycompany.gif") no-repeat 35px 40px; } HTML: <h1><span>My Company</span></h1> This allows the text version to be displayed for non-CSS browsers, and allows a more visually appealing logo to be displayed for CSS enabled browsers (assuming they don't have images turned off). One side effect of thi...

Text and Image inside table <td> Alight Text Left and Image right in same cell ??
Is that possible? How? <td > <asp:Label ID="StartDateLabel" runat="server" Text="Start Date:"> <asp:imagebutton ID="Imagebutton1" width=18 Height=18 CommandName=SetDate imageUrl="../cal.jpg" runat=server /> </asp:Label> </td> <td > On 2006-10-24, Jason <jason@cyberpine.com> wrote: > Is that possible? How? Set text-align: left on the cell as usual (it's likely to be the default), and make the image float: right. To work around a Firefox float bug, better to put the image befor...

8.5a2 text widget crashes with embedded image
Hi, I'm getting a Tcl_Panic "Added too many new lines in UpdateDisplayInfo" in generic/tkTextDisp.c:1888 . I create an image with set logo [image create photo -file [findfile logo.gif]] (findfile just prepends the appropriate path from auto_path). Then I create a text widget and put the image in it: text $W.out.txt -xscrollcommand "dynsbset $W.out.h" -yscrollcommand "dynsbset $W.out.v" -bg #dfffdf if { !$::modest } { $W.out.txt image create end -image $::logo $W.out.txt insert end "\n\n" $W.out.txt tag configure center -justify center $W.out.txt tag add center 1.0 2.0 } As the program runs, it writes to this text widget (which is not mapped yet), and to another which is visible. When enough lines have been written that the widget needs to scroll (I have a moveto to keep the end of the widget visible), then I get this panic. The image is much taller than a single line of text. I'm thinking that this causes Tk to become confused about what can fit on the screen. Is there any other place in which I should report this? Thanks bugcatcher bugcatcher schrieb: > Hi, > > I'm getting a Tcl_Panic "Added too many new lines in UpdateDisplayInfo" > in > generic/tkTextDisp.c:1888 . > I create an image with > set logo [image create photo -file [findfile logo.gif]] > (findfile just prepends the appropriate pa...

text-widget and typing non-latin chars (greek again)
While the text-widget can perfectly display the greek chars (if inserted as unicode-chars), it doesn't seem to accept them directly from keyboard: package require Tk (--> 8.5) text .t pack .t bind .t <Key> {puts "%A %K"} (now I switch keyboard to "el" and type some letters) {} Greek_gamma {} Greek_phi {} Greek_delta (now I switch back to "de" and type the same letters) g g f f d d Also, with Georgios' Keyboard, I can "enter" the greek letters through his virtual keyboard, but trying to type greek letters directly to the text-widget also fails. It looks like Tk doesn't know how to translate the Greek_* keycodes to unicode-chars. I don't know whose responsibility it is to do this, and on what local things this might depend, but opera, firefox, gedit, gvim(after: ":set enc=utf-8") and uxterm all do this perfectly well. This is one of my gripes as well. The last time I posted a question about it, the only response I got was that I could accomplish the same thing with key bindings, which in my opinion is a suboptimal solution. By the way, which OS are you on? I'm experiencing these issues on Windows XP, and curious if things work better on Mac or Linux. Aric Bills <aric.bills@gmail.com> wrote: > This is one of my gripes as well. The last time I posted a question > about it, the only response I got was that I could accomplish the same > thing with key bindings, which in m...

Tcl/Tk text widget article in Linux Journal
Linux Journal have just published an article I wrote on the Tk text widget. None of the seasoned veterans on c.l.t will learn anything from it, but newbies might find it useful. The information should apply to Windows users too. The link is: http://www.linuxjournal.com/article.php?sid=7357&mode=thread&order=0 This is the first Tcl article (or indeed, any article) I've had published, so I'd welcome any constructive feedback - both on my writing and my Tcl coding. More importantly, this is the first Tcl based article that Linux Journal have published. When I made the original suggestion to the editor he asked why Tcl was better than Perl, Python and shell, which are the usual languages the magazine focuses on. I put forward gentle arguments and he agreed to give something Tcl-based a try. The magazine is now awaiting feedback to see if it is worth them running further Tcl articles. Putting that another way, there's a new opening for spreading the Tcl-word here. Linux Journal receiving page hits and comments from the Tcl community can only be a good thing, so hit the link! In article <400b35da$0$1753$5a62ac22@freenews.iinet.net.au>, Derek Fountain <nomail@hursley.ibm.com> wrote: . . . > http://www.linuxjournal.com/article.php?sid=7357&mode=thread&order=0 > >This is the first Tcl article (or indeed, any article) I've had published, >so I'd welcome any constructive feedback - both on my writing and my Tcl ...

Removing border from image buttons embedded in text widget
Hi all, I am trying to embed a small button containing an image into a text widget. I have created an image which is as high as a normal line of text, and then use the following code to insert it into the text widget: button $buttonBar.$srcLineIter -image $Images::dwt \ -borderwidth 0 -padx 0 -pady 0 -highlightthickness 0 \ -command "expandAssembly $inst $srcFile $srcLineIter" \ $buttonBar window create $srcLineIter.0 \ -window $buttonBar.$srcLineIter \ -align center -padx 0 -pady 0 However, this code always results in a one-pixel border being displayed around the button, which results in the text widget's line spacing changing for the line containing the image (i.e., the button uses two more pixels than the line would normally use). How do I remove this border, so that my embedded button is the same height as a line of text? As you can see, I have tried using the highlightthickness and borderwidth options for the button to remove the border, but this doesn't seem to work. If I change the relief of the button to flat, two pixels are inserted to the left, and above the image, with no extra pixels appearing to the right, and below? If I use an embedded image, instead of an embedded window button, the image appears without the border. What am I doing wrong? I am using Tk 8.3, running on a Redhat 8 system using KDE. thanks, dan. Hi, Why not use the 'image create' command and put a tag and binding on the ...

Web resources about - replacing chars in text widget with an image - comp.lang.tcl

Facebook Tests Replacing Keyword Ad Targeting With Broad Category Targeting
Facebook is testing a major functionality change for its self-serve performance ad tool that would replace the specific Like keyword targeting ...

The Dangers of Replacing Coil Springs on Your Vehicle - Bonus Clip - YouTube
In this episode of Saturday Mechanic bonus clip, Ben and Russ show what happens when a coil spring compressor fails. Subscribe today for more! ...

School apologises for taking cane off blind boy and replacing it with pool noodle
A primary school has apologised for taking away the cane of an eight-year-old blind boy and replacing it swimming pool noddle as a form of punishment. ...

Federation Centres stuns market by replacing CEO Steven Sewell with Angus McNaughton effective immediately ...
Retail landlord Federation Centres has surprised the market with the&nbsp;appointment of&nbsp;former Novion Property's Angus McNaughton as the ...

Replacing China's broken economic gauge
As Chinese growth shifts away from its reliance on heavy industry, we need a new index to the track the ups and downs of the economy.

Inner south residents worried about high-rises replacing public housing flats
Residents say the&nbsp;government&nbsp;is over-developing its inner south blocks to maximise their sale value.

Apache Software Foundation unveils Hadoop 2, replacing MapReduce with YARN
The Apache Software Foundation unveiled its latest release of its open source data processing program, Hadoop 2. It runs multiple applications ...

Australia spends $110 million a year replacing lost coins
Australians lose 255 million coins every year - down the back of our couches, taken overseas in the pockets of tourists and stuck to footpaths. ...

Tweets Replacing Resumes - Twitter Becomes Job-Hunting Tool
Forget paper resumes, your next job could hang on a 140-letter tweet.

A case of one bad government replacing another
THERE is a widening gap between the sort of government a Tony Abbott-led Coalition will need to become to steer the nation successfully in the ...

Resources last updated: 3/13/2016 8:58:27 PM