Skip to content

Tutorial EzLang Position Hints

ddbnl edited this page Aug 30, 2022 · 1 revision

Position hints can only be used for widgets that are in a layout in float mode. Using position hints you specify the relative position you want the widget to be in, and it will be handled for you. There are horizontal position hints (pos_hint_x) and vertical position hints (pos_hint_y).

The available settings for pos_hint_x are:

  • Left
  • Center
  • Right

The available settings for pos_hint_y are:

  • Top
  • Middle
  • Bottom

If you want a widget to be in the bottom right of the screen, you would give a widget: "pos_hint_x: right" and "pos_hint_y: bottom". For convenience you could use the "pos_hint" property to set both at the same time in the format: "pos_hint: x, y":

- Layout:
    mode: float
    border: true
    - Label:
        text: Hello world
        auto_scale: true, true
        pos_hint: right, bottom
        border: true

32_ez_lang_relpos

Note that in the example we auto_scale the label. If we don't, it would take up the entire screen and positioning would be pointless.

It is possible to be more specific with position hints. Instead of just specifying "bottom" for example, we could use "bottom: 0.9". This would position the widget 90% towards the bottom of the layout. The number goes from 0 to 1. This method can be used for 'center', 'right', 'middle' and 'bottom'. It is not useful with 'left' and 'top', because they represent position (0, 0) and cannot be scaled. Let's say we want a label to be 90% towards the right of the layout and 90% towards the bottom:

- Layout:
    mode: float
    border: true
    - Label:
        text: Hello world
        pos_hint: right: 0.9, bottom: 0.9
        auto_scale: true, true
        border: true

33_ez_lang_relpos

Finally, let's use all position hints in one example. We'll recreate this setup:

1   2 
  3
4   5
- <MyLabelTemplate@Label>:
    text: hello
    border: True
    auto_scale: true, true

- Layout:
    mode: float
    - MyLabelTemplate:
        id: my_upper_left_label
        pos_hint: left, top
    - MyLabelTemplate:
        id: my_middle_label
        pos_hint: center, middle
    - MyLabelTemplate:
        id: my_lower_left_label
        pos_hint: left, bottom
    - MyLabelTemplate:
        id: my_upper_right_label
        pos_hint: right, top
    - MyLabelTemplate:
        id: my_lower_right_label
        pos_hint: right, bottom

float_layout_pos_hints

Continue

The general tutorial continues with: EzLang Position Maths.

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