Page 49 of 76

Posted: Thu 18 Dec 2014, 20:59
by don570
Here is the way I tested my script.

1) I created a folder in /root called test

2) I ran the script so that the destination folder is /root/test

3) I trashed the folder

4) I ran the script again. I saw that the initial folder choice is /root/test
which may cause confusion. That is why I suggested that there be a
test of the existence of the destination folder
(Note that the file 'destination' holds the folder name including path)

Code: Select all

[ ! -d  $WORKDIR/destination ]  && echo "/root" > $WORKDIR/destination 
______________________________________________________

Your script is very clever. I never thought of doing it that way however
profession programmers prefer to modify configuration files
in case a write-to-disk operation is faulty. With your script the script would be damaged
and the entire app would have to be installed again.

_____________________________________________________

Posted: Wed 24 Dec 2014, 17:04
by don570
OOps wrong :oops: I need to read the file with cat command

Code: Select all

[ ! -d  $(cat $WORKDIR/destination) ]  && echo "/root" > $WORKDIR/destination
___________________________________________________

Posted: Wed 24 Dec 2014, 17:25
by don570
I came across this Trusty Tahr version of gtkdialog

https://launchpad.net/~geinux/+archive/ ... 4_i386.deb

__________________________________________________

Posted: Fri 02 Jan 2015, 23:57
by inops
Hi guys.

Any idea how I could get the "X" button in the top right of a window to a run a function, i.e. a confirmation of closing?

I know you can do this:

Code: Select all

for STATEMENTS in  $(gtkdialog --program DIALOG); do
  eval $STATEMENTS
done
if [ "$EXIT" = "abort" ]; then
  echo "You entered: $ENTRY."
fi
but I want the GUI to stay while this is asked, to allow the user to go back to it if they click "no" on "Are you sure you want to close".

Thanks, Inops.

Posted: Sat 03 Jan 2015, 20:41
by don570
Any idea how I could get the "X" button in the top right of a window to a run a function
The only app that leaves Xwindows is Zigbert's ptiming
There's a button that the user clicks to leave X windows and put
up a digital clock. I think the user can come back to X windows???

I made an interesting app that doesn't leave X windows.
You might study it. I was learning how to use the togglebutton widget.
http://www.murga-linux.com/puppy/viewtopic.php?t=92152
http://murga-linux.com/puppy/viewtopic.php?t=91989
http://murga-linux.com/puppy/viewtopic. ... 690#756690

Posted: Sat 10 Jan 2015, 21:59
by Bert
Back to basics :wink:

I've been playing with zigbert's
5.) The benefits of a config file
in the first post of this thread.
Can someone explain why the contents of the config file become invisible in Geany? It changes to an invisible one-liner (security?).

I tested creating different config files for other scripts and they all become "invisible" as soon as the main script is activated.

Why?
Thanks for any help!

Posted: Mon 12 Jan 2015, 08:55
by MochiMoppel
Bert wrote:Can someone explain why the contents of the config file become invisible in Geany? It changes to an invisible one-liner (security?)
The first code example Set status of Radiobuttons, Comboboxes... contains a bug. The last line

Code: Select all

gtkdialog -p main > $HOME/.testrc
writes the status/contents of the 3 widgets to the config file - provided you leave the dialog via the "OK" button. If you close it with Alt+F4 or with the X button, only the line EXIT="abort" will be written to the config file. The next time you try to open the dialog, it will not work at all and an empty string will be written to $HOME/.testrc. This is one way to create an "invisible one-liner". After the next try the dialog will then open with the default values (same as if no $HOME/.testrc exists). There are other ways to trash the config file, basically any error in gtkdialog will do.

IMO it would be better to test the output for EXIT="OK", and only in this case write the new defaults to $HOME/.testrc.
And while you play with it, you might want to replace the outdated combobox widget ("deprecated since GTK+ 2.4") with a comboboxtext or comboboxentry widget. This will eliminate the odd workaround to put the default item at the top of the list, which results in having this item in the list twice.

Here a quick fix of zigbert's code which should work better:

Code: Select all

