v1cont / yad

Yet Another Dialog
GNU General Public License v3.0
687 stars 57 forks source link

Form: aligning button icons and text vertically #70

Open manuel-192 opened 4 years ago

manuel-192 commented 4 years ago

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.

Misko-2083 commented 4 years ago

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"
manuel-192 commented 4 years ago

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.

Misko-2083 commented 4 years ago

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:

\ 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: