1

I have this code:

#Displaying Line Numbers
def update_line_number(event=None):
    txt = ''
    if showln.get(): 
        endline, endcolumn = textPad.index('end-1c').split('.')        
        txt = '\n'.join(map(str, range(1, int(endline))))
    lnlabel.config(text=txt, anchor='n', font=("Arial",13))

And I have this:

textPad = Text(root, undo=True, relief='flat', font=("Arial",13))
textPad.pack(expand=YES, fill=BOTH)
scroll=Scrollbar(textPad)
textPad.configure(yscrollcommand=scroll.set, insertbackground='#cbcbcb',bg='#202020',fg='#cbcbcb', highlightbackground="#252525", highlightcolor="#252525")

lnlabel = Label(textPad,  width=3,  bg='#252525', fg='#a2a2a2', relief='flat')
lnlabel.pack(side=LEFT, anchor='nw', fill=Y)

When I add too many lines the lines are not displayed correctly only shows up to line 27, lines are added, but in the Label widget are not moving, the lines are not allocated to each line number if I maximize the application only shows up to line 47 the Text widget scrolls but the lines don't, what I can do?

Kik Bm
  • 13
  • 4
  • For a better (though more complex) way to add line numbers to a text widget, see http://stackoverflow.com/a/16375233/7432 – Bryan Oakley Aug 11 '14 at 18:40

0 Answers0