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 Fri 19 Sep 2014, 23:02
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 62 of 64 [951 Posts]   Goto page: Previous 1, 2, 3, ..., 60, 61, 62, 63, 64 Next
Author Message
SFR


Joined: 26 Oct 2011
Posts: 1068

PostPosted: Mon 27 Jan 2014, 18:22    Post subject:  

Can8v, <combobox> is rather deprecated - how about <comboboxentry> or <comboboxtext> instead, which have <input file> tag, what makes importing data much easier?

Here's a sample:
Code:
DEVICE_FILE="/root/my-applications/bin/activeMTPdevices.txt"

export DEVICE_DIALOG_LIST='
<window title="The list">
  <vbox>

    <comboboxtext active="0">
      <variable>RESULT</variable>
      <input file>'${DEVICE_FILE}'</input>
    </comboboxtext>

    <hbox>
      <button ok>
        <action>exit:PROCEED</action>
      </button>
      <button cancel>
        <action>exit:CANCEL</action>
      </button>
    </hbox>
 
  </vbox>
</window>'


# In order to access returned variables, we have to evaluate them first
eval `gtkdialog --program DEVICE_DIALOG_LIST`


# EXIT states "PROCEED" and "CANCEL" are defined above, but "abort" is internal
if [ "$EXIT" = "PROCEED" ]; then
  xmessage "$RESULT"   #show the result
elif [ "$EXIT" = "CANCEL" ]; then
  xmessage "Cancelled"
elif [ "$EXIT" = "abort" ]; then
  xmessage "Window closed via X"
fi

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 
can8v

Joined: 15 Jul 2006
Posts: 584
Location: Yuba City, CA

PostPosted: Mon 27 Jan 2014, 22:26    Post subject:  

@SFR
Thanks so much for this.
Back to top
View user's profile Send private message Visit poster's website 
Puma

Joined: 09 Oct 2012
Posts: 7

PostPosted: Sat 22 Feb 2014, 10:33    Post subject: Gtkdialog -get notebook tabnumber  

could one explain why this code works

Code:
export MAIN='
<notebook>
  <frame><text><label>first tab</label></text></frame>
  <frame><text><label>second tab</label></text></frame>
  <frame><text><label>third tab</label></text></frame>
 
  <variable>VAR</variable>
  <action signal="button-release-event">[ $VAR -eq 0 ] && xmessage "first tab"</action>
  <action signal="key-release-event">[ $VAR -eq 0 ] && xmessage "first tab"</action>
  <action signal="button-release-event">[ $VAR -eq 1 ] && xmessage "second tab"</action>
  <action signal="key-release-event">[ $VAR -eq 1 ] && xmessage "second tab"</action>
  <action signal="button-release-event">[ $VAR -eq 2 ] && xmessage "third tab"</action>
  <action signal="key-release-event">[ $VAR -eq 2 ] && xmessage "third tab"</action>
 
</notebook>'

gtkdialog -cp MAIN


and this not

Code:
export MAIN="
<notebook>

  <frame><text><label>\"first tab\"</label></text></frame>
  <frame><text><label>\"second tab\"</label></text></frame>
  <frame><text><label>\"third tab\"</label></text></frame>
 
  <variable>nTabPage</variable>
   
  <action signal=\"button-release-event\">[ $nTabPage -eq 0 ] && xmessage \"first tab\"</action>
  <action signal=\"button-release-event\">[ $nTabPage -eq 1 ]  && xmessage \"second tab\"</action>   

</notebook>"

gtkdialog -cp MAIN


also i tried

Code:
I=$IFS; IFS=""
for STATEMENTS in  $(PumaGui.pmx -cp MAIN); do
  eval $STATEMENTS
done
IFS=$I


the only different is the double qoute sign.

thanks in advance

[/quote]
Back to top
View user's profile Send private message 
Puma

Joined: 09 Oct 2012
Posts: 7

PostPosted: Sat 22 Feb 2014, 10:36    Post subject: sorry last code should read  

I=$IFS; IFS=""
for STATEMENTS in $(gtkdialog -cp MAIN); do
eval $STATEMENTS
done
IFS=$I
Back to top
View user's profile Send private message 
SFR


Joined: 26 Oct 2011
Posts: 1068

PostPosted: Sat 22 Feb 2014, 11:22    Post subject:  

Puma wrote:
the only different is the double qoute sign.

When you're using double quotes instead of single ones, the variables between <action>...</action> tags get evaluated instead of being exported literally as strings, so in result (since nTabPage var is null at this stage) MAIN contains:
Quote:
<action signal="button-release-event">[ -eq 0 ] && xmessage "first tab"</action>

