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 Wed 20 Aug 2014, 05:10
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 53 of 64 Posts_count   Goto page: Previous 1, 2, 3, ..., 51, 52, 53, 54, 55, ..., 62, 63, 64 Next
Author Message
ASRI éducation


Joined: 09 May 2009
Posts: 2400
Location: France

PostPosted: 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!
Wink
Back to top
View user's profile Send_private_message Visit_website 
ASRI éducation


Joined: 09 May 2009
Posts: 2400
Location: France

PostPosted: 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.
Wink
Back to top
View user's profile Send_private_message Visit_website 
SFR


Joined: 26 Oct 2011
Posts: 1052

PostPosted: 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! Laughing

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!
Screenshot.png
 Description   
 Filesize   8.43 KB
 Viewed   520 Time(s)

Screenshot.png


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


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

PostPosted: Wed 14 Aug 2013, 03:03    Post_subject:  

Quote:
Nested expanders - can be used for 'tree-view' of folders.
Really nice Very Happy
_________________
Stardust resources
Back to top
View user's profile Send_private_message Visit_website 
smokey01


Joined: 30 Dec 2006
Posts: 1801
Location: South Australia

PostPosted: 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

_________________
Puppy Software <-> Distros <-> Puppy Linux Tips
Back to top
View user's profile Send_private_message Visit_website 
SFR


Joined: 26 Oct 2011
Posts: 1052

PostPosted: 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. Wink
Anyway, hope it'll help you somehow.
________________

zigbert wrote:
Quote:
Nested expanders - can be used for 'tree-view' of folders.
Really nice Very Happy

Thanks! Smile

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 Rolling Eyes ).
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!
Screenshot.png
 Description   
 Filesize   22.93 KB
 Viewed   455 Time(s)

Screenshot.png


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


Joined: 30 Dec 2006
Posts: 1801
Location: South Australia

PostPosted: Thu 15 Aug 2013, 01:31    Post_subject:  

SFR,

I sent you a PM.

_________________
Puppy Software <-> Distros <-> Puppy Linux Tips
Back to top
View user's profile Send_private_message Visit_website 
technosaurus


Joined: 18 May 2008
Posts: 4334

PostPosted: 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

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send_private_message 
koulaxizis


Joined: 17 Jul 2011
Posts: 428
Location: Greece

PostPosted: 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! Laughing

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 packages | Puppy search ]
Back to top
View user's profile Send_private_message Visit_website 
SFR


Joined: 26 Oct 2011
Posts: 1052

PostPosted: 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!). Embarassed

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. Rolling Eyes
___________________

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
View user's profile Send_private_message 
koulaxizis


Joined: 17 Jul 2011
Posts: 428
Location: Greece

PostPosted: 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! Smile

_________________
Christos Koulaxizis
Woof woof from Greece...

[ Puppy packages | Puppy search ]
Back to top
View user's profile Send_private_message Visit_website 
koulaxizis


Joined: 17 Jul 2011
Posts: 428
Location: Greece

PostPosted: 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 packages | Puppy search ]
Back to top
View user's profile Send_private_message Visit_website 
box579

Joined: 29 Jul 2013
Posts: 3

PostPosted: 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. Smile
If yes, maybe a slight hint how would be perfect.

Thanks & regards,
Box579.
Back to top
View user's profile Send_private_message 
SFR


Joined: 26 Oct 2011
Posts: 1052

PostPosted: 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
View user's profile Send_private_message 
Nathan F


Joined: 08 Jun 2005
Posts: 1760
Location: Wadsworth, OH (occasionally home)

PostPosted: 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
View user's profile Send_private_message AIM YIM MSNM 
Display_posts:   Sort by:   
Page 53 of 64 Posts_count   Goto page: Previous 1, 2, 3, ..., 51, 52, 53, 54, 55, ..., 62, 63, 64 Next
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » Off-Topic Area » Programming
Jump to:  

Rules_post_cannot
Rules_reply_cannot
Rules_edit_cannot
Rules_delete_cannot
Rules_vote_cannot
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1594s ][ Queries: 13 (0.0199s) ][ GZIP on ]