#!/bin/sh
#in case no testc file (first run), build the file 
 [ ! -s $HOME/.testrc ] && echo -e -n 'COMBOBOX="item 3"\nENTRY="default text"\nRADIOBUTTON1="false"\nRADIOBUTTON2="true"\n' > $HOME/.testrc 
 . $HOME/.testrc 
 #define comboboxtext list items 
 COMBOBOX_DEFAULT="$COMBOBOX"
 for I in 1 2 3 4; do COMBOBOX_ITEMS=`echo "$COMBOBOX_ITEMS<item>item $I</item>"`; done 
 export main=" 
 <window title="The benefits of a config file"> 
  <vbox> 
   <frame The first item of list is the default choice in a Combobox> 
    <comboboxtext> 
     <variable>COMBOBOX</variable> 
     <default>$COMBOBOX_DEFAULT</default>
     $COMBOBOX_ITEMS
    </comboboxtext> 
   </frame> 
   <frame If nothing else is set, the first radiobutton is the active one> 
    <radiobutton> 
     <variable>RADIOBUTTON1</variable> 
     <label>Yes I am</label> 
     <default>$RADIOBUTTON1</default> 
    </radiobutton> 
    <radiobutton> 
     <variable>RADIOBUTTON2</variable> 
     <label>No I'm not</label> 
     <default>$RADIOBUTTON2</default> 
    </radiobutton> 
   </frame> 
   <frame Fetch entry-value from config file> 
    <entry> 
     <variable>ENTRY</variable> 
     <default>$ENTRY</default> 
    </entry> 
   </frame> 
   <hbox> 
    <button ok></button> 
   </hbox> 
  </vbox> 
 </window>" 
 I=$IFS; IFS="" 
 for STATEMENTS in  $(gtkdialog -p main); do 
    eval $STATEMENTS 
 done 
 IFS=$I 
 [ "$EXIT" = "OK" ] && echo -n "$STATEMENTS" > $HOME/.testrc  

Posted: Mon 12 Jan 2015, 13:52
by Bert
What a perfectly helpful reply!

The problems you describe are exactly what I experienced.
MochiMoppel wrote:There are other ways to trash the config file, basically any error in gtkdialog will do.
Good to know :lol:

Thanks a lot, MochiMoppel!

Go home widgets, you're drunk!

Posted: Tue 27 Jan 2015, 20:43
by SFR
Yet another useless, nice-looking though, trick. :wink:

Code: Select all

#!/bin/bash

SIN=( $(awk 'BEGIN { for (i=0; i<=32; i++) printf("%.0f\n", sin(i*(3.14/16))*16+16)}') )

export MAIN='
<window resizable="false" width-request="300" height-request="300">
  <notebook show-tabs="false" show-border="false">
    '$(for i in {0..31}; do
      echo '
      <vbox spacing="'${SIN[$(((i+0)&31))]}'">
        <hseparator></hseparator>
        <vbox spacing="'${SIN[$(((i+5)&31))]}'">
          <entry></entry>
          <vbox spacing="'${SIN[$(((i+10)&31))]}'">
            <hbox homogeneous="true"><checkbox></checkbox></hbox>
            <vbox spacing="'${SIN[$(((i+15)&31))]}'">
              <hbox spacing="'${SIN[$((i&31))]}'" homogeneous="true">
                <radiobutton></radiobutton>
                <radiobutton></radiobutton>
              </hbox>
              <vbox spacing="'${SIN[$(((i+20)&31))]}'">
                <hscale range-value="50"></hscale>
                <vbox spacing="'${SIN[$(((i+25)&31))]}'">
                  <comboboxentry></comboboxentry>
                  <vbox spacing="'${SIN[$(((i+30)&31))]}'">
                    <hseparator></hseparator>
                    <button ok></button>
                  </vbox>
                </vbox>
              </vbox>
            </vbox>
          </vbox>
        </vbox>
      </vbox>';
    done)'
    <variable>varINDEX</variable>
    <input>echo $(( (varINDEX+1) & 31 ))</input>
  </notebook>
  <timer visible="false" milliseconds="true" interval="50">
    <action>refresh:varINDEX</action>
  </timer>
</window>'

gtkdialog -p MAIN
Greetings!

Re: Go home widgets, you're drunk!

Posted: Tue 27 Jan 2015, 21:08
by radky
SFR wrote:Yet another useless, nice-looking though, trick.
I'm very dizzy now! :D

