Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


  • 0

Align 4 lebel's text


Neo Andersson

Question

Hello guys

 

I can not figure out, why can't I align the text inside 4 labels..

Altough they have different 5 strings inside but i am using a function to make them the same lenght so that content of all labels should get aligned the same way

However, it doesn't work as you can see

 

Please login or register to see this image.

/monthly_2024_04/image.png.7426c3286310fdad9d1972b0080e47c0.png" />

 

i am using this function to make every single word the same lenght so they take up the same space

 

Please login or register to see this code.

 

Anyone any assist please? 

Link to comment
Share on other sites

17 answers to this question

Recommended Posts

  • 0
  • Inquirer
  • 9 minutes ago, SmartHomeEddy said:

    Is it an option to use only one label? 

    Yeah i have tried with one label, but its even harder without html. I need to split it into 4 rows, and every row has 5 values, so they need to look llike a table. Columns aligned etc..

    I can do it using html table, but i want to avoid it. I am looking for a solution wihtout using html, creating a kinda fake table using only \n, or &nbsp 

    Link to comment
    Share on other sites

    • 0

    The standard font is not fixed width. You need to wrap it in a <font ..>...</font> with a fixed with font.

    Alternatively, wrap it it <tt>...</tt> that always use a fixed font.

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Posted (edited)
    1 minute ago, jgab said:

    The standard font is not fixed width. You need to wrap it in a <font ..>...</font> with a fixed with font.

    Alternatively, wrap it it <tt>...</tt> that always use a fixed font.

    Yeah this is with html, and i am trying to get the result without it byt i think it is impossible

    Edited by Neo Andersson
    Link to comment
    Share on other sites

    • 0
    1 minute ago, Neo Andersson said:

    Yeah this is with html, and i am trying to get the result without it byt i think it is impossible

    Yes, because the standard font is not fixed width

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Posted (edited)
    5 minutes ago, SmartHomeEddy said:

    And are buttons an option? Or are those a bit too much like a table? 

    I am trying to replace HTML in this QA, so only buttons would kill the thing

     

    Please login or register to see this image.

    /monthly_2024_04/image.png.ed4c5201fce9f49397de000c782dd616.png" />

     

    kinda tricky, and looks that is impossible.. HTML sucks in new native APP..plugin many times closing randomly, or cant event open if ther eis too much to render

    Edited by Neo Andersson
    Link to comment
    Share on other sites

    • 0

    I have the same problem with "formatting" a text in QA interface to look like a table in HC3. The <tt> tag works, but it's not enough - the content is centred and it ruins my beautifully formatted table. Is it possible to do something to align label text to the left?

     

     

    Please login or register to see this attachment.

    Please login or register to see this attachment.

    Edited by Łukasz997
    Link to comment
    Share on other sites

    • 0

    If you can use html wrap it in a section/tt

    Ex.

    Please login or register to see this code.

     

    • Like 1
    Link to comment
    Share on other sites

    • 0
    26 minut temu, jgab napisał:

    If you can use html wrap it in a section/tt

    Ex.

    Please login or register to see this code.

     

    The wrap was added to variable holding the text (and </br> at the end of the line). Unfortunately, it seems not working. It leads to the different results, depending from where the interface is called - hitting the "eye" icon, edit&preview or mobile app. At the console it looks OK.

    Please login or register to see this attachment.

    Please login or register to see this attachment.

    Link to comment
    Share on other sites

    • 0
    23 godziny temu, Neo Andersson napisał:

     

    Please login or register to see this code.

     

    Anyone any assist please? 

     

     

    I would like to turn you attention on this: #text not always return length of the text like chars count. It rather return bytes count. Some characters can be 2-bytes (as national characters).
    This works better:

    local function StringAlign(strn, len) local l=0 for _ in string.gmatch(strn, utf8.charpattern) do l=l+1 end return strn..string.rep("&nbsp", len-l) end

    Edited by Łukasz997
    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 36 minutes ago, Łukasz997 said:

    I would like to turn you attention on this: #text not always return length of the text like chars count. It rather return bytes count. Some characters can be 2-bytes (as national characters).
    This works better:

    local function StringAlign(strn, len) local l=0 for _ in string.gmatch(strn, utf8.charpattern) do l=l+1 end return strn..string.rep("&nbsp", len-l) end

    Thanks i realized that #is not the proper way..I will stick to HTML approach

    Link to comment
    Share on other sites

    • 0

    I've tried some html on QA interface. On example:

     

    local str1 = "<section style=\"text-align: left;\"> <code>this is my monospaced, leftcentered text<br>and this too...</code> </section>"
    self:updateView("label_ID_0", "text", str1)

     

    produces mono-spaced, centred, smaller than normal, PINK (!) text.

     

    and:

    <section style="text-align: left;"> <code style="color: yellow; display: block;">this is my monospaced, leftcentered text<br>and this too...</code> </section>

    produces exactly the same PINK text.
    <tt> and <code> works, rest is a surprise. To be quiet a truthful, I'm not familiar with HTML, maybe it's normal. Is there any description what can be done in HTML in QA interface?

    Edited by Łukasz997
    Link to comment
    Share on other sites

    • 0
    12 godzin temu, Łukasz997 napisał:

    Is there any description what can be done in HTML in QA interface?

    Neo, maybe I ask another way: if you build your table using html, can you share it here?

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 6 hours ago, Łukasz997 said:

    Neo, maybe I ask another way: if you build your table using html, can you share it here?

    It is nothing speacial..just using  text = <b> <font color = red> somtexthere  </font></b> will print a bold text in red , and building a table is as simple as other html <table> <row> <td>    </td></row></table>

    Please login or register to see this link.

    • Thanks 1
    Link to comment
    Share on other sites

    • 0
    1 godzinę temu, Neo Andersson napisał:

    It is nothing speacial..just using  text = <b> <font color = red> somtexthere  </font></b> will print a bold text in red , and building a table is as simple as other html <table> <row> <td>    </td></row></table>

    Please login or register to see this link.

    I've tried - table works in this small 50-chars wide area we have at our disposal, thank you very much. But I can't align cells left, content remain centered what I don't want...

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 5 minutes ago, Łukasz997 said:

    I've tried - table works in this small 50-chars wide area we have at our disposal, thank you very much. But I can't align cells left, content remain centered what I don't want...

    <table width= 400px border = 1px>
    <td align =left>
     
    • Thanks 1
    Link to comment
    Share on other sites

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Answer this question...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    ×
    ×
    • Create New...