I am trying to create a simple notepad for android. How can I add line numbers to the Kivy's TextInput()? My code is
from kivy.app import App
from kivy.uix.textinput import TextInput
from kivy.uix.boxlayout import BoxLayout
class Text(TextInput):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.hint_text = "Your text here"
class NotePad(App):
def build(self):
box = BoxLayout()
text = Text()
box.add_widget(text)
return box
I want to add the line numbers. How can I do that?
Is late for you base on time stamp, but I found it my self in the same problem like you and I assume are and other on the same both. I'm new in kivy and I do note use KV files because some times is confusing me, I like more of "python" style.
I take a look on kivy API and I found my own way of doing line numbers. Is not the best one or the smarter one, but is doing the job.
Because CodeInput is inherit from TextInput you can replace it and will work as well.
I updated the code to solve errors and I added comments and futures. For now one I will continue to update it on my github because is become a little bigger (600+ lines).
Preview: