I am trying to put textinput and label with same settings in one place so text would be at same place but textinput making strange indent while label doesnt.
I am calculating height of text with limited width using label’s function _label.texture.size
and then applying this height and width to text input and label expecting two textes would be in same place for accurate label’s text selection. But im getting this, firstly all is good but then text in textinput makes strange indent and all text then goes wrong.
Result:
Code:
from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.textinput import TextInput
from kivy.uix.floatlayout import FloatLayout
class main(App):
def build(self):
f = FloatLayout()
text = "This is random text Every time you're online, you are bombarded by pictures, articles, links and videos trying to tell their story. Unfortunately, not all of these stories are true. Sometimes they want you to click on another story or advertisement at their own site, other times they want to upset people for political reasons. "
labeltocheckheight = Label(text=text, text_size=(200, None), markup=True,font_size="24", size=(400, 100), pos=(100, 100), size_hint=(1, 1), valign='top')
labeltocheckheight._label.refresh()
width, height = labeltocheckheight._label.texture.size
label = Label(text=text, text_size=(width, height), markup=True,font_size="24", size=(width, height), pos=(100, 100), size_hint=(None, None), valign='top')
textinput2 = TextInput(text=text, font_size="24", size=(width, height), cursor=(0,0),pos=(100, 100), size_hint=(None, None), readonly=True, foreground_color=(1, 1, 1, 0.5),background_color=(1, 0, 0, 0), padding=0)
f.add_widget(textinput2)
f.add_widget(label)
return f
main().run()
Mango is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.