hi,
after few&more trying i changed example to this working:
import re
from tkinter import *
from tkinter.font import Font
def get_current_line():
start = text.index('insert linestart')
end = text.index('insert')
return text.get(start, end)
def parse(event=None):
line = get_current_line()
match = re.search(reg, line)
if match:
print('match!', match.group('defkey'))
text.insert('insert lineend', '\n') # changed
text.insert('insert', '\t') # +
return 'break' # this
was my problem i think
root=Tk()
f = Font(family='courier', size=-12)
text = Text(root, font=f, tabs=(4 * f.measure(0), 'left'),
tabstyle='wordprocessor')
text.pack(fill=BOTH, expand=1)
text.bind('<Return>', parse)
text.focus()
pattern = r"^.*define\s(?P<defkey>.*):$"
reg = re.compile(pattern, re.S|re.M)
root.mainloop()
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss