The time now is Thu 21 Jan 2021, 22:24
All times are UTC - 4 |
Page 53 of 101 [1505 Posts] |
Goto page: Previous 1, 2, 3, ..., 51, 52, 53, 54, 55, ..., 99, 100, 101 Next |
Author |
Message |
ASRI éducation

Joined: 09 May 2009 Posts: 3203 Location: France
|
Posted: Wed 31 Jul 2013, 05:47 Post subject:
|
|
box579 wrote: | Hi ASRI education,
to prevent users from editing your items use <comboboxtext> instead of <combobox>. See below, for specs read this:
http://code.google.com/p/gtkdialog/wiki/comboboxtext
Code: | <vbox>
<text><label>Live Support</label></text>
<comboboxtext width-request=\""$COMBOBOX_WIDTH"\" tooltip-text=\" Select the live support \">
<variable>CheckLiveSupport</variable>
$LIVE_SUPPORT_ITEMS
</comboboxtext>
</vbox> |
BR, box579. |
This is exactly what I needed.
A big thank you!
|
Back to top
|
|
 |
ASRI éducation

Joined: 09 May 2009 Posts: 3203 Location: France
|
Posted: Wed 31 Jul 2013, 07:09 Post subject:
|
|
@ zigbert
May be, it could be interesting to add this info in the first message.
Cordialement,
ASRI éducation wrote: | Hello !
I'm trying to create a GUI (GTK) and I need help.
I use the combobox option and I do not want the user could edit the items offered (so that he can choose only in the list of items proposed by the script).
Currently, my combobox like this:
Code: | <vbox>
<text><label>Live Support</label></text>
<combobox width-request=\""$COMBOBOX_WIDTH"\" tooltip-text=\" Select the live support \">
<variable>CheckLiveSupport</variable>
$LIVE_SUPPORT_ITEMS
</combobox>
</vbox> |
My question: is it possible to prevent the publishing of the items proposed by the combobox?
Cordialement, |
box579 wrote: | Hi ASRI education,
to prevent users from editing your items use <comboboxtext> instead of <combobox>. See below, for specs read this:
http://code.google.com/p/gtkdialog/wiki/comboboxtext
Code: | <vbox>
<text><label>Live Support</label></text>
<comboboxtext width-request=\""$COMBOBOX_WIDTH"\" tooltip-text=\" Select the live support \">
<variable>CheckLiveSupport</variable>
$LIVE_SUPPORT_ITEMS
</comboboxtext>
</vbox> |
BR, box579. |
ASRI éducation wrote: | This is exactly what I needed.
 |
|
Back to top
|
|
 |
SFR

Joined: 26 Oct 2011 Posts: 1802
|
Posted: Tue 13 Aug 2013, 14:39 Post subject:
Nested expanders |
|
Does anyone did it before?
Nested expanders - can be used for 'tree-view' of folders.
Hack on a hack pushed by another hack, but works beautifully!
Ok, so who's gonna write a routine that recursively parses directory tree and dynamically builds a GUI?
Not me - no way!
Code: | #!/bin/bash
# Pure Mess v1.0 ;)
# Nested expanders example by SFR'2013
# Tricky as hell (chaos with vbox/hbox and alignment), but works like a charm!
# Requires Gtkdialog >= 0.8.1
file_select () {
xmessage --center "'$@' has been selected..."
}
export -f file_select
export MAIN='
<window title="Recursive expander">
<vbox spacing="0">
<expander label="directory 1" space-fill="false" space-expand="false">
<vbox spacing="0">
<hbox>
<text space-fill="false" space-expand="false"><label>" "</label></text>
<vbox spacing="0">
<expander label="directory 2" space-fill="false" space-expand="false">
<vbox spacing="0">
<hbox>
<text space-fill="false" space-expand="false"><label>" "</label></text>
<vbox spacing="0">
<expander label="dir3" space-fill="false" space-expand="false">
<vbox spacing="0">
<hbox>
<text space-fill="false" space-expand="false"><label>" "</label></text>
<button relief="2" space-fill="false" space-expand="false">
<label>bla bla 1</label>
<action>file_select bla bla 1</action>
</button>
<text space-fill="true" space-expand="true"><label>" "</label></text>
</hbox>
<hbox>
<text space-fill="false" space-expand="false"><label>" "</label></text>
<button relief="2" space-fill="false" space-expand="false">
<label>bla bla 2</label>
<action>file_select bla bla 2</action>
</button>
<text space-fill="true" space-expand="true"><label>" "</label></text>
</hbox>
</vbox>
</expander>
</vbox>
<text space-fill="true" space-expand="true"><label>" "</label></text>
</hbox>
<hbox>
<text space-fill="false" space-expand="false"><label>" "</label></text>
<button relief="2" space-fill="false" space-expand="false">
<label>somefile1 in dir2</label>
<action>file_select somefile1</action>
</button>
<text space-fill="true" space-expand="true"><label>" "</label></text>
</hbox>
<hbox>
<text space-fill="false" space-expand="false"><label>" "</label></text>
<button relief="2" space-fill="false" space-expand="false">
<label>somefile2 in dir2</label>
<action>file_select somefile2</action>
</button>
<text space-fill="true" space-expand="true"><label>" "</label></text>
</hbox>
<hbox>
<text space-fill="false" space-expand="false"><label>" "</label></text>
<button relief="2" space-fill="false" space-expand="false">
<label>and one more file in dir2</label>
<action>file_select one more file</action>
</button>
<text space-fill="true" space-expand="true"><label>" "</label></text>
</hbox>
</vbox>
</expander>
<hbox>
<button relief="2" space-fill="false" space-expand="false">
<label>File in directory 1</label>
<action>file_select file from first dir</action>
</button>
<text space-fill="true" space-expand="true"><label>" "</label></text>
</hbox>
</vbox>
<text space-fill="true" space-expand="true"><label>" "</label></text>
</hbox>
</vbox>
</expander>
</vbox>
</window>
'
gtkdialog -cp MAIN |
Greetings!
Description |
|
Filesize |
8.43 KB |
Viewed |
1154 Time(s) |

