GtkDialog - tips

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
brokenman
Posts: 25
Joined: Thu 20 Oct 2011, 23:00

#631 Post by brokenman »

Thanks very much. I understand now.

User avatar
8-bit
Posts: 3406
Joined: Wed 04 Apr 2007, 03:37
Location: Oregon

#632 Post by 8-bit »

First, I am not going to post an example for this since the example Barry posted in Cutting Edge - Gtkdialog can be used to show what I am talking about.
In the Country selection one, if one clicks on the down arrow to show the item choices, a selection window is shown that has a height that takes the full height of my display with additional up and down arrows at each end of that window.
My question is:

Since one has to use the additional up/down arrows in that window, is it possible to specify the height of it?
It would sure help in cleaning up the looks of it for selection of country/language/keyboard if the popup selection window was a given height.

I tried changing <comboboxtext> to <combobox> throughout the script and to me, I think it helped. The height is still there in the selection windows, but the change gave a vertical scrollbar that helps in locating a selection.

User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

#633 Post by Argolance »

Hello,
Please, see this thread: => Converting gtkdialog3 script into gtkdialog4 problem...

Thank you.

Cordialement.
[SOLVED] Thanks thunor!
Last edited by Argolance on Thu 17 Nov 2011, 08:17, edited 1 time in total.

User avatar
Geoffrey
Posts: 2355
Joined: Sun 30 May 2010, 08:42
Location: Queensland

#634 Post by Geoffrey »

I was trying to find a way to center the text in a label in a tree list, but came across this by accident

Code: Select all

<tree> 
		<label>'"_MY LIST OF STUFF"'</label>
this gives the label bar a keyboard control of Alt+M, I didn't see this mentioned anywhere else, so I thought I'd pass it on.

Geoffrey
Attachments
tree_list.jpg
(4.42 KiB) Downloaded 1242 times

User avatar
darkcity
Posts: 2534
Joined: Sun 23 May 2010, 19:16
Location: near here
Contact:

#635 Post by darkcity »

updated wiki

http://puppylinux.org/wikka/PBurn

is this limitation still true?
It will only perform the writing function with a blank disc, i.e. the disc is either new, or, as in the case of a re-writable disc, it has been erased first.

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

#636 Post by zigbert »

darkcity wrote:updated wiki

http://puppylinux.org/wikka/PBurn

is this limitation still true?
It will only perform the writing function with a blank disc, i.e. the disc is either new, or, as in the case of a re-writable disc, it has been erased first.
What is the origin for that statement? (If it is in the docs, I should remove it) It is not true. In those cases where burning require a blank disc (ie. audio-CD), user will get an option to erase disc before burning.


Thank you for maintaining the wiki !!!!!
Sigmund

User avatar
darkcity
Posts: 2534
Joined: Sun 23 May 2010, 19:16
Location: near here
Contact:

#637 Post by darkcity »

(Opps, I was meant to post in PBurn) anyhow, the origin is unknown to me - probably from a very old version of PBurn. Fixed it now ; -)

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

#638 Post by smokey01 »

I'm trying to find a way to include a progress bar into a small GUI.

It needs to be able to show copying and burning DVD's

I'm trying to use the following example as a starting point:

Code: Select all

#! /bin/bash

export MAIN_DIALOG='
<vbox>
  <frame Progress>
    <text>
      <label>Some text describing what is happening.</label>
    </text>
    <progressbar>
      <label>Time left</label>
      <input>for i in $(seq 0 10 100); do echo $i; sleep 0.3; done</input>
      <action type="exit">Ready</action>
    </progressbar>
  </frame>
  <hbox>
   <button cancel></button>
  </hbox>
 </vbox>
'
gtkdialog --program=MAIN_DIALOG

How do I calculate the percentages and parse the info to the progress bar?

Thanks

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

#639 Post by seaside »

smokey01,

You can find an example of a progress bar with percentages in PupsaveRestore by 8-bit.

See -
http://www.murga-linux.com/puppy/viewtopic.php?t=72153

Regards,
s

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

#640 Post by smokey01 »

seaside wrote:smokey01,

You can find an example of a progress bar with percentages in PupsaveRestore by 8-bit.

See -
http://www.murga-linux.com/puppy/viewtopic.php?t=72153

Regards,
s
Thanks seaside.

I have already seen 8-bits code but am looking for a simpler example.

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

#641 Post by technosaurus »

There is a simple progress bar example in /usr/share/doc/gtkdialog3 (in the devx)
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].

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

Variable/Function as button's label?

#642 Post by SFR »

Hi

Is it possible to show variable or function's result as a button's label (<button></button>)?
I tried with <input>, <input file...>, <label> and nothing works...

Thanks in advance.

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]

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

Re: Variable/Function as button's label?

#643 Post by seaside »

SFR wrote:Hi

