Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Wed 26 Nov 2014, 12:28
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
GtkDialog - tips
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
Page 48 of 64 Posts_count   Goto page: Previous 1, 2, 3, ..., 46, 47, 48, 49, 50, ..., 62, 63, 64 Next
Author Message
zigbert


Joined: 29 Mar 2006
Posts: 5788
Location: Valåmoen, Norway

PostPosted: Wed 31 Oct 2012, 13:58    Post_subject:  

sklimkin
I have read your post some times to get the grip of the problem....
Is it this line that won't work?
Code:
<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:
call() {
 cat "$COMMANDSTRING" | scrot
}

[...]

<action>call </action>



Sigmund

_________________
Stardust resources
Back to top
View user's profile Send_private_message Visit_website 
sklimkin

Joined: 11 Jul 2012
Posts: 154
Location: Russia Moscow

PostPosted: Wed 31 Oct 2012, 15:46    Post_subject:  

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:
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:
#!/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:
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:
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:
sh: funccommand: command not found

Problem in this string:
Code:
<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:
sklimkin@sklimkin-desktop:~$ gtkdialog -v
gtkdialog version 0.8.0 (C) 2003-2007 Laszlo Pere, 2011 Thunor


Also isn't works:
Code:
#!/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.
Back to top
View user's profile Send_private_message 
technosaurus


Joined: 18 May 2008
Posts: 4379

PostPosted: Wed 31 Oct 2012, 18:52    Post_subject:  

export -f func_name
_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send_private_message 
sklimkin

Joined: 11 Jul 2012
Posts: 154
Location: Russia Moscow

PostPosted: Thu 01 Nov 2012, 15:04    Post_subject:  

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!
Back to top
View user's profile Send_private_message 
oldyeller


Joined: 15 Nov 2011
Posts: 818
Location: Mishawaka IN

PostPosted: Tue 06 Nov 2012, 18:27    Post_subject:  

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

Quote:

#!/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


Back to top
View user's profile Send_private_message 
sklimkin

Joined: 11 Jul 2012
Posts: 154
Location: Russia Moscow

PostPosted: Sat 10 Nov 2012, 13:36    Post_subject: GtkDialog + scrot = Graphic-interface  

sklimkin wrote:
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!


There was a task to make the graphic interface with the program scrot.
It is for this purpose convenient and pleasant to use gtkdialog and bash.
The variant with a call of additional function works.

Here that has turned out:
Code:

#!/bin/bash
## or /bin/sh

funccommand () {
if [ "$COMBOBOX1" == "All" ]; then
COMMAND1="-m"
else COMMAND1="-s"
fi
## !!! Attention: This works in scrot ver. >= 0.8 only !!!
if [ "$COMBOBOX1" == "Window" ]; then
COMMAND1="-u"
fi
COMMAND2="$COMBOBOX2"
COMMANDSTRING="$COMMAND1-b-d $COMMAND2"
cd "$FILE"
scrot "$COMMANDSTRING"
}

export MAIN_DIALOG="
<window>
   <vbox>
      <text>
         <label>SCReenshOT  screen-grabber</label>
      </text>
      <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>
               </combobox>
            </vbox>
            <vbox>
               <text>
                  <label>Time-delay-sec</label>
               </text>
               <combobox>
                  <variable>COMBOBOX2</variable>
                  <item>0</item>
                  <item>1</item>
                  <item>2</item>
                  <item>3</item>
                  <item>5</item>
                  <item>10</item>
                  <item>20</item>
                  <action>save:COMBOBOX2</action>
               </combobox>
            </vbox>
            <button>
               <label>ACCEPT</label>
               <action>$0 func</action>
            </button>
         </hbox>
      </frame>
      <frame Select DIR for save screenshot>
         <chooser>
            <height>200</height>
            <width>200</width>
            <variable>FILE</variable>
            <default>/home/</default>
            <action>save:FILE</action>
            <action>$2= $FILE</action>
         </chooser>
      </frame>
   </vbox>
</window>
"

case $1 in
   func) funccommand $2 ;;
   *) gtkdialog --program=MAIN_DIALOG ;;
esac


And it is variant of usage gtkdialog for C-lang:
http://www.mediafire.com/download.php?el5ruubgov613qg

ScreenShot of "SreenShoter":[/img][/code]
2012-11-10-213247_459x416_scrot.png
 Description   
 Filesize   40.54 KB
 Viewed   1054 Time(s)

2012-11-10-213247_459x416_scrot.png

Back to top
View user's profile Send_private_message 
recobayu


Joined: 15 Sep 2010
Posts: 114
Location: indonesia

PostPosted: Mon 12 Nov 2012, 02:19    Post_subject:  

