YAD - Tips

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

#261 Post by vovchik »

Dear Misko,

Very nice, and nicely coded. I just added a bit of eye candy. :)

With kind regards,
vovchik
Attachments
yt-get.tar.gz
(5.5 KiB) Downloaded 158 times

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

#262 Post by vovchik »

Dear all,

Here is a little YAD-based task killer. I found most of the code somewhere and modded it a bit. It's not too bad, but it is not the fastest thing in the world. It seems to work. :)

With kind regards,
vovchik
Attachments
ypid.tar.gz
(1.37 KiB) Downloaded 153 times

User avatar
misko_2083
Posts: 114
Joined: Tue 08 Nov 2016, 13:42

#263 Post by misko_2083 »

vovchik wrote:Dear Misko,

Very nice, and nicely coded. I just added a bit of eye candy. :)

With kind regards,
vovchik
Vovchik, it looks great. :D
Just found this for the .bashrc
similar to this http://worldwidemann.com/a-gui-file-pic ... s-of-code/

Code: Select all

# Yad gui file selector
# put in .bashrc and call with ctrl+g from terminal
select_files() { 
local file files i IFS=' '
local -n l=READLINE_LINE p=READLINE_POINT
while IFS= read -rd '' file; do printf -v 'files[i++]' %q "$file"
done < <(yad --file --multiple --width=600 --height=600 --center | tr '|\n' '\0\0')
files="${files[*]}" l=${l:0:p}$files${l:p} p=$((p+${#files})); 
}
bind -x '"\C-g":select_files'
Regards

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

#264 Post by vovchik »

Dear Misko,

Thanks. It's very compact and convenient, and available everywhere. :)

With kind regards,
vovchik

step
Posts: 1349
Joined: Fri 04 May 2012, 11:20

#265 Post by step »

My bash shell returns an error when parsing Misko's script - but I can't find a syntax error anywhere in it. Anyone with the same problem?

Code: Select all

sh: syntax error near unexpected token `<'
That's the "<" before "<("

Code: Select all

# bash --version
GNU bash, version 4.3.42(1)-release (x86_64-unknown-linux-gnu)
[url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Fatdog64-810[/url]|[url=http://goo.gl/hqZtiB]+Packages[/url]|[url=http://goo.gl/6dbEzT]Kodi[/url]|[url=http://goo.gl/JQC4Vz]gtkmenuplus[/url]

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#266 Post by MochiMoppel »

step wrote:My bash shell returns an error when parsing Misko's script - but I can't find a syntax error anywhere in it. Anyone with the same problem?

Code: Select all

sh: syntax error near unexpected token `<'
That's the "<" before "<("
Even without looking into the script the error message is obvious: "<(" would be a bash process substitution which is not available when you invoke bash in POSIX mode. i.e. with a #!/bin/sh shebang.
Use #!/bin/bash instead.

step
Posts: 1349
Joined: Fri 04 May 2012, 11:20

#267 Post by step »

MochiMoppel wrote:pocess substitution which is not available when you invoke bash in POSIX mode. i.e. with a #!/bin/sh shebang.
Use #!/bin/bash instead.
Thanks MochiMoppel. Actually, I was pasting the code directly into terminal, so there was no shebang involved. But I'm pretty sure you hit the nail on its head. There are other ways to enable POSIX mode, so I'll check my setup to ensure that POSIX is disabled.
[url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Fatdog64-810[/url]|[url=http://goo.gl/hqZtiB]+Packages[/url]|[url=http://goo.gl/6dbEzT]Kodi[/url]|[url=http://goo.gl/JQC4Vz]gtkmenuplus[/url]

april

#268 Post by april »

I have one I want to get going but don't know how .

I'm after a form that comes up with say 8 fields on one line and then the next line down is the same but a different background colour.

Multiple lines , say 1000 and scrolling . Ability to work through each field in order and enter takes it to the next line.

Now it is needed to look exactly like a bank statement and have the same data fields as date number details code debit credit balance and presented(T/F).

If anyone knows Quickbooks I want it to look just like one of their bank entry forms

Anyone ever done similar?

gyro
Posts: 1798
Joined: Tue 28 Oct 2008, 21:35
Location: Brisbane, Australia

#269 Post by gyro »

I've just discovered yad and I'm trying to use it for a little project I'm working on,
but I have a problem.

I'm using the following code to select a directory:

Code: Select all

INIT_DIR="$(pwd)"
RET_DIR=$(yad --center --borders=6 --title "dircrypt - Select encrypted directory" \
			--file --directory --width=600 --height=400 --filename="$INIT_DIR/")
It all seems to work fine except when I use the "Create Folder" button. After typing in the name of the new folder I hit the "Enter" key, and nothing happens. I expect it to cause the new folder name to be accepted.

I'm doing this on puppy_xenial_7.0.4 using

Code: Select all

yad --version
0.38.1 (GTK+ 2.24.30)
(I downloaded and compiled it.)

Has anyone had a similar problem?
Is it likely to be a bug in this particular version?

Note1: All my other yad dialogs seem to work as expected.

Note2: Before "discovering" yad, I wrote a gtk C program to do the same thing, calling the builtin gtk_file_chooser_dialog. It looks rather similar, except that the "Enter" key works after naming a new folder.

gyro

User avatar
Geoffrey
Posts: 2355
Joined: Sun 30 May 2010, 08:42
Location: Queensland

#270 Post by Geoffrey »

gyro, works ok for me with yad

Code: Select all

yad --version 
0.36.3 (GTK+ 2.24.23)
yeah the new folder is created by either a mouse click or enter key, the button's do nothing, they need to be give an action

Code: Select all

INIT_DIR="$(pwd)"
RET_DIR=$(yad --center --borders=6 --title "dircrypt - Select encrypted directory" \
        --button="gtk-ok:0" --button="gtk-cancel:1" --file --directory --width=600 --height=400 --filename="$INIT_DIR/")

[[ $? -eq 0 ]] && SOME_ACTION

[[ $? -eq 1 ]] && SOME_OTHER_ACTION
[b]Carolina:[/b] [url=http://smokey01.com/carolina/pages/recent-repo.html]Recent Repository Additions[/url]
[img]https://dl.dropboxusercontent.com/s/ahfade8q4def1lq/signbot.gif[/img]

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

#271 Post by seaside »

I have the same version-

Code: Select all

yad --version
0.38.1 (GTK+ 2.24.30)
After "create folder" is clicked and a name entered, a "tab" writes the new folder and returns the dialog to a "no selected directory" mode.

Or you could click on the dark section to the right of the entry.

The path of the new directory is returned in both cases.

Cheers,
s
(Not exactly my idea of intuitive :D )

gyro
Posts: 1798
Joined: Tue 28 Oct 2008, 21:35
Location: Brisbane, Australia

#272 Post by gyro »

@seaside,

Thanks.
I think "Enter" is more intuitive than "Tab", but that's life.
But, at least it's not just me.

@Geoffrey,
Thanks.
I'll try to give "0.36.3" a go to see if it is different for me.

gyro

gyro
Posts: 1798
Joined: Tue 28 Oct 2008, 21:35
Location: Brisbane, Australia

#273 Post by gyro »

@Geoffrey and seaside,
gyro wrote:It all seems to work fine except when I use the "Create Folder" button. After typing in the name of the new folder I hit the "Enter" key, and nothing happens.
Using

Code: Select all

yad --version
0.36.3 (GTK+ 2.24.30)
The "Enter" key does what I expect. It causes the new directory to be accepted and it gets opened.
So the remaining question is, do any of the versions between 0.36.3 and 0.38.1 function "correctly"?

gyro

User avatar
Geoffrey
Posts: 2355
Joined: Sun 30 May 2010, 08:42
Location: Queensland

#274 Post by Geoffrey »

gyro wrote:@Geoffrey and seaside,
gyro wrote:It all seems to work fine except when I use the "Create Folder" button. After typing in the name of the new folder I hit the "Enter" key, and nothing happens.
Using

Code: Select all

yad --version
0.36.3 (GTK+ 2.24.30)
The "Enter" key does what I expect. It causes the new directory to be accepted and it gets opened.
So the remaining question is, do any of the versions between 0.36.3 and 0.38.1 function "correctly"?

gyro
I'm most likely getting it wrong on what you want to do.

Code: Select all

INIT_DIR="$(pwd)"
RET_DIR=$(yad --center --borders=6 --title "dircrypt - Select encrypted directory" \
        --file --directory --width=600 --height=400 --filename="$INIT_DIR/") 
        
echo $RET_DIR
This works fine, create directory press enter or left mouse on new directory text to create and select directory,
OK button to confirm selected directory and continue to next script action, or Cancel button to abort.
[b]Carolina:[/b] [url=http://smokey01.com/carolina/pages/recent-repo.html]Recent Repository Additions[/url]
[img]https://dl.dropboxusercontent.com/s/ahfade8q4def1lq/signbot.gif[/img]

gyro
Posts: 1798
Joined: Tue 28 Oct 2008, 21:35
Location: Brisbane, Australia

#275 Post by gyro »

Geoffrey wrote:I'm most likely getting it wrong on what you want to do.
Unfortunately, sort of yes.
I'm happy with the script code, as the rest of my script makes use of $RET_DIR.
My problem was with yad version 0.38.1, where the "Enter" key failed to do what I expected when using the "Create Folder" button in the select directory dialog.

Problem solved:
The "Enter" key works as expected in both yad version 0.36.3 and the recent 0.38.2.

@seaside,
Upgrade to yad 0.38.2 and the problem is fixed.

So the YAD tip is: avoid version 0.38.1

gyro

User avatar
Geoffrey
Posts: 2355
Joined: Sun 30 May 2010, 08:42
Location: Queensland

#276 Post by Geoffrey »

gyro wrote:So the YAD tip is: avoid version 0.38.1
Yes, https://groups.google.com/forum/#!forum/yad-common
YAD 0.38.2 released

This is a bugfix release. One serious bug was fixed, update is highly recommended

Changes in this release:

- fix enter behavior
[b]Carolina:[/b] [url=http://smokey01.com/carolina/pages/recent-repo.html]Recent Repository Additions[/url]
[img]https://dl.dropboxusercontent.com/s/ahfade8q4def1lq/signbot.gif[/img]

gyro
Posts: 1798
Joined: Tue 28 Oct 2008, 21:35
Location: Brisbane, Australia

#277 Post by gyro »

Geoffrey wrote:Buttons in --form --field are the width of the window

Code: Select all

yad --form --field="test1:FBTN" "yad --text='test1'" \
--field="test2:FBTN" "yad --text='test2'" \
--field="test3:FBTN" "yad --text='test3'"
Thanks for this example, I find such a column of buttons quite useful as a kind of menu with each button executing a corresponding script.

gyro

step
Posts: 1349
Joined: Fri 04 May 2012, 11:20

#278 Post by step »

I see that some people are using YAD 0.38.2. I have upgraded too, from 0.36.3, but I think 0.38.2 bombs X11. Twice already I clicked a yad --entry dialog button and X11 crashed. The first time I found myself back at the console prompt, and had to restart X manually. The second time X restarted automatically. All this happened on Fatdog64-710.
My script involves closing the yad dialog with "kill -USR2 $YAD_PID", but I'm not positive this is connected to X11 crashing.

edited after vovchik's post below: X11 restarted again with yad 0.36.3, so this issue isn't version dependent. On to more investigation...
Last edited by step on Sun 05 Feb 2017, 12:37, edited 1 time in total.
[url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Fatdog64-810[/url]|[url=http://goo.gl/hqZtiB]+Packages[/url]|[url=http://goo.gl/6dbEzT]Kodi[/url]|[url=http://goo.gl/JQC4Vz]gtkmenuplus[/url]

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

#279 Post by vovchik »

Dear step,

I am using the same version (0.38.2) and have not experienced your problem in Tahr, so I don't really think it is a "version" problem. I compiled YAD myself for Inetl and for my Raspberry PI. This runs fine on my various machines:

Code: Select all

#!/bin/bash

function CLOSE_EXIT()
{
    echo "Close and exit..."
    kill -s SIGUSR1 $YAD_PID
} ; export -f CLOSE_EXIT

yad  --text "<b>Simple Dialog</b>" --button="OK:bash -c CLOSE_EXIT"
With kind regards,
vovchik

step
Posts: 1349
Joined: Fri 04 May 2012, 11:20

#280 Post by step »

Dear vovchik,

thank you. I'm using kill -USR1 in a similar fashion. I also don't think anymore that it's a "version" problem, because the X11 restart just happened again, this time with yad 0.36.3. I need to investigate further what's going on.
[url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Fatdog64-810[/url]|[url=http://goo.gl/hqZtiB]+Packages[/url]|[url=http://goo.gl/6dbEzT]Kodi[/url]|[url=http://goo.gl/JQC4Vz]gtkmenuplus[/url]

Post Reply