yad icon indicating copy to clipboard operation
yad copied to clipboard

Form: aligning button icons and text vertically

Open manuel-192 opened this issue 5 years ago • 3 comments

Hi! Again about yad 5.0. This is not really an issue but more of a feature request!

Example: yad --form --field=' Emacs!emacs!':fbtn emacs --field=' Mousepad!mousepad!':fbtn mousepad --field=' Leafpad!leafpad!':fbtn leafpad Here the icons and text on the buttons are not vertically aligned, but e.g. left-aligning both icons and text would make them look better.

manuel-192 avatar Feb 07 '20 17:02 manuel-192

If you make all the strings the same length and force Monospace font they will align to the left.

#!/bin/bash

for word in Emacs Mousepad Leafpad
do
    len=${#word}
    if (( len > longest ))
    then
        longest=$len
        longword=$word
    fi
done

yad --form --field="$(printf "<tt> %-${longest}s</tt>%s" "Emacs" "!emacs!")":fbtn "emacs" \
--field="$(printf "<tt> %-${longest}s</tt>%s" "Mousepad" "!mousepad!")":fbtn "mousepad" \
--field="$(printf "<tt> %-${longest}s</tt>%s" "Leafpad" "!leafpad!")":fbtn "leafpad"

Misko-2083 avatar Feb 08 '20 20:02 Misko-2083

If you make all the strings the same length and force Monospace font they will align to the left.

Thanks! That's a nice and working idea (although the <tt> tag is deprecated and not available in HTML5). But for my rather complex forms (in a notebook) this would require quite much additional work.

I'm hoping for a solution that would involve support from yad, for example a form option --button-text-align=left or something similar for fields of fbtn.

manuel-192 avatar Feb 11 '20 14:02 manuel-192

Thanks! That's a nice and working idea (although the <tt> tag is deprecated and not available in HTML5).

If you are using HTML dialogs (yad --html) I can imagine the code. alarm script Javascript, HTML, CSS ans bash. :grinning:

<tt> tags are in the Pango Markup Language used in yad and gtk+ apps.

But for my rather complex forms (in a notebook) this would require quite much additional work.

I understand that. It would be easier and the form buttons would look better with the system font. :+1:

Misko-2083 avatar Feb 11 '20 22:02 Misko-2083