GtkDialog - tips

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#691 Post by zigbert »

disciple wrote:A pity it can't refresh more often than once a second...
It can

Code: Select all

<timer milliseconds="true" interval="200" visible="false">

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#692 Post by zigbert »

Mick
I have cut down the code to give a simple-as-possible example.
Main post updated

Code: Select all

#!/bin/sh
export MSG="This is a test... I repeat: This is a test... "
export GTKBOX='
<vbox width-request="300">
 <text>
  <variable>MSG</variable>
  <input>echo -en "${MSG:2}${MSG:0:2}"</input>
 </text>
 <timer milliseconds="true" interval="200" visible="false">
  <action type="refresh">MSG</action>
 </timer> 
</vbox>'
gtkdialog4 -p GTKBOX

disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#693 Post by disciple »

Cool!
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

restrain combobox

#694 Post by don570 »

Two scripts AVAILABLE

I posted two scripts in programming section of forums
to demonstrate how to restrain the combobox

From a list of audio players , only the installed
audio players are shown.

Image


________________________________________________________

User avatar
walter leonardo
Posts: 234
Joined: Thu 10 Dec 2009, 22:10

Help with gtk-dialog

#695 Post by walter leonardo »

Could you help me with mine program electricity for puppy linux I'm doing. I want to do the calculations by pressing "enter" instead of pressing the button "calculate". Could you do that for me?. Now I send the files.
I'd also like to know how to make programs in a single window with multiple tabs, each program in each tab.
Attachments
vatiohms.tar.gz
(1 KiB) Downloaded 506 times