hi everyone,
i want to make a startmenu in puppy linux like "unity" in ubuntu or something like "metro start menu" in windows8. below, i make a button and scroll in vbox and gtkdialog desklet. but i want more..
i want to a textbox (an entry), that can search every program by change (key-pressed). can anyone help me, please?
thanks in advance
startku.png
Description 
png

 Download 
Filename  startku.png 
Filesize  210.34 KB 
Downloaded  422 Time(s) 

_________________
myblog: http://muktyas.blogspot.com
Back to top
View user's profile Send_private_message 
smokey01


Joined: 30 Dec 2006
Posts: 1844
Location: South Australia

PostPosted: Mon 12 Nov 2012, 03:06    Post_subject:  

Have you had a look at http://www.smokey01.com/software/desktop/myGTKmenu.tar.gz
_________________
Puppy Software <-> Distros <-> Puppy Linux Tips
Back to top
View user's profile Send_private_message Visit_website 
sklimkin

Joined: 11 Jul 2012
Posts: 154
Location: Russia Moscow

PostPosted: Thu 15 Nov 2012, 12:48    Post_subject: tag for closewindow  

I read old authoring gtkdialog help:
Quote:
6.2 Widget manipulation
6.2.1 'Closewindow:NAME'
The command closes the named window opened by the 'Launch:' command. The program remain active if there are more windows active.
6.2.2 'Launch:NAME'
The command opens a new window using the environment variable 'Widget'.

For some reasons I can't use tags:
Code:
<action type="launch">DIALOG1</action>
<action type="closewindow">DIALOG1</action>

I use and It works:
Code:
<action>Launch:DIALOG1</action>

And it isn't works:
Code:
<action>Closewindow:DIALOG1</action>

Why?
Who can help?
Back to top
View user's profile Send_private_message 
don570


Joined: 10 Mar 2010
Posts: 3379
Location: Ontario

PostPosted: Sat 22 Dec 2012, 14:55    Post_subject: yaf-splash tip  

Here's a tip....
Code:

<action>yaf-splash -border false  -center -close box -bg orange -fontsize large -text "  John's  message
here   "  & </action>

The above code isn't allowed for the action of a button in a gtkdialog script,
because the text is on two lines.

A way around this problem is to define a variable at beginning of script
such as

Code:
export MESSAGE=" John's message
here "


Then the button's action becomes one line...
Code:
<action>yaf-splash -border false  -center -close box -bg orange -fontsize large -text " $MESSAGE  "  & </action>





_______________________________________________

I found that if Zigbert's localisation method is used then
MESSAGE=" John's message
here "

is all that is needed. In other words the exporting of the
variable isn't needed.

________________________________________


EDIT: I couldn't get this method of using yaf-splash in a button action
to work when there was a gettext text string Crying or Very sad

.

Edited_times_total
Back to top
View user's profile Send_private_message 
mavrothal


Joined: 24 Aug 2009
Posts: 1805

PostPosted: Mon 31 Dec 2012, 03:35    Post_subject: newbe question  

Happy New Year "dialoguers" Very Happy

I'm trying to make a simple GUI for pet installation (below), but I can not find the way to pass the fileselect choice to petget (apparently did not study enough Embarassed )

I appreciate any suggestions

Code:
export INSTALL_PET_GUI='<window title="Pet installer GUI">
 <vbox>
   <frame>
   <text use-markup="true"><label>"Sellect a pet to install"</label></text>
     
   <hbox>
    <text><label>Sellect pet</label></text>
    <entry fs-action="file" fs-folder="/root"
   tooltip-text="Drag or type the pet path here or use the file select button">
     <default>pet</default>
     <variable>EXEC</variable>
    </entry>
   <button>
     <input file stock="gtk-directory"></input>
     <action>fileselect:EXEC</action>
    </button>
   </hbox>
   <hbox homogeneous="true">
   <button>
     <label>"Install"</label>
     <action>/usr/local/petget/petget ??? </action>
     <action>exit:apply</action>
   </button>
   <button cancel></button>
  </hbox> 
  </frame>
 </vbox>
</window>'
gtkdialog -p INSTALL_PET_GUI

_________________
Kids all over the world go around with an XO laptop. They deserve one puppy (or many) too Very Happy
Back to top
View user's profile Send_private_message 
Geoffrey


Joined: 30 May 2010
Posts: 1477
Location: Queensland Australia ɹǝpu∩uʍop

PostPosted: Mon 31 Dec 2012, 05:14    Post_subject:  

Hi mavrothal,

This works
Code:
<button>
     <label>"Install"</label>
     <action>/usr/local/petget/petget $EXEC</action>
     <action>exit:apply</action>
   </button>


or better yet, the full path isn't needed,

