Author Topic: Creating custom gui dialogs for shell / bash scripts  (Read 20843 times)

Offline travisN000

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1758
Re: Creating custom gui dialogs for shell / bash scripts
« Reply #30 on: August 31, 2010, 08:31:55 AM »
...here is a sample of file select dialogs:
http://xpt.sourceforge.net/techdocs/language/gtkdialog/gtkde02-GtkdialogExamples/ar01s48.html


My guess is that you would have to test the users selection with a script and re-display the dialog if it does not match your criteria;  I think I have a sample of this in a GUI I wrote awhile back for the old mklivecd script...  I'll see if I can find it when I get home this evening.
« Last Edit: August 31, 2010, 08:38:04 AM by travisn000 »

Offline Was_Just19

  • Hero Member
  • *****
  • Posts: 6852
  • MLU
Re: Creating custom gui dialogs for shell / bash scripts
« Reply #31 on: September 01, 2010, 02:30:51 PM »
Thanks  .....  there were a couple of those Links which were new to me.

I saw a reference to the size in one of the links so I think I will get that OK.

Quote
My guess is that you would have to test the users selection with a script and re-display the dialog if it does not match your criteria;  I think I have a sample of this in a GUI I wrote awhile back for the old mklivecd script...  I'll see if I can find it when I get home this evening.

Oh!  I am surprised .......  GtkDialog seems so much more powerful than Zenity (for instance) that I automatically thought it would have a file filter or somesuch built in.

Thanks for the help.

Will continue to search around ....  anythng you have to add later is appreciated.   ;)

regards

musonio

  • Guest
Re: Creating custom gui dialogs for shell / bash scripts
« Reply #32 on: September 01, 2010, 08:10:25 PM »
GtkDialog seems so much more powerful than Zenity (for instance) that I automatically thought it would have a file filter or somesuch built in.

If I recall correctly, it does not give you the option to filter by filetypes. You can only choose the initial folder in which the filechooser will be opened.
However, you can launch a zenity dialog (or kdialog) from within gtkdialog, and with the oxigen gtk theme, nobody will notice.  ;D

Offline Was_Just19

  • Hero Member
  • *****
  • Posts: 6852
  • MLU
Re: Creating custom gui dialogs for shell / bash scripts
« Reply #33 on: September 02, 2010, 01:02:48 AM »
GtkDialog seems so much more powerful than Zenity (for instance) that I automatically thought it would have a file filter or somesuch built in.

If I recall correctly, it does not give you the option to filter by filetypes. You can only choose the initial folder in which the filechooser will be opened.
However, you can launch a zenity dialog (or kdialog) from within gtkdialog, and with the oxigen gtk theme, nobody will notice.  ;D

Thank you .......  had not thought of that being avialable .......  so a Zenity prompt with filter might be launched from within GtkDialog to browse to a particular file type .........  nice idea ......  must have a play with that soon ....

regards.

musonio

  • Guest
Re: Creating custom gui dialogs for shell / bash scripts
« Reply #34 on: September 02, 2010, 07:05:56 AM »
Last year I had written a ver simple script with gktdialog to gather all the usual things one does (sources.lst, fstab, dmesg, etc.). I lost my whole hard drive due to an electrician's mistake, but I had written something about it in the magazine. I'll  see if I can find it.

Offline Was_Just19

  • Hero Member
  • *****
  • Posts: 6852
  • MLU
Re: Creating custom gui dialogs for shell / bash scripts
« Reply #35 on: September 02, 2010, 08:43:59 AM »
Last year I had written a ver simple script with gktdialog to gather all the usual things one does (sources.lst, fstab, dmesg, etc.). I lost my whole hard drive due to an electrician's mistake, but I had written something about it in the magazine. I'll  see if I can find it.

Thank you

musonio

  • Guest

Offline Was_Just19

  • Hero Member
  • *****
  • Posts: 6852
  • MLU
Re: Creating custom gui dialogs for shell / bash scripts
« Reply #37 on: September 02, 2010, 11:20:18 AM »
found it:
http://pclosmag.com/html/Issues/200910/page21.html


Thanks ......  looks like I might have to learn French too to read what seems to be a very interesting PDF   :D

musonio

  • Guest
Re: Creating custom gui dialogs for shell / bash scripts
« Reply #38 on: September 02, 2010, 01:42:55 PM »
You won't need to learn French. It's quite transparent and provides some hints that I haven't found elsewhere.

Offline travisN000

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1758
Re: Creating custom gui dialogs for shell / bash scripts
« Reply #39 on: September 02, 2010, 02:36:20 PM »
found it:
http://pclosmag.com/html/Issues/200910/page21.html


..that is a great article; I added to my list of references on the first post!


@John-

I did find the script last night that I was going to post for you, but it has a few issues related to syntax changes in recent bash versions.. I should have time to finish updating it tonight and I will post the link when it is fixed.  It has a section of code that looks for duplicate or non-existing directory selections in a list of user selected directories, uses zenity to display a warning, then re displays the initial dialog to allow the user to make changes to the list of selected directories. 