Is it possible to show variable or function's result as a button's label (<button></button>)?
I tried with <input>, <input file...>, <label> and nothing works...

Thanks in advance.

Greetings!
SFR,

Perhaps this is what you want-

Code: Select all

#! /bin/bash
LABEL=`echo result of some program`
export MAIN_DIALOG='
     <button>
      <label>'"$LABEL"'</label>
      <action>echo new label '"$LABEL"' created</action>
    </button>
  
'

gtkdialog3 --program=MAIN_DIALOG 
This would take the result of some program (in this case the phrase "result of some program") and assign it to the variable LABEL. Note that $LABEL is surrounded by double quotes followed by outer single quotes.

Cheers,
s

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

Re: Variable/Function as button's label?

#644 Post by SFR »

seaside wrote:Perhaps this is what you want-

Code: Select all

#! /bin/bash
LABEL=`echo result of some program`
export MAIN_DIALOG='
     <button>
      <label>'"$LABEL"'</label>
      <action>echo new label '"$LABEL"' created</action>
    </button>
  
'

gtkdialog3 --program=MAIN_DIALOG 
This would take the result of some program (in this case the phrase "result of some program") and assign it to the variable LABEL. Note that $LABEL is surrounded by double quotes followed by outer single quotes.
This is exactly it, thanks very much!
I was stuck focusing myself on functions, your method is much easier. :)

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
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

timer example

#645 Post by 01micko »

This is a simplified timer widget example. The timer widget is not visible.

Requires gtkdialog >= 0.8.0 (you may need to change the call to "gtkdialog4" in wary/racy/lupu)

Thanks to technosaurus for the text2svg function. (@ techno, the header is needed to stop gtkdialog and other gtk apps from segfaulting, coutesy of thunor).

Code: Select all

#!/bin/bash
# timertest

# Functions====================================================================
text2svg()
{
#generate an image
WIDTH=$(($(echo "$1"|wc -c)*19))
T=35
BG="$2"
echo '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
  <rect width="'$WIDTH'"
     height="50"
     x="0"
     y="0"
     style="font-size:'${T}';fill:'$BG';fill-opacity:0.75;fill-rule:evenodd;stroke-width:3pt;"
     id="rect1" />
  <text
     x="0"
     y="35"
     style="font-size:'${T}';font-weight:normal;fill-opacity:0.75;stroke-width:3pt;font-family:helvetica;"
     id="text1">
    <tspan
       id="tspan1">'"${1}"'</tspan>
  </text>
</svg>' > /tmp/${3}.svg
}
export -f text2svg

randomfunc(){
echo "some random number $RANDOM"
}
export -f randomfunc

pixfunc(){
DATE=`date`	
text2svg "${DATE}" "#ADD8E6" date
	}
export -f pixfunc

btnfunc(){
TXT=`cat /tmp/timerfile`
case $TXT in
the)echo quick >/tmp/timerfile;text2svg quick "#0000FF" label ;;
quick)echo brown >/tmp/timerfile;text2svg brown "#00FFFF" label ;;
brown)echo fox >/tmp/timerfile;text2svg fox "#FF0000" label ;;
fox)echo jumped >/tmp/timerfile;text2svg jumped "#00FF00" label ;;
jumped)echo over >/tmp/timerfile;text2svg over "#FFFF00" label ;;
over)echo a >/tmp/timerfile;text2svg a "#FF00FF" label ;;
a)echo lazy >/tmp/timerfile;text2svg lazy "#FF9500" label ;;
lazy)echo dog >/tmp/timerfile;text2svg dog "#FF00AA" label ;;
dog)echo the >/tmp/timerfile;text2svg the "#FFFFFF" label ;;
esac
}
export -f btnfunc
#==============================================================================

echo dog >/tmp/timerfile
pixfunc
btnfunc

export gui='<window>
 <vbox>
  <text><label>timer test</label></text>
  <pixmap>
    <variable>PIX</variable>
    <input file>/tmp/date.svg</input>
  </pixmap> 
  <hbox homogeneous="true">  
   <button tooltip-text="exit">
    <variable>BTX</variable>
    <input file>/tmp/label.svg</input>
   </button>
  </hbox>
  <text><variable>VAR</variable><input>date +%T</input></text>
  <text><variable>RANDNUM</variable><input>randomfunc</input></text>
  <entry><variable>ENTRY</variable><input>echo $RANDOM is random too</input></entry>
  <timer interval="1" visible="false">
    <action>pixfunc</action>
    <action>btnfunc</action>
    <action type="refresh">PIX</action>
    <action type="refresh">BTX</action>
    <action type="refresh">VAR</action>
    <action type="refresh">RANDNUM</action>
    <action type="refresh">ENTRY</action>
  </timer> 
  <hbox>
   <button ok></button>
  </hbox>
 </vbox>
