[Tkinter-discuss] Text and newlines [newbie Q]
spooky.ln at tbs-software.com
spooky.ln at tbs-software.com
Mon Jan 3 13:50:44 CET 2011
hi all,
i have little method for parsing line in tkinter.Text.
text.bind(‘<Return>’, parse)
def parse(event=None):
text = get_current_line() # this give me whole text on line
pattern = r”^.*define\s<?P<defkeyword>.*):$” # simple search pattern
reg = re.compile(pattern, re.S|re.M) # for use with more patterns
match = re.search(reg, text)
if match:
print(‘found %s definition.’ % match.group(‘defkeyword’))
text.insert(‘end’, ‘\n’)
text.insert(‘insert linestart’, ‘\t’)
there is small problem for me. how to insert tab into newline without next ‘\n’ ?
i want only 2 lines not 3.
i want:
1. define some:
2. .......[next insert will be here]
and not:
1. define some:
2. .......
3. [now ‘end’ points here]
and second how i define width of tab in chars not in pixels using text.config(tabs=X)
thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tkinter-discuss/attachments/20110103/deac0f7b/attachment.html>
More information about the Tkinter-discuss
mailing list