That's why I prefer s. quotes - much less hassle with escaping, etc.
Anyway, this will work:
Code:
[ "'$nTabPage'" -eq 0 ]

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 
zigbert


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

PostPosted: Sat 22 Feb 2014, 11:24    Post subject:  

Try a slash in front of $
Code:
<action signal=\"button-release-event\">[ \$nTabPage -eq 0 ] && xmessage \"first tab\"</action>

_________________
Stardust resources
Back to top
View user's profile Send private message Visit poster's website 
don570


Joined: 10 Mar 2010
Posts: 3287
Location: Ontario

PostPosted: Sat 22 Feb 2014, 16:40    Post subject:  

I found that it is possible to force a button to bottom of list by a simple
trick. ---> text widget gets space-expand="true"

Code:

<vbox>
<button>....</button>
...
...
<text space-expand="true"><label>""</label></text>

<button>...</button>
</vbox>


Note the button in right bottom corner. The button doesn't go
all the way to bottom, but close enough.
Back to top
View user's profile Send private message 
Puma

Joined: 09 Oct 2012
Posts: 7

PostPosted: Sun 23 Feb 2014, 14:31    Post subject: notebook tab refresh  

Thanks all for the quick reply. Code example of SFR works perfect but a new
problem arised. First some explanation.

At the moment i developed a Wary Distribution with special attention to server administration of VNC, PureFtp, Hiawatha (WebServer), PHP, and MySql.

Name of the distribution is Pumalix (Pu for Puppy, Ma for Part of my Name and Lix for Linux). Distribution is based on Wary becauce of old Bios support.

Included are Firefox (latest Version), PlayOnLinux, Gimp, Virtual Box and many more. Also i adapted all GtkDialog code to support multilingual appearance.

All is controlled by a GUI shown in attachement. Each Tab of the GUI is represented by a string variable which is allocated by a Function.

Because there is some code behind each Tab (especially ther Server Tab)
i would like to avoid running this code if only Tab one is shown. In this
case only code for Tab one should run and for the other tabs there is a simple dummy function running.

But if you click Tab two then the content of the represented string should change by calling the appropriate function.

Do do this i miss a event or something i can refresh after click.

below a simple code example.


Code:
#! /bin/bash


########################  EXPORT Variablen  ##############################

export cTabBlank
export cTabPage1
export cTabPage2
export cTabPage3

#typeset -i nTabPage=0
#declare -i nTabPage=1

########################  EXPORT Functions  ##############################

function GetTabPage1()
{
  cTabPage1="<frame>
    <text>
      <label>\"first tab\"</label>
    </text>
  </frame>"
 
  echo $cTabPage1
}
export -f GetTabPage1


#########################################################################

function GetTabPage2()
{
  cTabPage2="<frame>
    <text>
      <label>\"second tab\"</label>
    </text>
  </frame>"
 
  echo $cTabPage2
}
export -f GetTabPage2


#########################################################################

function GetTabPage3()
{
  cTabPage3="<frame>
    <text>
      <label>\"third tab\"</label>
    </text>
  </frame>"
 
  echo $cTabPage3
}
export -f GetTabPage3

#########################################################################

function GetTabBlank()
{
  cTabBlank="<frame>
    <text>
      <label>\"blank tab\"</label>
    </text>
  </frame>"
 
  echo $cTabBlank
}
export -f GetTabBlank

#########################################################################

function OnTabPageChanged()
{
  declare -i local nActPage

  nActPage=$1

  if [ $nActPage -eq 0 ]; then
    xmessage "content of tab one is allways the same, no changes needed"
    #cTabPage1=$(GetTabPage1)
  elif [ $nActPage -eq 1 ]; then
    xmessage "content of tab two should change by changing variable cTabPage2"
    cTabPage2=$(GetTabPage2)   
  elif [ $nActPage -eq 2 ]; then
   xmessage "content of tab three should change by changing variable cTabPage3"
   cTabPage3=$(GetTabPage3)
  fi 
 
}
export -f OnTabPageChanged


####################  INIT Notebook Tabs ################################

cTabPage1=$(GetTabPage1)
cTabPage2=$(GetTabBlank)
cTabPage3=$(GetTabBlank)

#############################  M A I N ##################################

export MAIN="
<notebook>

  $cTabPage1
  $cTabPage2
  $cTabPage3
 
  <variable>nTabPage</variable>
  <action signal=\"button-release-event\">[ "'$nTabPage'" -eq 0 ] && OnTabPageChanged "'$nTabPage'" && refresh:nTabPage</action>
  <action signal=\"button-release-event\">[ "'$nTabPage'" -eq 1 ] && OnTabPageChanged "'$nTabPage'" && refresh:nTabPage</action>
  <action signal=\"button-release-event\">[ "'$nTabPage'" -eq 2 ] && OnTabPageChanged "'$nTabPage'" && refresh:nTabPage</action>     

