Page 1 of 1

Gtkdialog examples from DEVX

Posted: Mon 15 Feb 2010, 21:49
by 8-bit
The example /usr/doc/gtkdialog/examples/07.02-list_actions script maxes out my processor when I run it and I have to kill it.
I tried making another button and putting the echo line there.
The program would then be ok until I clicked that button and again max out the processor.
So, any ideas as to why?

Posted: Thu 18 Feb 2010, 16:37
by seaside
8-bit,

I don't have an answer to this question and I just wanted you to know that it happens when I try it also.

(I haven't used "list" and perhaps it's just as well) :D

s

Posted: Thu 18 Feb 2010, 18:35
by 8-bit
Thank you for the reply.
I also tried modifying the script by putting the echo line in an action call using the ok button to call it.
Then I tried adding xmessage without the echo.
There was no change as to processor maxing out and xmessage failed to display any output.
So I will keep playing round with it.
For now, I know not to use that form of list in any programs.

Posted: Thu 18 Feb 2010, 19:20
by technosaurus
could you paste the example - I am not at a Puppy box to check it, but I can examine the script - it probably just needs a sleep 1 inserted somewhere in a loop. This one may have already been discussed in the gtkdialog tips thread.

Posted: Thu 18 Feb 2010, 22:09
by 8-bit
You ask for the original example file and here it is 07.02-list_actions

Code: Select all

#! /bin/bash

export MAIN_DIALOG='
  <vbox>
    <list>
      <variable>LIST</variable>
      <item>First item</item>
      <item>Second item</item>
      <item>Third item</item>
      <action>echo Chosen item is $LIST</action>
    </list>
    <hbox>
     <button ok></button>
     <button cancel></button>
    </hbox>
  </vbox>
'

gtkdialog3 --program=MAIN_DIALOG
I already tried moving the action line to be acted on by the OK button.

Posted: Thu 18 Feb 2010, 22:55
by technosaurus
hmm - I would use a "combobox" for that instead of a list - I have a template for combobox in the how to section

http://www.murga-linux.com/puppy/viewtopic.php?t=45474

Code: Select all

<combobox>
    <variable>COMBO1</variable>
    <item>item 1</item>
    <item>item 2</item>
</combobox>
then you will either need to eval MAIN_DIALOG after exit for the value of $COMBO1 or set up and action within the dialog window such as
Xdialog --infobox $COMBO1 0 0

Posted: Fri 19 Feb 2010, 04:56
by 8-bit
I realize their are work arounds for the example program.
But.....
Why are there example programs in the /usr/share/doc/gtkdialog3/examples directory that just do not work.
Isn't an example supposed to work?

Also, can one find out where the example program is at fault and correct it?
Is it a matter of a debug option?
Everything seems fine till the <action>echo Chosen item is $LIST</action>
line is executed.
As to what is happening, that is to find out.
And the echo never takes place even when run from a terminal.

Posted: Wed 24 Feb 2010, 10:01
by aragon
8-bit wrote:I realize their are work arounds for the example program.
But.....
Why are there example programs in the /usr/share/doc/gtkdialog3/examples directory that just do not work.
Isn't an example supposed to work?
yes that also drived me crazy for many times :twisted: maybe memoving would be better...
Also, can one find out where the example program is at fault and correct it?
not really, but with the following, it does work and echos the choosen value...

Code: Select all

#! /bin/bash

export MAIN_DIALOG='
  <vbox>
    <list>
      <variable>LIST</variable>
      <item>First item</item>
      <item>Second item</item>
      <item>Third item</item>
    </list>
  <hbox>
   <button ok></button>
   <button cancel></button>
  </hbox>
  </vbox>
'

I=$IFS; IFS=""
for STATEMENTS in  $(gtkdialog3 --program MAIN_DIALOG); do
  eval $STATEMENTS
done
IFS=$I

if [ "$EXIT" = "OK" ]; then
  echo "Chosen item is $LIST."
else
  echo "You pressed the Cancel button."
fi
aragon

Posted: Wed 24 Feb 2010, 10:43
by 8-bit
aragon,

It appears to work because it exits to show $LIST.
But I have an option for you.
When creating a GUI, why have it use the echo command?
That entails running it from a terminal to see the output of the echo command.
Instead, just replace "echo" with "xmessage".
Then the output will be displayed in a GUI type message box.

Posted: Wed 24 Feb 2010, 11:37
by aragon
8-bit wrote:aragon,

It appears to work because it exits to show $LIST.
But I have an option for you.
When creating a GUI, why have it use the echo command?
That entails running it from a terminal to see the output of the echo command.
Instead, just replace "echo" with "xmessage".
Then the output will be displayed in a GUI type message box.
sure, but i wanted to leave it as it has been in the example...

but usually this is to give parameter to an external comand.

aragon