About left justification and right justification of Kivy Label

Kivy Label displayed in the center when written normally

Use Label to display characters in Kivy. If you want to move it to the upper left, write it like below.

test.kv


Label:
    text: root.text
    halign: 'left'
    valign: 'top'

Actually, this doesn't move to the upper left. It is displayed in the center. Label has a property called text_size that determines the display area in addition to size. halign and valign are properties that determine the position in text_size.

If text_size remains small, no matter which one you approach within text_size The text_size itself is displayed in the center After all, the characters are displayed in the middle.

Let's specify text_size

If you specify text_size: self.size as shown below, the entire Label area will be displayed. It becomes the display area of characters. The characters will be displayed in the upper left because they will be moved to the upper left.

Label:
    text_size: self.size       #← Add
    text: root.text
    halign: 'left'
    valign: 'top'

Recommended Posts

About left justification and right justification of Kivy Label
Grid display of double plots (left and right vertical axes) (matplotlib)
About sensor_mode and angle of view of picamera
About _ and __
About the behavior of copy, deepcopy and numpy.copy
About cumulative assignment of lists and numpy arrays
About the * (asterisk) argument of python (and itertools.starmap)
About shallow and deep copies of Python / Ruby
About problems and solutions of OpenPyXL (Ver 3.0 version)
About Kivy root
About import error of numpy and scipy in anaconda
Coordinates of the right end of Label made with tkinter
Think about the next generation of Rack and WSGI
Render and synthesize objects from front, back, left and right
Personal notes about the integration of vscode and anaconda
[Python] Chapter 01-02 About Python (Execution and installation of development environment)