</window>'
eval $(gtkdialog -p gui)
case $EXIT in
*)rm -f /tmp/*.svg ;;
esac

Puppy Linux Blog - contact me for access

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

#646 Post by technosaurus »

It often comes up how to get wget to give you the percent complete (for progress bars), so I grokked it out to work with Xdialog (I am working on some gtk1 stuff right now) - perhaps someone would like to tweak it for gtkdialog?

Code: Select all

download_progress(){
while ([ $# -gt 0 ]) do
	wget -v $1 -o /dev/stdout | while read LINE; do
		case $LINE in
			*%*)LINE=${LINE##*..};echo ${LINE%%%*};;
		esac
	done |Xdialog --gauge "Download progress ($# files remaining.)
Current file is:
$1" 0 0
	shift
done
}
and here is one for curl:
{export your CURL_PARAMETERS first}

Code: Select all

upload_progress(){
curl --progress-bar $CURL_PARAMETERS 2>&1 \
| tr "\r" "\n"|sed "s,# *,,gm" \
| Xdialog --title "Progress" --gauge "$1 \n transfering ..." 0 0
}
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].

User avatar
Dougal
Posts: 2502
Joined: Wed 19 Oct 2005, 13:06
Location: Hell more grotesque than any medieval woodcut

#647 Post by Dougal »

technosaurus wrote:It often comes up how to get wget to give you the percent complete (for progress bars), so I grokked it out to work with Xdialog (I am working on some gtk1 stuff right now) - perhaps someone would like to tweak it for gtkdialog?
Gtkdialog enables you to run a shell inside the progressbar element, so you can just sort the wget output inside it... that's what I did with the dhcpcd progressbars (note that with gtkdialog, when you echo a number, it is used for the percentage, while echoing text changes what's displayed in the progressbar).
What's the ugliest part of your body?
Some say your nose
Some say your toes
But I think it's your mind

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#648 Post by jpeps »

Here's one solution to a combo-checklist. I was looking for a simple way to create a useable array for the whole checklist.

Code: Select all

#!/bin/sh

#Combo-Checklist example

export NUM="5"
 function funcChkCreate() {
 
 for ((i=1;i<"$NUM";i++)); do
    echo '<checkbox>
      <label>NAME '"$i"'</label>
      <variable>STAT'"$i"'</variable>
     </checkbox>'
 done
    
  }
ComboCheck() {

echo
for ((i=1;i<"$NUM";i++)); do
eval echo "NAME ${i}=""\$STAT${i}" >/tmp/out
var[$i]=`cat /tmp/out`
echo "${var[$i]}"
  done
 
}
export -f ComboCheck

export MAIN_DIALOG='

<vbox height="150" scrollable="true">
'"$(funcChkCreate)"'
<hbox>
<button>
  <label>ComboCheck</label>
  <action>ComboCheck</action>
</button>
<button ok></button>
</hbox>
</vbox>
'
gtkdialog --program=MAIN_DIALOG

User avatar
RSH
Posts: 2397
Joined: Mon 05 Sep 2011, 14:21
Location: Germany

#649 Post by RSH »

jpeps wrote:Here's one solution to a combo-checklist. I was looking for a simple way to create a useable array for the whole checklist.
Hi.

I think it would be more comfortable to have the buttons outside the scrollable section.

Code: Select all

#!/bin/sh

#Combo-Checklist example

export NUM="15"
 function funcChkCreate() {
 
 for ((i=1;i<"$NUM";i++)); do
    echo '<checkbox>
      <label>NAME '"$i"'</label>
      <variable>STAT'"$i"'</variable>
     </checkbox>'
 done
   
  }
ComboCheck() {

echo
for ((i=1;i<"$NUM";i++)); do
eval echo "NAME ${i}=""\$STAT${i}" >/tmp/out
var[$i]=`cat /tmp/out`
echo "${var[$i]}"
  done
 
}
export -f ComboCheck

export MAIN_DIALOG='
<vbox>
<vbox height="150" scrollable="true">
'"$(funcChkCreate)"'
</vbox>
<vbox>
<hbox>
<button>
  <label>ComboCheck</label>
  <action>ComboCheck</action>
</button>
<button ok></button>
</hbox>
</vbox>
</vbox>'
gtkdialog --program=MAIN_DIALOG
Attachments
combocheck-buttoons-outside.jpg
(10.49 KiB) Downloaded 1197 times
[b][url=http://lazy-puppy.weebly.com]LazY Puppy[/url][/b]
[b][url=http://rshs-dna.weebly.com]RSH's DNA[/url][/b]
[url=http://murga-linux.com/puppy/viewtopic.php?t=91422][b]SARA B.[/b][/url]

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#650 Post by jpeps »

Good idea, RSH. I just incorporated that into gnewpet.

Post Reply