</notebook>"

#############################  T E S T ##################################

#I=$IFS; IFS=""
#for STATEMENTS in  $(gtkdialog -cp MAIN   ); do
#  eval $STATEMENTS
#done
#IFS=$I

gtkdialog -cp MAIN   

##################### UNSET Functions ################################

unset GetTabBlank
unset GetTabPage1
unset GetTabPage2
unset GetTabPage3
unset OnTabPageChanged

##################### UNSET Variablen ################################

unset cTabBlank
unset cTabPage1
unset cTabPage2
unset cTabPage3
Back to top
View user's profile Send private message 
Puma

Joined: 09 Oct 2012
Posts: 7

PostPosted: Sun 23 Feb 2014, 14:38    Post subject: screenshoot of control gui  

see attachment
Last edited by Puma on Tue 25 Feb 2014, 15:26; edited 7 times in total
Back to top
View user's profile Send private message 
Puma

Joined: 09 Oct 2012
Posts: 7

PostPosted: Sun 23 Feb 2014, 14:46    Post subject: next try image upload  

as embedded image

[img]/home/puma/Desktop/ServerControl.png[/img]

Last edited by Puma on Sun 23 Feb 2014, 14:56; edited 1 time in total
Back to top
View user's profile Send private message 
Puma

Joined: 09 Oct 2012
Posts: 7

PostPosted: Sun 23 Feb 2014, 14:48    Post subject: s o r r y  

cant upload any image neither as embedded image nor attachment
Back to top
View user's profile Send private message 
don570


Joined: 10 Mar 2010
Posts: 3287
Location: Ontario

PostPosted: Thu 27 Feb 2014, 21:00    Post subject:  

When I post an image I use photobucket.com as a server,
then I can use <IMG>.....</IMG> tags
_________________________________________________
Back to top
View user's profile Send private message 
thanius

Joined: 04 Feb 2014
Posts: 8

PostPosted: Tue 04 Mar 2014, 16:31    Post subject: Regarding updating pixmaps  

I just wrote an ad cycler and thought I'd share some on the pixmap updater. I saw the example here but I found it more clean to make symbolic links instead of copying the files. Here's my ad cycler:

Code:
#!/bin/bash

ln -fs ad1.png ad.png
echo 2 > /tmp/count

function cycle_ad {

# Because gtkdialog won't handle global vars for some retarded reason!
i=`cat /tmp/count`

if [ -e "ad$i.png" ]; then
  ln -fs ad$i.png ad.png
  echo $i+1|bc > /tmp/count
else
  ln -fs ad1.png ad.png
  echo 2 > /tmp/count
fi

}

export MAIN='
<window width-request="600" height-request="400">

<vbox homogeneous="true">
 <pixmap>
  <variable>IMAGE</variable>
  <input file>ad.png</input>
 </pixmap>
 
 <timer milliseconds="false" interval="13" visible="false">
   <action>exec $SHELL -c cycle_ad</action>
   <action>sleep 2</action>
   <action type="refresh">IMAGE</action>
 </timer>

</vbox>
</window>'

export -f cycle_ad

gtkdialog --center --program=MAIN
Back to top
View user's profile Send private message 
brokenman

Joined: 20 Oct 2011
Posts: 25

PostPosted: Mon 28 Apr 2014, 21:08    Post subject: Always on top
Subject description: Keeping gtkdialog always on top in openbox
 

Keeping a gtkdialog app 'always on top'

I've just read that this is possible in jwm using the .jwmrc file and launching the gtkdialog as a --class=APPLET. Is there an inbuilt way to do the same in openbox?

This could probably be achieved with other methods inside the openbox rc.xml file but I am wondering if something similar to the JWM solution si viable.
Back to top
View user's profile Send private message 
disciple

Joined: 20 May 2006
Posts: 6435
Location: Auckland, New Zealand

PostPosted: Mon 28 Apr 2014, 21:18    Post subject:  

"other methods inside the openbox rc.xml file" sounds similar to "using the .jwmrc file" to me...
_________________
DEATH TO SPREADSHEETS
- - -
Classic Puppy quotes
- - -
Beware the demented serfers!
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 62 of 64 [951 Posts]   Goto page: Previous 1, 2, 3, ..., 60, 61, 62, 63, 64 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.1282s ][ Queries: 13 (0.0232s) ][ GZIP on ]