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
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#961 Post 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.

_____________________________________________________

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

#962 Post 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
___________________________________________________

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

#963 Post by don570 »

I came across this Trusty Tahr version of gtkdialog

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

__________________________________________________

inops
Posts: 1
Joined: Fri 02 Jan 2015, 23:22

#964 Post 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.

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

#965 Post 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

User avatar
Bert
Posts: 1103
Joined: Fri 30 Jun 2006, 20:09

#966 Post 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!
[url=http://pupsearch.weebly.com/][img]http://pupsearch.weebly.com/uploads/7/4/6/4/7464374/125791.gif[/img][/url]
[url=https://startpage.com/do/search?q=host%3Awww.murga-linux.com%2F][img]http://i.imgur.com/XJ9Tqc7.png[/img][/url]

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#967 Post 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  

User avatar
Bert
Posts: 1103
Joined: Fri 30 Jun 2006, 20:09

#968 Post 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!
[url=http://pupsearch.weebly.com/][img]http://pupsearch.weebly.com/uploads/7/4/6/4/7464374/125791.gif[/img][/url]
[url=https://startpage.com/do/search?q=host%3Awww.murga-linux.com%2F][img]http://i.imgur.com/XJ9Tqc7.png[/img][/url]

User avatar
SFR
Posts: 1800
Joined: Wed 26 Oct 2011, 21:52

Go home widgets, you're drunk!

#969 Post 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!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]

radky
Posts: 977
Joined: Mon 03 May 2010, 03:13

Re: Go home widgets, you're drunk!

#970 Post by radky »

SFR wrote:Yet another useless, nice-looking though, trick.
I'm very dizzy now! :D
[color=blue][b][url=http://www.smokey01.com/radky/PupMates.html]PupMates[/url][/b][/color]

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

Re: Go home widgets, you're drunk!

#971 Post by zigbert »

SFR wrote:Yet another useless, nice-looking though, trick. :wink:
:lol:

User avatar
xanad
Posts: 400
Joined: Fri 28 Feb 2014, 14:56
Location: 2 locations: MonteRosa Alp and Milano
Contact:

#972 Post by xanad »

:shock: ahahahah.... gtk-vumeter or gtk-compiz or gtk-alert or gtk-warning or.....
[url]http://www.xanad.tk[/url] Html5 Parallax

User avatar
mavrothal
Posts: 3096
Joined: Mon 24 Aug 2009, 18:23

#973 Post 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.
Attachments
Classic_scroll.jpg
(38.31 KiB) Downloaded 324 times
== [url=http://www.catb.org/esr/faqs/smart-questions.html]Here is how to solve your[/url] [url=https://www.chiark.greenend.org.uk/~sgtatham/bugs.html]Linux problems fast[/url] ==

User avatar
LazY Puppy
Posts: 1934
Joined: Fri 21 Nov 2014, 18:14
Location: Germany

#974 Post 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...
RSH

"you only wanted to work your Puppies in German", "you are a separatist in that you want Germany to secede from Europe" (musher0) :lol:

No, but I gave my old drum kit away for free to a music store collecting instruments for refugees! :wink:

User avatar
SFR
Posts: 1800
Joined: Wed 26 Oct 2011, 21:52

#975 Post 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!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]

User avatar
mavrothal
Posts: 3096
Joined: Mon 24 Aug 2009, 18:23

#976 Post 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:
== [url=http://www.catb.org/esr/faqs/smart-questions.html]Here is how to solve your[/url] [url=https://www.chiark.greenend.org.uk/~sgtatham/bugs.html]Linux problems fast[/url] ==

User avatar
SFR
Posts: 1800
Joined: Wed 26 Oct 2011, 21:52

#977 Post 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!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]

User avatar
mavrothal
Posts: 3096
Joined: Mon 24 Aug 2009, 18:23

#978 Post 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:
== [url=http://www.catb.org/esr/faqs/smart-questions.html]Here is how to solve your[/url] [url=https://www.chiark.greenend.org.uk/~sgtatham/bugs.html]Linux problems fast[/url] ==

User avatar
fabrice_035
Posts: 765
Joined: Mon 28 Apr 2014, 17:54
Location: Bretagne / France

#979 Post 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/

User avatar
mister_electronico
Posts: 969
Joined: Sun 20 Jan 2008, 20:20
Location: Asturias_ España
Contact:

Question?

#980 Post 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

Post Reply