I also looked a little more into your need to filter the file list, and according to one site, zenity can do this with the following syntax:

Code: [Select]
zenity --file-selection --file-filter "*.txt"
(..I haven't tested, as I'm at work on a windoze box  :-\ )

Offline Was_Just19

  • Hero Member
  • *****
  • Posts: 6852
  • MLU
Re: Creating custom gui dialogs for shell / bash scripts
« Reply #40 on: September 02, 2010, 03:11:48 PM »
Quote
I also looked a little more into your need to filter the file list, and according to one site, zenity can do this with the following syntax:

Code:
zenity --file-selection --file-filter "*.txt"

(..I haven't tested, as I'm at work on a windoze box   )

Yes I have used the Zenity file filter previously and it works well.
I was not previously aware that I could easily call the Zenity files selector from within GtkDialog until   musonio   mentioned it in an earlier post.
So that seems to solve that 'problem'.

The biggest difficulty I seem to be having is getting the info about GtkDialog into some semblence of order so that I can learn about it in a logical manner.  :(

Quote
I did find the script last night that I was going to post for you, but it has a few issues related to syntax changes in recent bash versions.. I should have time to finish updating it tonight and I will post the link when it is fixed.

Thank you. I guess the more examples I can access the more likely I will see most of what is available.

There seems to be nothing to get a new user 'into the groove' - explaining how things are and should be done with GtkDialog.
For instance I still have not come across a definitive list of 'tags' (<label></label>) anywhere with explanations of their uses and options.

The best I seem to be able to do is to look to examples and try to remember what is used and where.

Maybe it is just my head is not in the right place this week and things will be a little better next week  :)

I think I will take a couple of days break from the subject and try a fresh approach next week ......  at present I am only frustrating myself.

***

I have received great tips and examples here and on the pages linked to; but where is the manual that gets you started and then helps you advance with the subject?  I seem to have missed it .....  or am not recognising it.


Of the questions I started out with, two have been answered and two remain unanswered.
The Window width and the file selection questions I think are probably OK now.
Why my script threq a hissey when I tried to select a 0Byte file is unknown to me, and I am still searching for a list of <tags>.


Thanks for all the help guys.

Much appreciated.

regards.
« Last Edit: September 02, 2010, 03:15:43 PM by JohnBoy »

Offline Was_Just19

  • Hero Member
  • *****
  • Posts: 6852
  • MLU
Re: Creating custom gui dialogs for shell / bash scripts
« Reply #41 on: September 02, 2010, 03:20:19 PM »
found it:
http://pclosmag.com/html/Issues/200910/page21.html


I copy and pasted the script from the mag but get a seg fault when I run it .....  which mentions the last line which calls the GtkDiaog script.
I have no idea how to go about getting any further info ....   :(

musonio

  • Guest
Re: Creating custom gui dialogs for shell / bash scripts
« Reply #42 on: September 02, 2010, 06:22:22 PM »
JohnBoy:
It's an old script that worked in kde3. I don't even remember which command line apps it used, but some of them probably do not exist anymore.

On a side note: one of the most tedious problems of gtkdialog is that you don't get too much information when something goes wrong.

EDIT: I took a quick look at it and you would have to modify the paths to the icons. I don't think it will run as is.
« Last Edit: September 02, 2010, 06:24:15 PM by musonio »

Offline Was_Just19

  • Hero Member
  • *****
  • Posts: 6852
  • MLU
Re: Creating custom gui dialogs for shell / bash scripts
« Reply #43 on: September 03, 2010, 02:20:21 AM »
JohnBoy:
It's an old script that worked in kde3. I don't even remember which command line apps it used, but some of them probably do not exist anymore.

On a side note: one of the most tedious problems of gtkdialog is that you don't get too much information when something goes wrong.

EDIT: I took a quick look at it and you would have to modify the paths to the icons. I don't think it will run as is.

Thanks musonio .......  I will look at the icons to see if that allows it to run.

Is there no means to get such a script to print a more comprehensive outout that would help in debugging?

Thanks again for the help   ;)

Offline travisN000

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1758
Re: Creating custom gui dialogs for shell / bash scripts
« Reply #44 on: September 07, 2010, 10:09:51 PM »
Here is a sample gtkdialog script that I've been working on for CO that uses zenity with a file filter for the file selection dialog:

http://dl.dropbox.com/u/2425248/gtkdialog-test.sh.tar.gz

..the tar includes an image that needs to stay in the same directory as the script.  

The trick to making it work is to have the file entry box read a text file for it's value. The file browse button then has multiple "actions" defined.. The first action uses zenity to browse for the file and then writes the zenity output to the previously mentioned text file; the second "action" tells the file entry box to refresh its value which results in it reading the path/file that the user just selected via zenity and re-populates the entry box with their selection.

In the case of the example above, their are two different browse buttons with a checkbox that determines which file type the user is allowed to browse for.
 8)
« Last Edit: September 08, 2010, 06:10:16 AM by travisn000 »