yad icon indicating copy to clipboard operation
yad copied to clipboard

yad: Text always appears on the right hand side, cannot get text to appear above/below my image , examples below

Open jBNeo opened this issue 1 year ago • 8 comments

Beginner here. I have been trying to post notifications to myself using a combination of text and images I also want this to work in my user's crontab. I tried many different variations of yad options and I cannot get my text to appear either above or below my image. The text ALWAYS appears to the right hand side of the image no matter which variation/options I try (see below). This leads me to suspect that something more fundamental is wrong with my sytem. This error occurs BOTH when I enter the command directly in the terminal and through crontab. The same problem, namely the text appears on the right hand side of the image and NOT above or below.

Can anyone suggest a solution ? Please see below for various options I tried:

Example 1: Using cat EOF

#!/bin/bash
export DISPLAY=:0

yad --image-on-top --on-top --title "My Dream World!" \
    --timeout=30 --no-buttons --sticky --center \
    --image=/usr/local/bin/text2.dream.world.image.Thirteenth.Floor.png \
    --text "$(cat <<EOF
Welcome to my dream world!
Enjoy your stay!
Feel free to explore.
EOF
)"

Example 2:Using text align center

#!/bin/bash
TEXT="Welcome to my dream world!\nEnjoy your stay!\nFeel free to explore."
yad --image-on-top --on-top --title "My Dream World!" \
    --timeout=30 --no-buttons --sticky --center \
    --image=/usr/local/bin/text2.dream.world.image.Thirteenth.Floor.png \
    --text "$TEXT" \
    --text-align=center

Example 3: Using form

#!/bin/bash
TEXT="Welcome to my dream world!\nEnjoy your stay!\nFeel free to explore."

yad --title "My Dream World!" --on-top --timeout=30 --no-buttons --sticky --center \
    --form \
    --item-separator="" \
    --text="$TEXT" \
    --image=/usr/local/bin/text2.dream.world.image.Thirteenth.Floor.png

Example 5: using Grid

#!/bin/bash
export DISPLAY=:0
TEXT="Welcome to my dream world!"

yad --title "My Dream World!" --on-top --timeout=30 --no-buttons --sticky --center \
    --grid \
    --image=/usr/local/bin/text2.dream.world.image.Thirteenth.Floor.png 1 1 \
    --text "$TEXT" 2 1

Example 6: using width height, export DISPLAY variable

#!/bin/bash

# Ensure the correct display
export DISPLAY=:0.0

TEXT="Welcome to my dream world!\nEnjoy your stay!\nFeel free to explore."

yad --title "My Dream World!" --on-top --timeout=30 --no-buttons --sticky --center \
    --image=/usr/local/bin/text2.dream.world.image.Thirteenth.Floor.png \
    --text "$TEXT" \
    --text-align=center \
    --height=200 --width=400

Example 7: using GTK

#!/bin/bash

export DISPLAY=:0
TEXT="Welcome to my dream world!\nEnjoy your stay!\nFeel free to explore."

yad --title "My Dream World!" --on-top --timeout=30 --no-buttons --sticky --center \
    --image=/usr/local/bin/text2.dream.world.image.Thirteenth.Floor.png \
    --text "$TEXT" \
    --button="gtk-ok:0" \
    --width=300 --height=200

=================================== For a temporary solution I simply added my text to the image itself and didn't use a text option tag. See below: This works but not best...

#!/bin/bash
export DISPLAY=:0

yad --image-on-top --on-top --title "My Dream World!" \
--timeout=120 --no-buttons \
--sticky --center \
--image=/usr/local/bin/text3.dream.world.image.Thirteenth.Floor.png \

Thanks in advance !

=================================== System: Kernel: 6.1.0-25-amd64 [6.1.106-3] arch: x86_64 bits: 64 compiler: gcc v: 12.2.0 parameters: BOOT_IMAGE=/boot/vmlinuz-6.1.0-25-amd64 root=UUID= ro quiet init=/lib/systemd/systemd Desktop: Xfce v: 4.18.1 tk: Gtk v: 3.24.36 info: xfce4-panel wm: xfwm v: 4.18.0 vt: 7 dm: LightDM v: 1.26.0 Distro: MX-23.4_x64 Libretto May 19 2024 base: Debian GNU/Linux 12 (bookworm)

$ yad --version
0.40.0 (GTK+ 3.24.38)

P.S. I note that the Gtk i use is 3.24.36 but above it reports it as 3.24.38. Does this matter ?

jBNeo avatar Nov 01 '24 22:11 jBNeo