Re: Go home widgets, you're drunk!

Posted: Tue 27 Jan 2015, 21:24
by zigbert
SFR wrote:Yet another useless, nice-looking though, trick. :wink:
:lol:

Posted: Wed 28 Jan 2015, 10:15
by xanad
:shock: ahahahah.... gtk-vumeter or gtk-compiz or gtk-alert or gtk-warning or.....

Posted: Thu 05 Feb 2015, 10:23
by mavrothal
I do not have any tips to offer but I would appreciate one.
The clasic UI of PPM has the repos on top in a simple hbox as

Code: Select all

<hbox>
  <text><label>$(gettext 'Repo:')</label></text>
  ${DB_ORDERED}
 </hbox>
where

Code: Select all

DB_ORDERED="$REPOS_RADIO"
# and 
REPOS_RADIO="${REPOS_RADIO}<radiobutton space-expand=\"false\" space-fill=\"false\"><label>${xREPOCUT}</label>
<action>/tmp/filterversion.sh ${REPOCUT}</action><action>/usr/local/petget/filterpkgs.sh</action>
<action>refresh:TREE1</action></radiobutton>"
# This is a single line. Just added breaks so will not mess you web page
Adding

Code: Select all

scrollable=\"true\"
so the window will not grow when we add more repos, works but the hight of the hbox is now very high (see pick) and no matter what options I tried I failed to make more narrow.

I do not really know if there is a magic option for the hbox or if some tag should be added to the <radiobutton> (tried few) to achieve this and I would appreciate any hint.

Posted: Thu 05 Feb 2015, 11:22
by LazY Puppy
Try using the tag below in <vbox> and/or <hbox>:

Code: Select all

space-expand=\"true\" space-fill=\"true\"
or

Code: Select all

space-expand="true" space-fill="true"
or

Code: Select all

space-expand=\"false\" space-fill=\"false\"
or

Code: Select all

space-expand="false" space-fill="false"
or combinations etc...

Posted: Thu 05 Feb 2015, 11:44
by SFR
@Mav: Hmm, <height></height> might help, but the problem is that what looks (more or less) good if scrollbar is visible, doesn't look so good if it's not visible.
Try this and then try again with width-request="600", to see what I mean:

Code: Select all

echo '
<window width-request="300">
  <hbox scrollable="true" homogeneous="true">
    <radiobutton></radiobutton>
    <radiobutton></radiobutton>
    <radiobutton></radiobutton>
    <radiobutton></radiobutton>
    <height>48</height>
  </hbox>
</window>' | gtkdialog -s
Perhaps hscrollbar-policy="0" (always visible) is the way to go..?

Greetings!

Posted: Thu 05 Feb 2015, 12:09
by mavrothal
Thanks SFR, the <height> attribute did it.
(I was trying height-request that is apparently ignored)

What are you up to these days?... :wink:

Posted: Thu 05 Feb 2015, 12:44
by SFR
mavrothal wrote:What are you up to these days?... :wink:
I took a vacation from Slacko for now and been playing with FD64 for last couple of months, although I'm still tracking what's going on in Woof-CE. 8)

Greetings!

Posted: Fri 06 Feb 2015, 20:38
by mavrothal
SFR wrote:
mavrothal wrote:What are you up to these days?... :wink:
I took a vacation from Slacko for now and been playing with FD64 for last couple of months, although I'm still tracking what's going on in Woof-CE. 8)
If you are into 64s, I believe slacko64 is going to be an orphan if not an orphan already... :wink:

Posted: Sat 21 Feb 2015, 14:32
by fabrice_035
Hello,

I am not sure but i think it's not possible with Tree-widget to :

1) show number of selected row
2) export all selected column in variable

could you please confirm ?


Regard/

Question?

Posted: Wed 25 Mar 2015, 20:29
by mister_electronico
Hi I'm trying to create a rotary knob by a svg image
I want to create an event every time I press the picture with the mouse but can not find how to do it.

I do not know how to do it but the idea would do something like this

Code: Select all

<pixmap>
    <input file>./rotary1.svg</input>
    <action signal="clicked">exec somescript</action>
</pixmap>
I know that this does not work but this would be the idea.

Any idea
Thanks ... greetings