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 Mon 20 Nov 2017, 11:45
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 65 of 82 [1226 Posts]   Goto page: Previous 1, 2, 3, ..., 63, 64, 65, 66, 67, ..., 80, 81, 82 Next
Author Message
don570


Joined: 10 Mar 2010
Posts: 4755
Location: Ontario

PostPosted: Thu 18 Dec 2014, 16:59    Post subject:  

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:

[ ! -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.

_____________________________________________________
Back to top
View user's profile Send private message 
don570


Joined: 10 Mar 2010
Posts: 4755
Location: Ontario

PostPosted: Wed 24 Dec 2014, 13:04    Post subject:  

OOps wrong Embarassed I need to read the file with cat command

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


___________________________________________________
Back to top
View user's profile Send private message 
don570


Joined: 10 Mar 2010
Posts: 4755
Location: Ontario

PostPosted: Wed 24 Dec 2014, 13:25    Post subject:  

I came across this Trusty Tahr version of gtkdialog

https://launchpad.net/~geinux/+archive/ubuntu/lanzadoc/+files/gtkdialog_0.8.4_i386.deb

__________________________________________________
Back to top
View user's profile Send private message 
inops

Joined: 02 Jan 2015
Posts: 1

PostPosted: Fri 02 Jan 2015, 19:57    Post subject:  

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:
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.
Back to top
View user's profile Send private message 
don570


Joined: 10 Mar 2010
Posts: 4755
Location: Ontario

PostPosted: Sat 03 Jan 2015, 16:41    Post subject:  

Quote:
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.php?p=756690#756690
Back to top
View user's profile Send private message 
Bert


Joined: 30 Jun 2006
Posts: 1105

PostPosted: Sat 10 Jan 2015, 17:59    Post subject:  

Back to basics Wink

I've been playing with zigbert's
Quote:
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!

_________________


Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1390
Location: Japan

PostPosted: Mon 12 Jan 2015, 04:55    Post subject:  

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:
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:
#!/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 
Back to top
View user's profile Send private message 
Bert


Joined: 30 Jun 2006
Posts: 1105

PostPosted: Mon 12 Jan 2015, 09:52    Post subject:  

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 Laughing

Thanks a lot, MochiMoppel!

_________________


Back to top
View user's profile Send private message 
SFR


Joined: 26 Oct 2011
Posts: 1641

PostPosted: Tue 27 Jan 2015, 16:43    Post subject: Go home widgets, you're drunk!  

Yet another useless, nice-looking though, trick. Wink
Code:
#!/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!

_________________
[O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
Back to top
View user's profile Send private message 
radky

Joined: 02 May 2010
Posts: 744

PostPosted: Tue 27 Jan 2015, 17:08    Post subject: Re: Go home widgets, you're drunk!  

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

I'm very dizzy now! Very Happy

_________________
PupMates
Back to top
View user's profile Send private message 
zigbert


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

PostPosted: Tue 27 Jan 2015, 17:24    Post subject: Re: Go home widgets, you're drunk!  

SFR wrote:
Yet another useless, nice-looking though, trick. Wink
Laughing
_________________
Stardust resources
Back to top
View user's profile Send private message Visit poster's website 
xanad


Joined: 28 Feb 2014
Posts: 400
Location: 2 locations: MonteRosa Alp and Milano

PostPosted: Wed 28 Jan 2015, 06:15    Post subject:  

Shocked ahahahah.... gtk-vumeter or gtk-compiz or gtk-alert or gtk-warning or.....
_________________
www.xanad.tk Html5 Parallax
Back to top
View user's profile Send private message Visit poster's website 
mavrothal


Joined: 24 Aug 2009
Posts: 2908

PostPosted: Thu 05 Feb 2015, 06:23    Post subject:  

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:
<hbox>
  <text><label>$(gettext 'Repo:')</label></text>
  ${DB_ORDERED}
 </hbox>

where
Code:
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:
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.
Classic_scroll.jpg
 Description   
 Filesize   38.31 KB
 Viewed   255 Time(s)

Classic_scroll.jpg


_________________
== Here is how to solve your Linux problems fast ==
Back to top
View user's profile Send private message 
LazY Puppy


Joined: 21 Nov 2014
Posts: 2007
Location: Germany

PostPosted: Thu 05 Feb 2015, 07:22    Post subject:  

Try using the tag below in <vbox> and/or <hbox>:

Code:
space-expand=\"true\" space-fill=\"true\"


or

Code:
space-expand="true" space-fill="true"


or

Code:
space-expand=\"false\" space-fill=\"false\"


or

Code:
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) Laughing

No, but I gave my old drum kit away for free to a music store collecting instruments for refugees! Wink
Back to top
View user's profile Send private message 
SFR


Joined: 26 Oct 2011
Posts: 1641

PostPosted: Thu 05 Feb 2015, 07:44    Post subject:  

@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:
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!

_________________
[O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 65 of 82 [1226 Posts]   Goto page: Previous 1, 2, 3, ..., 63, 64, 65, 66, 67, ..., 80, 81, 82 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1416s ][ Queries: 14 (0.0299s) ][ GZIP on ]