Hi list, hi Michael,> Hi everybody,
> I'm looking for some directions, while programming a very simple
> editor (supporting basic formatting)
>
> The window where the user writes is a Text widget (named: text), where
> I put a tag 'b' to set the text where this tag applies to bold.
>
> This is not a problem when I apply the bold to a selection:
>
> text.tag_add('b', SEL_FIRST,SEL_LAST)
>
> I have instead two problems when I just want to switch on/off the bold
> while typing. To switch it on the only way I found is this:
>
> text.insert(INSERT, ' ', 'b' )
> text.mark_set("insert", INSERT+'-1c')
>
> notice that I have to insert TWO spaces. If I insert one, the bold
> doesnt apply. If I insert '', my cursor goes back one char!
>
> My second problem is how to switch it off, when I'm writing within a
> bolded region - and for this I havent the slightest idea...
After different attempts at it, I realized that the following works perfectly for deselecting the currently active bold tag. It still suffers from the problem that when I 'switch on' the tag it adds a space - but I can live with it...
thanks! alessandro -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ / Dr.Alessandro Magni \ Electromagnetics Division / INRiM Strada delle Cacce 91, 10135 Torino (ITALIA) \ Email [email protected] / Tel: 0039-011-3919821 Fax: 0039-011-3919834 \ URL http://www.inrim.it/~magni / Our business in life is not to succeed but to continue to fail \ in high spirits. -- Robert Louis Stevenson ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
_______________________________________________ Tkinter-discuss mailing list [email protected] http://mail.python.org/mailman/listinfo/tkinter-discuss
