sairam kumar :
Goal:
- To anchor the label to the bottom-left using FloatLayout.
Expected Result:
- The label must be on the bottom-left corner with a single line.
Actual Result:
- The label is on the bottom-left but it is double-lined.
The code:
class ScreenThree(Screen):
def __init__(self, **kwargs):
super(ScreenThree, self).__init__(**kwargs)
self.video1 = Video(source="somevideo.mpg")
float_layout = FloatLayout()
self.label1 = Label(text="Just a place holder video", opacity=0, pos_hint={"x": 0, "bottom": 1}, size_hint=[0.1, 0.1])
self.label1.texture_size = self.label1.size
self.label1.text_size = self.label1.texture_size
self.label1.halign = "center"
self.label1.valign = "center"
self.add_widget(float_layout)
float_layout.add_widget(self.label1)
float_layout.add_widget(self.video1, index=1)
self.video1.opacity = 0
def on_enter(self):
self.video1.allow_stretch = True
self.video1.state = "play"
self.label1.opacity = 1
Clock.schedule_once(self._adjust_opacity, 2)
def _adjust_opacity(self, *dt):
self.video1.opacity = 1
The Image:
Thank you very much for reading.
John Anderson :
In your line:
self.label1 = Label(text="Just a place holder video", opacity=0, pos_hint={"x": 0, "bottom": 1}, size_hint=[0.1, 0.1])
Just change the size_hint
to [None, 0.1]
:
self.label1 = Label(text="Just a place holder video", opacity=1, pos_hint={"x": 0, "bottom": 1}, size_hint=[None, 0.1])
and remove the lines:
self.label1.texture_size = self.label1.size
self.label1.text_size = self.label1.texture_size
self.label1.halign = "center"
self.label1.valign = "center"
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=319268&siteId=1