0

During Working with yad --form displayed some |||(vertical bars) after clicked a button, what are this bars indicating & how I can STOP them to display? Providing sample code, You can experience

yad --width=400 --height=200 --button="gtk-ok" --form --field="Click Down":LBL "echo Clicked" --field="Click HERE":BTN

Result output will be " Clicked then ||

Jeff Schaller
  • 66,199
  • 35
  • 114
  • 250
AlphaCoder
  • 163
  • 1
  • 3
  • 8

1 Answers1

0

I cannot reproduce the situation you describe entirely, but I think you need to ask yourself what you want yad to do when a button is pressed, or, more specifically, how yad should communicate any user choice back to you, i.e. via an exit code or via information on standard output.

The option --button="gtk-ok" creates a button that is not tied to an exit code with which yad can exit and silently let you know that this particular button was pressed. Consequently, it seems, it will try to inform you via output on stdout (printing two default output separator characters). To prevent this, you could rephrase the option, e.g. like so:

--button="gtk-ok":1

which ties an exit code of 1 to pressing the OK button, and prevents further output. At the command prompt (or in a script), you can test this exit code, which is available as $?.

Importantly: note that the yad manpage indicates that the proper syntax for the `--button'-option is:

--button=BUTTON:ID
Add the dialog button. May be used multiply times. ID is an exit code or a command. (...)

So the option `--button="gtk-ok" seems to be syntactically incorrect.


To get the behaviour your describe, I had to change --field="Click Down":LBL "echo Clicked" into --field="Click Down":BTN "echo Clicked".


All in all, the following command works as expected on my system:

yad --width=400 --height=200 --button="gtk-ok":1 --form --field="Click Down":BTN "echo Clicked" --field="Click HERE":BTN
ozzy
  • 825
  • 5
  • 5
  • ozzy, as you said by set gtk-ok":1 ,I skipped ||||||(vertical bars), but when I set gtk-ok:2 again I got vertical bars, In my bash script yad comes 3 times continuously and interesting point is whenever **gtk-ok:EVEN NUMBER** then I got vertical bars. Is there any special relation with even number ? – AlphaCoder Jan 06 '19 at 05:16
  • I Just skipped All vertical bars by setting ODD NUMBERS, So Why EVEN? – AlphaCoder Jan 06 '19 at 05:26
  • @AlpaCoder In the yad manpage, under EXIT CODES, it says “Even exit code mean to print result, odd just return result”. So this behaviour is apparently by design. – ozzy Jan 06 '19 at 08:05