Skip to content

Tutorial EzLang Label

ddbnl edited this page Aug 29, 2022 · 2 revisions

The label widget displays (colored) text non-interactively. If the label has a height higher than one, text will be automatically wrapped to respect word boundaries.

The text of a label comes either from its 'text' property, or from a text file using the 'from_file' property. If you load the text from a text file, then the file must be available in the folder specified by the EZ_FOLDER environment variable, and referred to as './path/to/file.txt' (the relative path starts at your EZ_FOLDER).

Fully formatted text and justify options are on the roadmap with priority.

Here are a few cropped examples with screenshots (see 'examples' for the full functional EzLang/code):

Scaled label

// This is a label with auto scale enabled. This way it will not take up any more space than needed.
// Keep in mind that since auto scale width is enabled, the label will always be height 1. In the next example
// we'll show how to grow the label vertically.
- Label:
    text: Scaled label
    auto_scale: true, true
    border: true

label_example_1

Scrolled, vertically growing label from text file

// This label loads a large dummy text from a file. We want the label to fit the text, so we want it to grow. We
// can accomplish this by fixing the width to the width of the layout (already true due to default
// 'size_hint_x: 1.0') and auto scaling height. We'll wrap it inside of a scrolling layout as well.
- Layout:
    scroll_y: true
    size_hint_y: 0.5
    border: true
    - Label:
        from_file: lorem_ipsum.txt
        auto_scale_height: true

label_example_2

Centered label

// This label is centered. In order to center we have to scale the label, because if the label takes up the full
// width of the layout, it cannot be centered.
- Label:
    text: Centered label
    auto_scale: true, true
    halign: center
    border: true

label_example_3

Colored text label

// This label has colored text through fg_color
- Label:
    text: Yellow label
    auto_scale: true, true
    fg_color: yellow
    border: true

label_example_4

Continue

The general tutorial continues with: EzLang Text input.

Tutorial Tutorial-Project-Structure
  Minimal example
EzLang
  EzLang basics
  EzLang Templates
  Ezlang Layout modes
   EzLang Box mode layouts
   EzLang Stack mode layouts
   EzLang Table mode layouts
   EzLang Float mode layouts
   EzLang Tab mode layouts
   EzLang Screen mode layouts
   EzLang Layout Scrolling
   EzLang Layout Views
  EzLang Widget overview
   EzLang Label
   EzLang Text Input
   EzLang Button
   EzLang Checkbox
   EzLang Radio button
   EzLang Dropdown
   EzLang Slider
   EzLang Canvas
  EzLang Property Binding
  EzLang Sizing
   EzLang Size hints
   EzLang Auto scaling
   EzLang Maths Sizing
   EzLang Manual Sizing
  EzLang Positioning
   EzLang Layout Mode Positioning
   EzLang Position Hints
   EzLang Position Maths
   EzLang Manual Position
   EzLang Adjusting Position
  EzLang Keyboard Selection
Scheduler
  Widget States and the State Tree
  The Scheduler Object
  Managing callbacks
   Callback Structure
   Callback Configs
   Callback: On keyboard enter
   Callback: On Left Mouse Click
   Callback: On Press
   Callback: On Select
   Callback: On Deselect
   Callback: On Right Mouse Click
   Callback: On Hover
   Callback: On Drag
   Callback: On Scroll Up
   Callback: On Scroll Down
   Callback: On Value Change
   Callback: Custom Key Binds
   Callback: Global Key Binds
   Callback: Property Binds
  Tasks
   Scheduled Single Exectution Tasks
   Scheduled Recurring Tasks
   Threaded Tasks
  Custom Properties
  Modals
  Programmatic Widgets
  Updating widgets
  Managing selection
Default global (key)binds
Performance
ExamplesLayout: Box Mode Nested
Layout: Box Mode Size Hints
Layout: Stack Mode
Layout: Table Mode Dynamic
Layout: Table Mode Static
Layout: Float Mode Manual
Layout: Float Mode Position hints
Layout: Screen Mode
Layout: Tab Mode
Layout: Scrolling
Layout: Views
Widget: Label
Widget: Text input
Widget: Button
Widget: Checkbox
Widget: Radio Button
Widget: Dropdown
Widget: Slider
Widget: Progress Bar
Widget: Canvas
Scheduler: Schedule Once
Scheduler: Schedule Once Callback
Scheduler: Schedule Recurring
Scheduler: Schedule Recurring Callback
Scheduler: Threaded Task State Tree
Scheduler: Threaded Task Custom Property
Scheduler: Create Widgets
Scheduler: Modal Popup
Reference Widgets
  Common Properties
  Label
  Text Input
  Button
  Checkbox
  Radio button
  Dropdown
  Slider
  Canvas
Scheduler
  Schedule once
  Schedule Recurring
  Schedule Threaded
  Cancel Task
  Cancel Recurring Task
  Create Widget
  Remove Widget
  Select Widget
  Deselect Widget
  Update Widget
  Force Redraw
  Open Modal
  Dismiss Modal
  Bind Global Key
  Remove Global Key
  Clear Global Keys
  Bind Property
  Create Custom Properties
  Get Property
  Get Property Mut
  Overwrite Callback Config
  Update Callback Config
  Exit
Clone this wiki locally