Code:
<button>
     <label>"Install"</label>
     <action>petget $EXEC</action>
     <action>exit:apply</action>
   </button>


Cheers, ☃HaPpy NeWyEaR☘

Geoffrey

_________________
Carolina: Recent Repository Additions
Create strikethrough text HERE
Back to top
View user's profile Send_private_message 
mavrothal


Joined: 24 Aug 2009
Posts: 1805

PostPosted: Mon 31 Dec 2012, 06:46    Post_subject:  

Geoffrey wrote:
This works
Code:
<button>
     <label>"Install"</label>
     <action>/usr/local/petget/petget $EXEC</action>
     <action>exit:apply</action>
   </button>



Indeed it does.
Thanks and a Happy New Year to you

_________________
Kids all over the world go around with an XO laptop. They deserve one puppy (or many) too Very Happy
Back to top
View user's profile Send_private_message 
thunor


Joined: 14 Oct 2010
Posts: 350
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings

PostPosted: Mon 07 Jan 2013, 11:47    Post_subject:  

Here's a nice tip:

Activating a menuitem processes the actions within the menuitem immediately and then returns to the activater.

Activating a button returns to the activater and then processes the actions within the button later when the button has finished animating.

So, a hidden menuitem is a good place to store lots of code that can be called (activated) from multiple places -- it can be thought of as a subroutine of gtkdialog pseudo-XML.

Here's an example that demonstrates the speed difference and the processing order (watch stdout in terminal):
Code:
#!/bin/sh

GTKDIALOG=gtkdialog

RandomGet="od -An -N2 -tu2 < /dev/urandom"

MAIN_DIALOG='
<window title="Activate Test" window-position="1" resizable="false"
   border-width="0">
   <vbox spacing="0">
      <menubar>
         <menu use-underline="true" label="_File">
            <menuitem stock-id="gtk-quit" accel-key="0x51" accel-mods="4">
               <action>exit:Quit</action>
            </menuitem>
         </menu>
         <menu use-underline="true" label="_Code">
            <menuitem stock-id="gtk-refresh">
               <variable>muiMenuitemRoute</variable>
               <action>echo MenuitemRoute 2</action>
               <action>refresh:entMenuitemRoute</action>
               <action>echo MenuitemRoute 3</action>
            </menuitem>
         </menu>
      </menubar>
      <vbox border-width="50">
         <hbox>
            <button image-position="1">
               <label>Activate</label>
               <input file stock="gtk-go-forward"></input>
               <action>echo ButtonRoute 0</action>
               <action>activate:btnButtonRoute</action>
               <action>echo ButtonRoute 1</action>
            </button>
            <button image-position="1">
               <variable>btnButtonRoute</variable>
               <label>Refresh</label>
               <input file stock="gtk-go-forward"></input>
               <action>echo ButtonRoute 2</action>
               <action>refresh:entButtonRoute</action>
               <action>echo ButtonRoute 3</action>
            </button>
            <entry>
               <variable>entButtonRoute</variable>
               <input>"'$RandomGet'"</input>
            </entry>
         </hbox>
         <hbox>
            <button image-position="1">
               <label>Activate</label>
               <input file stock="gtk-go-forward"></input>
               <action>echo MenuitemRoute 0</action>
               <action>activate:muiMenuitemRoute</action>
               <action>echo MenuitemRoute 1</action>
            </button>
            <text label="Refresh"></text>
            <pixmap stock-icon-size="3">
               <input file stock="gtk-go-forward"></input>
            </pixmap>
            <entry>
               <variable>entMenuitemRoute</variable>
               <input>"'$RandomGet'"</input>
            </entry>
         </hbox>
      </vbox>
   </vbox>
</window>
'
export MAIN_DIALOG

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

Regards,
Thunor

Edited_time_total
Back to top
View user's profile Send_private_message Visit_website 
RSH


Joined: 05 Sep 2011
Posts: 2420
Location: Germany

PostPosted: Mon 07 Jan 2013, 12:38    Post_subject:  

Hi.

I wanted to test the above posted script but it gives me an gtkdialog error in gtkdialog3, gtidialog4 and gtkdialog5.

Which version is used for this script?

RSH

_________________
LazY Puppy
RSH's DNA
SARA B.
Back to top
View user's profile Send_private_message 
Display_posts:   Sort by:   
Page 48 of 64 Posts_count   Goto page: Previous 1, 2, 3, ..., 46, 47, 48, 49, 50, ..., 62, 63, 64 Next
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » Off-Topic Area » Programming
Jump to:  

Rules_post_cannot
Rules_reply_cannot
Rules_edit_cannot
Rules_delete_cannot
Rules_vote_cannot
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1796s ][ Queries: 13 (0.0206s) ][ GZIP on ]