User avatar
smokey01
Posts: 2813
Joined: Sat 30 Dec 2006, 23:15
Location: South Australia :-(
Contact:

#696 Post by smokey01 »

Walter, to make tabs in a single window use the <notebook> command. The syntax can be found on the first page of this thread.

This should give you a clue how to use the enter key to accept input.

#! /bin/bash

export DIALOG='
<window title="Enter password" icon-name="gtk-dialog-question">
  <vbox>
    <hbox>
      <text>
        <label>Label:</label>
      </text>
      <entry activates-default="true">
        <variable>PASS0</variable>
      <visible>password</visible>
      </entry>
    </hbox>
    <hbox>
      <button cancel></button>
      <button can-default="true" has-default="true" use-stock="true">
        <label>gtk-ok</label>
      </button>
    </hbox>
  </vbox>
</window>
'

eval $(gtkdialog --program=DIALOG)
echo "$PASS0"

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#697 Post by zigbert »

To activate <entry> from enter-key you could use the 'activate' signal.

Code: Select all

<entry>
<action signal="activate">command</action>
</entry>

User avatar
walter leonardo
Posts: 234
Joined: Thu 10 Dec 2009, 22:10

Help with gtk-dialog

#698 Post by walter leonardo »

Use the function of the enter key and if it works, but only in a "Calcular" button and I want to get all the buttons work in "calcular"

As you would?


Code: Select all

#!/bin/bash
#Autor: Walter Leonardo Iñiguez
MAIN_DIALOG='
<window title="Programa VatiOhms"> 
<notebook page="0" labels=" Tab 1| Tab 2| Tab 3| Tab 4">        
<vbox>
  <frame  Calcular el Voltaje: V=I.R >
   <hbox>
     <text>
      <label>Ingrese Resistencia (Ohm):  </label>
     </text>
     <entry>
     <default>""</default>
      <variable>Resistencia</variable>
     </entry>
     <text>
      <label>o vatios</label>
     </text>
     <entry>
     <default>""</default>
      <variable>V</variable>
     </entry>
   </hbox>

   <hbox>
     <text>
      <label>Ingrese Corriente (Ampere):</label>
     </text>
     <entry activates-default="true">
     <default>""</default>
      <variable>Corriente</variable>
     </entry>
     <text>
      <label>o vatios</label>
     </text>
     <entry activates-default="true">
     <default>""</default>
      <variable>Val</variable>
     </entry>
   </hbox>

   <hbox>
     <text>
      <label>El voltaje es:                         </label>
     </text>
     <entry>
      <variable>Voltaje</variable>
      <input>echo "scale=6;$Resistencia*$Corriente" | bc</input>
      <input>echo "scale=6;$V/$Corriente" | bc</input>
      <input>echo "scale=6;sqrt($Val*$Resistencia)" | bc</input>
     </entry>
     <text>
      <label>Volts</label>
     </text>
   </hbox>

   <hbox>
     <button>
  	  <label>Borrar datos</label>
	  <action type="clear">Voltaje</action><action type="clear">Resistencia</action><action type="clear">Corriente</action><action type="clear">V</action><action type="clear">Val</action>
     </button>
     <button can-default="true" has-default="true" use-stock="true">
      <label>Calcular</label>
      <action>refresh:Voltaje</action>
     </button>
   </hbox>
 </frame>
 
 
 <frame Calcular la Resistencia: R=V/I >
   <hbox>
     <text>
      <label>Ingrese Tensión (Volt):         </label>
     </text>
     <entry>
     <default>""</default>
      <variable>Volts</variable>
     </entry>
     <text>
      <label>o vatios</label>
     </text>
     <entry>
     <default>""</default>
      <variable>Va</variable>
     </entry>
   </hbox>

   <hbox>
     <text>
      <label>Ingrese Corriente (Ampere):</label>
     </text>
     <entry activates-default="true">
     <default>""</default>
      <variable>Amper</variable>
     </entry>
     <text>
      <label>o vatios</label>
     </text>
     <entry activates-default="true">
     <default>""</default>
      <variable>Vas</variable>
     </entry>
   </hbox>

   <hbox>
     <text>
      <label>La resistencia es:                 </label>
     </text>
     <entry>
      <variable>Resistor</variable>
      <input>echo "scale=3;$Volts/$Amper" | bc</input>
      <input>echo "scale=3;($Va/$Amper)/$Amper" | bc</input>
      <input>echo "scale=3;$Volts/($Vas/$Volts)" | bc</input>
     </entry>
     <text>
      <label>Ohms</label>
     </text>
   </hbox>

  	<hbox>
  	 <button>
  	  <label>Borrar datos</label>
	  <action type="clear">Resistor</action><action type="clear">Volts</action><action type="clear">Amper</action><action type="clear">Va</action><action type="clear">Vas</action>
     </button>
     <button can-default="true" has-default="true" use-stock="true">
      <label>Calcular</label>
      <action>refresh:Resistor</action>
     </button>
    </hbox>
   </frame>
 
 
 <frame Calcular la Corriente: I=V/R >
   <hbox>
     <text>
      <label>Ingrese Tensión (Volt):        </label>
     </text>
     <entry>
     <default>""</default>
      <variable>Tensio</variable>
     </entry>
     <text>
      <label>o vatios</label>
     </text>
     <entry>
     <default>""</default>
      <variable>Vac</variable>
     </entry>
   </hbox>

   <hbox>
     <text>
      <label>Ingrese Resistencia (Ohm): </label>
     </text>
     <entry activates-default="true">
     <default>""</default>
      <variable>Resisten</variable>
     </entry>
     <text>
      <label>o vatios</label>
     </text>
     <entry activates-default="true">
     <default>""</default>
      <variable>Vat</variable>
     </entry>
   </hbox>

   <hbox>
     <text>
      <label>La Corriente es:                  </label>
     </text>
     <entry>
      <variable>Corrient</variable>
      <input>echo "scale=6;$Tensio/$Resisten" | bc</input>
      <input>echo "scale=6;$Vat/$Tensio" | bc</input>
      <input>echo "scale=6;(sqrt($Vac*$Resisten))/$Resisten" | bc</input>
     </entry>
     <text>
      <label>Amperes</label>
     </text>
   </hbox>
   

    <hbox>
     <button>
  	  <label>Borrar datos</label>
	  <action type="clear">Corrient</action><action type="clear">Tensio</action><action type="clear">Resisten</action><action type="clear">Vat</action><action type="clear">Vac</action>
     </button>
     <button can-default="true" has-default="true" use-stock="true">
      <label>Calcular</label>
      <action>refresh:Corrient</action>
     </button>
   </hbox>
 </frame>
 
 
 <frame Calcular los Vatios (Watts): W=I.V >
   <hbox>
     <text>
      <label>Ingrese Tensión (Volt):          </label>
     </text>
     <entry>
     <default>""</default>
      <variable>Tensione</variable>
     </entry>
     <text>
      <label>o resistencia</label>
     </text>
     <entry>
     <default>""</default>
      <variable>Vad</variable>
     </entry>
   </hbox>

   <hbox>
     <text>
      <label>Ingrese Corriente (Ampere): </label>
     </text>
     <entry activates-default="true">
     <default>""</default>
      <variable>Amperiore</variable>
     </entry>
     <text>
      <label>o resistencia</label>
     </text>
     <entry activates-default="true">
     <default>""</default>
      <variable>Vag</variable>
     </entry>
   </hbox>

   <hbox>
     <text>
      <label>Los Vatios son:                     </label>
     </text>
     <entry>
      <variable>Vatios</variable>
      <input>echo "scale=6;$Tensione*$Amperiore" | bc</input>
      <input>echo "scale=6;($Vad*$Amperiore)*$Amperiore" | bc</input>
      <input>echo "scale=6;($Tensione/$Vag)*$Tensione" | bc</input>
     </entry>
     <text>
      <label>Vatios</label>
     </text>
   </hbox>
   

    <hbox>
     <button>
  	  <label>Borrar datos</label>
	  <action type="clear">Vatios</action><action type="clear">Tensione</action><action type="clear">Amperiore</action><action type="clear">Vad</action><action type="clear">Vag</action>
     </button>
     <button can-default="true" has-default="true" use-stock="true">
      <label>Calcular</label>
      <action>refresh:Vatios</action>
     </button>
   </hbox>
 </frame>
 
 
    <hbox>
     <button>
  	  <label>BORRAR TODOS LOS DATOS</label>
	  <action type="clear">Resistor</action><action type="clear">Volts</action><action type="clear">Amper</action><action type="clear">Va</action><action type="clear">Vas</action><action type="clear">Vatios</action><action type="clear">Tensione</action><action type="clear">Amperiore</action><action type="clear">Vad</action><action type="clear">Vag</action><action type="clear">Corrient</action><action type="clear">Tensio</action><action type="clear">Resisten</action><action type="clear">Vat</action><action type="clear">Vac</action><action type="clear">Voltaje</action><action type="clear">Resistencia</action><action type="clear">Corriente</action><action type="clear">V</action><action type="clear">Val</action>
     </button>
    <button>
      <label>SALIR</label>
      <action>exit:EXIT</action>
     </button>
  </hbox>
</vbox>
</notebook>
</window>
' gtkdialog3 --program=MAIN_DIALOG
 

User avatar
walter leonardo
Posts: 234
Joined: Thu 10 Dec 2009, 22:10

Help with gtk-dialog

#699 Post by walter leonardo »

Now use the function tabs in my program and it worked well with the function of the enter key, but the enter key works only see in every window. What would be the problem?

Code: Select all

#!/bin/bash
#Autor: Walter Leonardo Iñiguez
MAIN_DIALOG='
<window title="Programa VatiOhms">
<notebook page="0" labels=" Tab 1| Tab 2| Tab 3| Tab 4">         
<vbox>
  <frame>
  <text use-markup="true">
  <label>"<b><u>Calcular el Voltaje: V=I.R</u></b>"</label>
  </text>
   <hbox>
     <text>
      <label>Ingrese Resistencia (Ohm):  </label>
     </text>
     <entry>
     <default>""</default>
      <variable>Resistencia</variable>
     </entry>
     <text>
      <label>o vatios</label>
     </text>
     <entry>
     <default>""</default>
      <variable>V</variable>
     </entry>
   </hbox>

   <hbox>
     <text>
      <label>Ingrese Corriente (Ampere):</label>
     </text>
     <entry activates-default="true">
     <default>""</default>
      <variable>Corriente</variable>
     </entry>
     <text>
      <label>o vatios</label>
     </text>
     <entry activates-default="true">
     <default>""</default>
      <variable>Val</variable>
     </entry>
   </hbox>

   <hbox>
     <text>
      <label>El voltaje es:                         </label>
     </text>
     <entry>
      <variable>Voltaje</variable>
      <input>echo "scale=6;$Resistencia*$Corriente" | bc</input>
      <input>echo "scale=6;$V/$Corriente" | bc</input>
      <input>echo "scale=6;sqrt($Val*$Resistencia)" | bc</input>
     </entry>
     <text>
      <label>Volts</label>
     </text>
   </hbox>

   <hbox>
     <button>
  	  <label>Borrar datos</label>
	  <action type="clear">Voltaje</action><action type="clear">Resistencia</action><action type="clear">Corriente</action><action type="clear">V</action><action type="clear">Val</action>
     </button>
     <button can-default="true" has-default="true" use-stock="true">
      <label>Calcular</label>
      <action>refresh:Voltaje</action>
     </button>
   </hbox>
 </frame>
 </vbox>
 
 <vbox>
 <frame Calcular la Resistencia: R=V/I >
   <hbox>
     <text>
      <label>Ingrese Tensión (Volt):         </label>
     </text>
     <entry>
     <default>""</default>
      <variable>Volts</variable>
     </entry>
     <text>
      <label>o vatios</label>
     </text>
     <entry>
     <default>""</default>
      <variable>Va</variable>
     </entry>
   </hbox>

   <hbox>
     <text>
      <label>Ingrese Corriente (Ampere):</label>
     </text>
     <entry activates-default="true">
     <default>""</default>
      <variable>Amper</variable>
     </entry>
     <text>
      <label>o vatios</label>
     </text>
     <entry activates-default="true">
     <default>""</default>
      <variable>Vas</variable>
     </entry>
   </hbox>

   <hbox>
     <text>
      <label>La resistencia es:                 </label>
     </text>
     <entry>
      <variable>Resistor</variable>
      <input>echo "scale=3;$Volts/$Amper" | bc</input>
      <input>echo "scale=3;($Va/$Amper)/$Amper" | bc</input>
      <input>echo "scale=3;$Volts/($Vas/$Volts)" | bc</input>
     </entry>
     <text>
      <label>Ohms</label>
     </text>
   </hbox>

  	<hbox>
  	 <button>
  	  <label>Borrar datos</label>
	  <action type="clear">Resistor</action><action type="clear">Volts</action><action type="clear">Amper</action><action type="clear">Va</action><action type="clear">Vas</action>
     </button>
     <button can-default="true" has-default="true" use-stock="true">
      <label>Calcular</label>
      <action>refresh:Resistor</action>
     </button>
    </hbox>
   </frame>
 </vbox>
 
 <vbox>
 <frame Calcular la Corriente: I=V/R >
   <hbox>
     <text>
      <label>Ingrese Tensión (Volt):        </label>
     </text>
     <entry>
     <default>""</default>
      <variable>Tensio</variable>
     </entry>
     <text>
      <label>o vatios</label>
     </text>
     <entry>
     <default>""</default>
      <variable>Vac</variable>
     </entry>
   </hbox>

   <hbox>
     <text>
      <label>Ingrese Resistencia (Ohm): </label>
     </text>
     <entry activates-default="true">
     <default>""</default>
      <variable>Resisten</variable>
     </entry>
     <text>
      <label>o vatios</label>
     </text>
     <entry activates-default="true">
     <default>""</default>
      <variable>Vat</variable>
     </entry>
   </hbox>

   <hbox>
     <text>
      <label>La Corriente es:                  </label>
     </text>
     <entry>
      <variable>Corrient</variable>
      <input>echo "scale=6;$Tensio/$Resisten" | bc</input>
      <input>echo "scale=6;$Vat/$Tensio" | bc</input>
      <input>echo "scale=6;(sqrt($Vac*$Resisten))/$Resisten" | bc</input>
     </entry>
     <text>
      <label>Amperes</label>
     </text>
   </hbox>
   

    <hbox>
     <button>
  	  <label>Borrar datos</label>
	  <action type="clear">Corrient</action><action type="clear">Tensio</action><action type="clear">Resisten</action><action type="clear">Vat</action><action type="clear">Vac</action>
     </button>
     <button can-default="true" has-default="true" use-stock="true">
      <label>Calcular</label>
      <action>refresh:Corrient</action>
     </button>
   </hbox>
 </frame>
</vbox>

<vbox>
 <frame Calcular los Vatios (Watts): W=I.V >
   <hbox>
     <text>
      <label>Ingrese Tensión (Volt):          </label>
     </text>
     <entry>
     <default>""</default>
      <variable>Tensione</variable>
     </entry>
     <text>
      <label>o resistencia</label>
     </text>
     <entry>
     <default>""</default>
      <variable>Vad</variable>
     </entry>
   </hbox>

   <hbox>
     <text>
      <label>Ingrese Corriente (Ampere): </label>
     </text>
     <entry activates-default="true">
     <default>""</default>
      <variable>Amperiore</variable>
     </entry>
     <text>
      <label>o resistencia</label>
     </text>
     <entry activates-default="true">
     <default>""</default>
      <variable>Vag</variable>
     </entry>
   </hbox>

   <hbox>
     <text>
      <label>Los Vatios son:                     </label>
     </text>
     <entry>
      <variable>Vatios</variable>
      <input>echo "scale=6;$Tensione*$Amperiore" | bc</input>
      <input>echo "scale=6;($Vad*$Amperiore)*$Amperiore" | bc</input>
      <input>echo "scale=6;($Tensione/$Vag)*$Tensione" | bc</input>
     </entry>
     <text>
      <label>Vatios</label>
     </text>
   </hbox>
   

    <hbox>
     <button>
  	  <label>Borrar datos</label>
	  <action type="clear">Vatios</action><action type="clear">Tensione</action><action type="clear">Amperiore</action><action type="clear">Vad</action><action type="clear">Vag</action>
     </button>
     <button can-default="true" has-default="true" use-stock="true">
      <label>Calcular</label>
      <action>refresh:Vatios</action>
     </button>
   </hbox>
 </frame>

    <hbox>
     <button>
  	  <label>BORRAR TODOS LOS DATOS</label>
	  <action type="clear">Resistor</action><action type="clear">Volts</action><action type="clear">Amper</action><action type="clear">Va</action><action type="clear">Vas</action><action type="clear">Vatios</action><action type="clear">Tensione</action><action type="clear">Amperiore</action><action type="clear">Vad</action><action type="clear">Vag</action><action type="clear">Corrient</action><action type="clear">Tensio</action><action type="clear">Resisten</action><action type="clear">Vat</action><action type="clear">Vac</action><action type="clear">Voltaje</action><action type="clear">Resistencia</action><action type="clear">Corriente</action><action type="clear">V</action><action type="clear">Val</action>
     </button>
    <button>
      <label>SALIR</label>
      <action>exit:EXIT</action>
     </button>
  </hbox>
  </vbox>
</notebook>
</window>
' gtkdialog3 --program=MAIN_DIALOG
 

User avatar
smokey01
Posts: 2813
Joined: Sat 30 Dec 2006, 23:15
Location: South Australia :-(
Contact:

#700 Post by smokey01 »

Can anyone offer a simple gtkdialog GUI for netcat.

I would like to be able to run netcat in backgrounded listening mode when I start the computer. If someone was to call me using netcat, my system should open a chat window so the caller and callee can chat.

It's easy enough to do it in two terminal on the local and remote computer.

EG: listening computer:
netcat -lp <port>

EG: Calling computer:
netcat 192.168.x.x <port>

Both terminals will connect and you can chat in the terminal windows.

This can also be done on a WAN but you need to do some port forwarding.

I would also be happy just to use the terminal/console as long as it is backgrounded until invoked by the caller. I just don't want in in the tray until it's required.

Thanks

User avatar
smokey01
Posts: 2813
Joined: Sat 30 Dec 2006, 23:15
Location: South Australia :-(
Contact:

#701 Post by smokey01 »

Alternative to the above, all I need is some indication that the remote computer is online. I don't really need a chat client. When both computers are online each should be visible to each other. I guess a poke function would be useful just to let the other party know you want to communicate.

Thanks

disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#702 Post by disciple »

ping?
nbtscan?
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#703 Post by technosaurus »

smokey01 wrote:Can anyone offer a simple gtkdialog GUI for netcat.
Goingnuts adapted my irc client to use netcat, I was just using Xdialog, but he may have used something else as well.
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

sklimkin
Posts: 157
Joined: Wed 11 Jul 2012, 21:21
Location: Russia Moscow

make string of argements for scrot-program

#704 Post by sklimkin »

Please help to master script.
There can be somebody collected a string of arguments from the program gtkdialog?

Here that I can't master in bash-gtkdialog:
#!/bin/bash
GTKDIALOG=gtkdialog

if [ "$COMBOBOX1" == "All" ]; then
COMMAND1=
##sprintf( COMMANDSTRING, "scrot -d %s -e 'mv $f ~%s'", COMBOBOX2, FILE );
else COMMAND1="-s"
##sprintf( COMMANDSTRING, "scrot -d %s -s -e 'mv $f ~%s'", COMBOBOX2, FILE );
echo "COMMAND1= $COMMAND1"
COMMAND2="$COMBOBOX2"
echo "COMMAND2= $COMMAND2"
COMMANDSTRING="-d $COMMAND2 $COMMAND1 -e 'mv $f ~'"
export COMMANDSTRING
echo "COMMANDSTRING= $COMMANDSTRING"
echo "End of export variables."
fi

export MAIN_DIALOG='
<window title="SCReenshOT screen-grabber">
<vbox>
... ... ...
I pass the insignificant
... ... ...
It is necessary to connect variable COMMANDSTRING here to what:
<button>
<label>ACCEPT</label>
<variable>GOMMANDSRING</variable>
<action>echo "Start of scrot:"</action>
<action>cat [ echo $COMMANDSTRING ] | scrot </action>
</button>

That is to transfer to function <action> a string of arguments for scrot (SCReen-shOT).

All other works: the directory for saving is selected, setting selected by the user are stored to an output from the program.

Commented out in the beginning of a file of a line ## sprintf (...) it that works in bash, but isn't accepted in gtkdialog and SO it would be desirable...

sklimkin
Posts: 157
Joined: Wed 11 Jul 2012, 21:21
Location: Russia Moscow

Corrected data to my previous post

#705 Post by sklimkin »

1. Script

Code: Select all

#!/bin/bash
GTKDIALOG=gtkdialog

if [ "$COMBOBOX1" == "All" ]; then
COMMAND1= 
##sprintf( COMMANDSTRING, "scrot -d %s -e 'mv $f ~%s'", COMBOBOX2, FILE );
else COMMAND1="-s"
##sprintf( COMMANDSTRING, "scrot -d %s -s -e 'mv $f ~%s'", COMBOBOX2, FILE );
echo "COMMAND1= $COMMAND1"
COMMAND2="$COMBOBOX2"
echo "COMMAND2= $COMMAND2"
COMMANDSTRING="-d $COMMAND2 $COMMAND1 -e 'mv $f ~'"
export COMMANDSTRING
echo "COMMANDSTRING= $COMMANDSTRING"
echo "End of export variables."
fi

export MAIN_DIALOG='
<window title="SCReenshOT  screen-grabber">
	<vbox>
		<frame Command button EXIT>
			<hbox>
				<button cancel></button>
			</hbox>
		</frame>

		<frame User-settings>
			<hbox>
				<vbox>
					<text>
						<label>Select grab-mode</label>
					</text>
					<combobox>
						<variable>COMBOBOX1</variable>
						<item>All</item>
						<item>Window</item>
						<item>Area</item>
						<action>save:COMBOBOX1</action>
						<variable>COMMAND1</variable>
					</combobox>
				</vbox>
				<vbox>
					<text>
						<label>Time-delay-sec</label>
					</text>
					<combobox>
						<variable>COMBOBOX2</variable>
						<item>0</item>
						<item>1</item>
						<item>2</item>
						<item>5</item>
						<item>10</item>
						<item>20</item>
						<action>save:COMBOBOX2</action>
						<variable>COMMAND2</variable>
					</combobox>
				</vbox>
				<button>
					<label>ACCEPT</label>
					<variable>GOMMANDSRING</variable>
					<action>echo "Start of scrot:"</action>
					<action>cat [ echo $COMMANDSTRING ] | scrot </action>
				</button>
			</hbox>
		</frame>

		<frame Select DIR for save screenshot>
			<chooser>
				<height>200</height>
				<width>200</width>
				<variable>FILE</variable>
				<default>/home/</default>
				<action>cat [ echo $FILE ] | zenity --text-info  --width=250 --height=250 --title $FILE</action>
			</chooser>
		</frame>
	</vbox>
</window>
'

case $1 in
	-d | --dump) echo "$MAIN_DIALOG" ;;
	*) $GTKDIALOG --program=MAIN_DIALOG ;;
esac
2. Screenshot with "head"

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#706 Post by zigbert »

sklimkin
I have read your post some times to get the grip of the problem....
Is it this line that won't work?

Code: Select all

<action>cat [ echo $COMMANDSTRING ] | scrot </action>
If you find gtkdialog sensitive to your bash code, remember, you can always place bash code in an external function. Like:

Code: Select all

call() {
 cat "$COMMANDSTRING" | scrot
}

[...]

<action>call </action>

Sigmund

sklimkin
Posts: 157
Joined: Wed 11 Jul 2012, 21:21
Location: Russia Moscow

#707 Post by sklimkin »

zigbert wrote:sklimkin
... ...
If you find gtkdialog sensitive to your bash code, remember, you can always place bash code in an external function. Like:

Code: Select all

call() {
 cat "$COMMANDSTRING" | scrot
}
[...]
<action>call </action>
Sigmund
Thanks for attention, Sigmund.
I read some hours about bash-scripting successively.
After that has corrected the program text:

Code: Select all

#!/bin/bash
GTKDIALOG=gtkdialog

funccommand () {
if [ "$COMBOBOX1" == "All" ]; then
COMMAND1= 
else COMMAND1="-s"
echo "COMMAND1= $COMMAND1"
COMMAND2="$COMBOBOX2"
echo "COMMAND2= $COMMAND2"
COMMANDSTRING="-d $COMMAND2 $COMMAND1 -e 'mv $f ~'"
echo "COMMANDSTRING= $COMMANDSTRING"
echo "End of export variables."
fi
}

export MAIN_DIALOG='
... ... ...

	<button>
		<label>ACCEPT</label>
		<variable>GOMMANDSRING</variable>
		<action>echo "Start of scrot:"</action>
		<action>funccommand $COMBOBOX1 $COMBOBOX2</action>
		<action>echo "COMMANDSTRING= $COMMANDSTRING"</action>
		<action>cat [ echo $COMMANDSTRING ] | scrot </action>
				</button>
In bash-script it works:

Code: Select all

sklimkin@sklimkin-desktop:~$ funccommand () {
> if [ "$COMBOBOX1" == "All" ]; then
> COMMAND1= 
> else COMMAND1="-s"
> echo "COMMAND1= $COMMAND1"
> COMMAND2="$COMBOBOX2"
> echo "COMMAND2= $COMMAND2"
> COMMANDSTRING="-d $COMMAND2 $COMMAND1 -e 'mv $f ~'"
> echo "COMMANDSTRING= $COMMANDSTRING"
> echo "End of export variables."
> fi
> }
sklimkin@sklimkin-desktop:~$ COMBOBOX2="5"
sklimkin@sklimkin-desktop:~$ COMBOBOX1="Window"
sklimkin@sklimkin-desktop:~$ GOMMANDSRING=""
sklimkin@sklimkin-desktop:~$ funccommand $COMBOBOX1 $COMBOBOX2
COMMAND1= -s
COMMAND2= 5
COMMANDSTRING= -d 5 -s -e 'mv  ~'
End of export variables.
sklimkin@sklimkin-desktop:~$
And in gtkdialog isn't works:

Code: Select all

Start of scrot:
sh: funccommand: command not found
COMMANDSTRING= 
sh: scrot: command not found
cat: [: file or dir missing
cat: echo: file or dir missing
cat: ]: file or dir missing
COMBOBOX1="Window"
COMBOBOX2="5"
FILE="/home/sklimkin/projects/gtkdialog/scrotdlg-bash2/dialog"
GOMMANDSRING=""
EXIT="Cancel"
sklimkin@sklimkin-desktop:~/projects/gtkdialog/scrotdlg-bash2$ 
gtkdialog doesn't find my new function funccommand ()

Code: Select all

sh: funccommand: command not found

Problem in this string:

Code: Select all

<action>funccommand $COMBOBOX1 $COMBOBOX2</action>
I want to understand how correctly to cause external functions from gtkdialog.
Probably such calls are inaccessible in prior versions gtkdialog
At me now:

Code: Select all

sklimkin@sklimkin-desktop:~$ gtkdialog -v
gtkdialog version 0.8.0 (C) 2003-2007 Laszlo Pere, 2011 Thunor
Also isn't works:

Code: Select all

#!/bin/bash
GTKDIALOG=gtkdialog

call() {
funccommand $COMBOBOX1 $COMBOBOX2
echo "call_COMMANDSTRING= $COMMANDSTRING"
cat "$COMMANDSTRING" | scrot
}

funccommand () {
if [ "$COMBOBOX1" == "All" ]; then
COMMAND1= 
else COMMAND1="-s"
echo "COMMAND1= $COMMAND1"
COMMAND2="$COMBOBOX2"
echo "COMMAND2= $COMMAND2"
COMMANDSTRING="-d $COMMAND2 $COMMAND1 -e 'mv $f ~'"
echo "COMMANDSTRING= $COMMANDSTRING"
echo "End of export variables."
fi
}

export MAIN_DIALOG='

	<button>
		<label>ACCEPT</label>
		<variable>GOMMANDSRING</variable>
		<action>echo "Start of scrot:"</action>
		<action>call </action>
	</button>
Thankful in advance for the correct helps.

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#708 Post by technosaurus »

export -f func_name
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

sklimkin
Posts: 157
Joined: Wed 11 Jul 2012, 21:21
Location: Russia Moscow

#709 Post by sklimkin »

technosaurus wrote:export -f func_name
export -f
This that magic word of which didn't suffice for the question decision.
Thanks for the help, mr technosaurus!

User avatar
oldyeller
Posts: 889
Joined: Tue 15 Nov 2011, 14:26
Location: Alaska

#710 Post by oldyeller »

Hello Everyone

Has anyone used the fontbutton widget yet?

I have tried to use it to increase the font in the reader that I am making with the edit widget.

Don't know if you can use it in the edit widget or not.

This is my code so far
#!/bin/bash

GTKDIALOG=gtkdialog

WORKDIR="/usr/local/Manna"
NOTES_DIR="$WORKDIR/notestxt"

funcbtnCreate() {
echo '<button image-position="'$2'">
<label>"'"$3"'"</label>
<input file stock="'$4'"></input>
<action>echo "'"$5"' '$1'"</action>
<action type="'"$3"'">'$1'</action>
</button>'
}
export TMPDIR=/tmp/notes
mkdir -p "$TMPDIR"

echo "$TMPDIR"/reading

export MAIN_DIALOG='
<window title="Notes" icon-name="Com">

<frame>
<vbox spacing="0">
<menubar>
<menu use-underline="true">
<menuitem stock-id="gtk-quit" accel-key="0x51" accel-mods="4">
<action>exit:Quit</action>
</menuitem>
<label>"_File"</label>
</menu>
<menu label="_Edit" use-underline="true">
<menuitem stock-id="gtk-home" label="Send to Abiword">
<action>abiword '"$TMPDIR"'/reading &</action>
</menuitem>
</menu>
</menubar>
</vbox>
<hbox>
<vbox width-request="120">
<table>
<label>Notes</label>
<variable>ITEM</variable>
<input>ls '"$NOTES_DIR"'</input>
<action>ln -sf "/usr/local/Manna/notestxt/$ITEM" '"$TMPDIR"'/reading</action>
<action>refresh:EDITOR</action>
</table>
</vbox>
<edit editable="true" accepts-tab="true" indent="" justification="0" left-margin="12" right-margin="15" wrap-mode="1">
<variable>EDITOR</variable>
<height>600</height>
<width>350</width>
<input file>'"$TMPDIR"'/reading</input>
<output file>'"$TMPDIR"'/reading</output>
</edit>

</hbox>

<hbox homogeneous="true" spacing="28" width-request="350">
'"$(funcbtnCreate EDITOR 0 Refresh gtk-refresh Refreshing)"'
'"$(funcbtnCreate EDITOR 0 Save gtk-save Saving)"'

<fontbutton font-name="Sans 14" use-font="true" use-size="true">
<variable>$EDITOR</variable>
<input file>'"$TMPDIR"'/reading</input>
<output file>'"$TMPDIR"'/reading</output>

<action>refresh:EDITOR</action>
</fontbutton>
</hbox>
</frame>
</window>
'

case $1 in
-d | --dump) echo "$MAIN_DIALOG" ;;
*) $GTKDIALOG --center --program=MAIN_DIALOG ;;
esac


Post Reply