|
_________________ [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
|
|
 |
zigbert

Joined: 29 Mar 2006 Posts: 6629 Location: Valåmoen, Norway
|
Posted: Wed 14 Aug 2013, 03:03 Post subject:
|
|
Quote: | Nested expanders - can be used for 'tree-view' of folders. | Really nice
_________________ Stardust resources
|
Back to top
|
|
 |
smokey01

Joined: 30 Dec 2006 Posts: 2820 Location: South Australia :-(
|
Posted: Wed 14 Aug 2013, 03:53 Post subject:
|
|
Is it possible to have variables in gtkdialog that include dots? EG: firstname.surname="Billy Bloggs"
Can this be saved to a config file and be reloaded after changes have been made.
Without the dots it works fine but the variables I need to use, have dots in the name.
TIA
_________________ Software <-> Distros <-> Tips <-> Newsletters
|
Back to top
|
|
 |
SFR

Joined: 26 Oct 2011 Posts: 1802
|
Posted: Wed 14 Aug 2013, 08:40 Post subject:
|
|
Hi Smokey
I'm not sure if I understand what exactly you want to achieve (maybe a short example?), but since Bash won't accept a variable with a dot:
Code: | # some.var=5
bash: some.var=5: command not found
# |
then probably Gtkdialog too.
I assume you have those "variables" stored in some file, haven't you?
So you could (before using) replace the dot with e.g. _underline , like this:
Code: | # eval $(echo 'some.var="Smith, John A."' | sed '0,/\./s/\./_/')
# echo $some_var
Smith, John A.
# |
and, after change has been made, but before saving to a file, replace it back:
Code: | # some_var="Brown, James E."
# echo "$(echo some_var | sed '0,/\_/s/\_/./')=\"$some_var\"" > storefile
# cat storefile
some.var="Brown, James E."
# |
But this method isn't too pretty.
Anyway, hope it'll help you somehow.
________________
zigbert wrote: | Quote: | Nested expanders - can be used for 'tree-view' of folders. | Really nice  |
Thanks!
I just wrote crude and simple equivalent of 'tree' in Bash, but I think I'll pass on trying to write dynamic GUI builder.
Besides, I'm afraid that Gtk(dialog) can have serious problems in handling such amount of widgets (thousands of expanders + buttons ).
But perhaps it would work nice with some small, local structures..?
Anyway, here's the 'tree' code, maybe someone find it useful:
Code: | #!/bin/bash
# Simple equivalent of 'tree' in Bash by SFR'2013
parse_dirs () {
CWD="$1"
cd "$CWD"
local DIRS=( $(find -maxdepth 1 -mindepth 1 -type d | sort | grep -v "$CWD$" | cut -f2 -d'/') )
local FILES=( $(find -maxdepth 1 -mindepth 1 ! -type d | sort | cut -f2 -d'/') )
if [ ${#DIRS[@]} -ne 0 ]; then
while read LINE; do
echo -e "${INDENT}${BLUECOL}$LINE${OFFCOL}"
INDENT="${INDENT} "
parse_dirs "$LINE"
done <<< `echo ${DIRS[@]}`
fi
if [ ${#FILES[@]} -ne 0 ]; then
while read LINE; do
echo "${INDENT}$LINE"
done <<< `echo ${FILES[@]}`
fi
unset DIRS FILES
INDENT=$(echo "${INDENT%?}")
cd ..
}
CWD="$1"
[ ! "$CWD" ] && CWD="`pwd`"
[ ! -d "$CWD" ] && echo "Directory doesn't exist!" && exit 1
BLUECOL="\e[0;34m"
OFFCOL="\e[00m"
OLD_IFS=$IFS; IFS=' '
echo -e "${BLUECOL}$(basename "$CWD")${OFFCOL}"
INDENT=" "
parse_dirs "$CWD"
IFS=$OLD_IFS
exit |
Greetings!
Description |
|
Filesize |
22.93 KB |
Viewed |
1087 Time(s) |

|
_________________ [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
|
|
 |
smokey01

Joined: 30 Dec 2006 Posts: 2820 Location: South Australia :-(
|
Posted: Thu 15 Aug 2013, 01:31 Post subject:
|
|
SFR,
I sent you a PM.
_________________ Software <-> Distros <-> Tips <-> Newsletters
|
Back to top
|
|
 |
technosaurus

Joined: 18 May 2008 Posts: 4878 Location: Blue Springs, MO
|
Posted: Thu 15 Aug 2013, 02:06 Post subject:
|
|
SFR wrote: | I just wrote crude and simple equivalent of 'tree' in Bash, but I think I'll pass on trying to write dynamic GUI builder. | I threw a recursive one together a couple years ago (also terminal only, I think it is in the bashbox thread)
... btw you can handle more widgets in older versions of gtkdialog (I think this is unneeded in newer versions) if you pipe the xml | gtkdialog -s instead of using an env variable for it
_________________ Check out my github repositories. I may eventually get around to updating my blogspot.
|
Back to top
|
|
 |
koulaxizis

Joined: 17 Jul 2011 Posts: 455 Location: Greece
|
Posted: Thu 15 Aug 2013, 08:45 Post subject:
|
|
I have just started playing with gtkdialog and i have a (rather stupid) question:
How can i set action for the chosen entry into a combobox, after pressing OK?
The script is a simple shutdown timer with 3 options for now: one hour, two hours and three hours
It was easy to make it with buttons but i can't understand how to do it with combobox! :/
This is my first effort, so stop mocking me!
Any help?
Code: | #!/bin/sh
GTKDIALOG=gtkdialog
export DIALOG='
<window title="Go to sleep" window_position="1">
<vbox>
<frame Shutdown computer in...>
<hbox>
<combobox>
<variable>COMBOBOX</variable>
<item>one hour</item>
<item>two hours</item>
<item>three hours</item>
</combobox>
</hbox>
</frame>
<hbox>
<button>
<label>Sleep</label>
<action>exec $COMBOBOX</action>
</button>
<button cancel></button>
</hbox>
</vbox>
</window>
'
$GTKDIALOG --program=DIALOG
|
_________________ Christos Koulaxizis
Woof woof from Greece!
[ Puppy Stuff Repository ]
|
Back to top
|
|
 |
SFR

Joined: 26 Oct 2011 Posts: 1802
|
Posted: Thu 15 Aug 2013, 09:52 Post subject:
|
|
technosaurus wrote: | SFR wrote: | I just wrote crude and simple equivalent of 'tree' in Bash, but I think I'll pass on trying to write dynamic GUI builder. | I threw a recursive one together a couple years ago (also terminal only, I think it is in the bashbox thread)
... btw you can handle more widgets in older versions of gtkdialog (I think this is unneeded in newer versions) if you pipe the xml | gtkdialog -s instead of using an env variable for it |
Hey Techno
Yeah, I found it in your bashbox:
Code: | tree() { #show a cli visualization of directories and files
for x in `ls $1`; do [ -d $1/$x ] && echo "$2\`-{"$x && tree $1/$x "$2 " || echo "$2\`-<"$x; done
} |
And now I'm embarrassed that it can be done with just a single line (vs. mine ~40!).
As for Gtkdialog, in such cases I use external files, but anyway with such amount of data it could take about 10-20 sec before GUI will appear.
___________________
koulaxizis wrote: | How can i set action for the chosen entry into a combobox, after pressing OK? |
Hi Koulaxizis
One of possibilities:
Code: | <button>
<label>Sleep</label>
<action>xmessage --center "Computer will shut down in ${COMBOBOX}." &</action>
<action>exit:EXIT</action>
</button> |
then, instead of 'xmessage' stuff you can put a call to your function that will compare $COMBOBOX and set timer properly.
HTH
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
|
|
 |
koulaxizis

Joined: 17 Jul 2011 Posts: 455 Location: Greece
|
Posted: Thu 15 Aug 2013, 10:31 Post subject:
|
|
SFR wrote: |
Hi Koulaxizis
One of possibilities:
Code: | <button>
<label>Sleep</label>
<action>xmessage --center "Computer will shut down in ${COMBOBOX}." &</action>
<action>exit:EXIT</action>
</button> |
then, instead of 'xmessage' stuff you can put a call to your function that will compare $COMBOBOX and set timer properly.
HTH
Greetings! |
Thanks! Seems like i have a lot of reading to do and a long road to go if i want to create something useful!
_________________ Christos Koulaxizis
Woof woof from Greece!
[ Puppy Stuff Repository ]
|
Back to top
|
|
 |
koulaxizis

Joined: 17 Jul 2011 Posts: 455 Location: Greece
|
Posted: Thu 15 Aug 2013, 10:43 Post subject:
|
|
Well, i have settled to this:
Code: | GTKDIALOG=gtkdialog
export DIALOG='
<window title="Go to sleep" window_position="1">
<vbox>
<frame Shutdown computer in...>
<hbox>
<entry>
<default>...seconds</default>
<variable>ENTRY</variable>
</entry>
</hbox>
</frame>
<text>
<label>30 minutes = 1800 seconds</label>
</text>
<text>
<label>60 minutes = 3600 seconds</label>
</text>
<text>
<label>90 minutes = 5400 seconds</label>
</text>
<hseparator></hseparator>
<hbox>
<button>
<label>Sleep</label>
<action>sleep "$ENTRY" && wmpoweroff &</action>
<action>exit:EXIT</action>
</button>
<button cancel></button>
</hbox>
</vbox>
</window>
'
$GTKDIALOG --program=DIALOG |
How can i improve it? What should i do to make it more handy?
_________________ Christos Koulaxizis
Woof woof from Greece!
[ Puppy Stuff Repository ]
|
Back to top
|
|
 |
box579
Joined: 29 Jul 2013 Posts: 3
|
Posted: Fri 16 Aug 2013, 01:51 Post subject:
|
|
Hi all,
I'm still in question whether there's any chance to have a list/table/tree with checkboxes in first column. Like I asked on the previous page of this thread:
Quote: | is there any option to have checkboxes within a gtkdialog tree/list/table? I would like to select multiple items.
Input is optained from a textfile:
monitor1|true|option1
monitor2|false|option2
monitor3|true|option3
Output is written to a textfile.
|
A simple yes/no would be enough.
If yes, maybe a slight hint how would be perfect.
Thanks & regards,
Box579.
|
Back to top
|
|
 |
SFR

Joined: 26 Oct 2011 Posts: 1802
|
Posted: Fri 16 Aug 2013, 06:11 Post subject:
|
|
box579 wrote: | any chance to have a list/table/tree with checkboxes in first column |
AFAIK it's not possible, but if you want to select multiple rows, why not use:
<tree selection-mode="3">
tree_selection_mode
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
|
|
 |
Nathan F

Joined: 08 Jun 2005 Posts: 1760 Location: Wadsworth, OH (occasionally home)
|
Posted: Fri 16 Aug 2013, 12:19 Post subject:
|
|
@koulaxizis - check out the comboboxtext and comboboxentry widgets, which are more powerful than the stock combobox.
For comboboxtext, the default signal is "changed", which is emitted when you choose another selection in the combobox. So you can easily do some useful things with it. The following example lists the contents of all the hidden directories in your home folder in the tree widget.
Code: | <vbox>
<comboboxtext tooltip-text="List contents of your dotdirs">
<variable>COMB1</variable>
<input>find $HOME -maxdepth 1 -mindepth 1 -type d -name '.*'</input>
<default>$HOME/.config</default>
<action>refresh:TREE1</action>
</comboboxtext>
<tree>
<label>Contents</label>
<variable>TREE1</variable>
<input>ls \$COMB1</input>
</tree>
<button ok></button>
</vbox> |
Hope that's helpful in the future even though you settled on a different approach.
_________________ Bring on the locusts ...
|
Back to top
|
|
 |
|
Page 53 of 101 [1505 Posts] |
Goto page: Previous 1, 2, 3, ..., 51, 52, 53, 54, 55, ..., 99, 100, 101 Next |
|
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
|