The man page says about --image:

 --image=IMAGE
          Set the dialog image which appears on the left side of dialog's text.

That pretty much rules out being able to position --image relative to --text.

But --text, which isn't a main widget, is always at the bottom of a main widget, such as --form, --list, --text-info and so on. Therefore, --image is also at the bottom of a main widget. You can leave --text empty, or even leave --text out. Instead Use your favorite choice of a main widget capable of displaying text, and pair it with --image. This combination will display an image above some text.

Example, using --text-info as a main widget capable of displaying text:

echo 'TEXT' | yad --text-info --image=/usr/share/icons/hicolor/128x128/apps/yad.png 

See also #186.

Note that option --image-on-top has been invalid since version 1.0 - I think.

Another, more complicated way to position an image above/below or to the left/right of a main widget is to use a NOTEBOOK or PANED plug dialog, which can combine multiple yad dialogs into a single window. The wiki https://github.com/yad/wiki includes examples of plugged dialogs.

step- avatar Nov 01 '24 23:11 step-

oops https://github.com/v1cont/yad/wiki

step- avatar Nov 01 '24 23:11 step-

man yad
       --image=IMAGE
              Set the dialog image which appears on the left side of dialog.   IMAGE  might
              be file name or icon name from current icon theme.

       --image-on-top
              Show  image  above  main widget instead of left. This option is always on for
              print dialog.

(1) The 1st one says left side of dialog. I take it this is the same as left side of dialog's text ? (2) Is there any way to get --image-on-top to work with text ?

jBNeo avatar Nov 02 '24 22:11 jBNeo

$ yad --image-on-top
 Unable to parse command line: Unknown option --image-on-top

$ yadu --version
14.0 (GTK+ 3.24.42)

You probably can't see the error message because your yad configuration disables showing that error message.

To your questions:

  1. Yes.
  2. With "text" yes, by placing "text" in a main widget. With "--text" no, because "--text" isn't a main widget.

step- avatar Nov 02 '24 22:11 step-

Ignore unknown command-line options: https://github.com/v1cont/yad/blob/b0774c42ed289f868b09da8cde67ae53236c25b7/data/yad.gschema.xml.in#L61

Yad manual source -- there is no "--image-on-top", as you can see: https://github.com/v1cont/yad/blob/v14.1/data/yad.1

step- avatar Nov 02 '24 22:11 step-

My apologies for this dumb question. What is this ?

$ yadu --version
14.0 (GTK+ 3.24.42)

I have this:

$ yad --version
0.40.0 (GTK+ 3.24.38)

jBNeo avatar Nov 02 '24 23:11 jBNeo

Sorry, "yadu" is a typo. It should have been "yad". You have yad version 0.40.0. That is very old and no longer supported in this GitHub repository. I suggest you should update your installed yad package to a newer version. The latest version in this repository is 14.1, as you can see in the Releases page. However, to update from this repository you will need to compile the source code yourself. If you can't compile then look for an updated yad package from the package manager of your Linux distribution.

If, for some reasons, you really need to stay on the 0.40.x branch, that version is still supported but elsewhere: https://github.com/step-/yad. However, even there you will need to compile the source code yourself. DISCLAIMER: I maintain that repository.

step- avatar Nov 03 '24 12:11 step-

printf "%s\n%s\n" "$text" "$path-to-image" | yad --list --column=:txt --column=:img &

On Sun, 3 Nov 2024, 20:16 step, @.***> wrote:

Sorry, "yadu" is a typo. It should have been "yad". You have yad version 0.40.0. That is very old and no longer supported in this GitHub repository. I suggest you should update your installed yad package to a newer version. The latest version in this repository is 14.1, as you can see in the Releases page. However, to update from this repository you will need to compile the source code yourself. If you can't compile then look for an updated yad package from the package manager of your Linux distribution.

If, for some reasons, you really need to stay on the 0.40.x branch, that version is still supported but elsewhere: https://github.com/step-/yad. However, even there you will need to compile the source code yourself. DISCLAIMER: I maintain that repository.

— Reply to this email directly, view it on GitHub https://github.com/v1cont/yad/issues/284#issuecomment-2453406976, or unsubscribe https://github.com/notifications/unsubscribe-auth/APRODETGEXY6TSTSHP4SEFDZ6YHZXAVCNFSM6AAAAABRBBFFPSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINJTGQYDMOJXGY . You are receiving this because you are subscribed to this thread.Message ID: @.***>

cou645 avatar Nov 13 '24 07:11 cou645